本文整理汇总了C#中System.Windows.Forms.OpenFileDialog类的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Forms.OpenFileDialog类的具体用法?C# System.Windows.Forms.OpenFileDialog怎么用?C# System.Windows.Forms.OpenFileDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Windows.Forms.OpenFileDialog类属于命名空间,在下文中一共展示了System.Windows.Forms.OpenFileDialog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AddFilm
public void AddFilm()
{
var ofd = new System.Windows.Forms.OpenFileDialog
{
};
if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;
var fileInfo = new FileInfo(ofd.FileName);
var closeableTabItem = new CloseableTabItem
{
Header = fileInfo.Name,
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch,
Content = new FilmEditor(ofd.FileName)
};
if ((string) closeableTabItem.Header == "swag") return;
foreach (var tabb in homeTabControl.Items.Cast<TabItem>().Where(tabb => tabb.Header == closeableTabItem.Header))
{
homeTabControl.SelectedItem = tabb;
return;
}
homeTabControl.Items.Add(closeableTabItem);
homeTabControl.SelectedItem = closeableTabItem;
}
开发者ID:0xdeafcafe,项目名称:vintage,代码行数:27,代码来源:Home.xaml.cs
示例2: Action
public override bool Action(string action)
{
bool result = base.Action(action);
if (result)
{
if (action == ACTION_IMPORT)
{
using (System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog())
{
dlg.FileName = "";
dlg.Filter = "*.gcc|*.gcc|*.*|*.*";
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
_errormessage = "";
_filename = dlg.FileName;
_importMissing = System.Windows.Forms.MessageBox.Show(string.Concat(Utils.LanguageSupport.Instance.GetTranslation(STR_IMPORTMISSING),"?"), Utils.LanguageSupport.Instance.GetTranslation(ACTION_IMPORT), System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question, System.Windows.Forms.MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes;
PerformImport();
if (!string.IsNullOrEmpty(_errormessage))
{
System.Windows.Forms.MessageBox.Show(_errormessage, Utils.LanguageSupport.Instance.GetTranslation(STR_ERROR), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
}
}
}
}
}
return result;
}
开发者ID:RH-Code,项目名称:GAPP,代码行数:27,代码来源:Import.cs
示例3: ChangePictureButton_Click
private void ChangePictureButton_Click(object sender, RoutedEventArgs e)
{
try
{
if (track != null)
{
var dialog = new System.Windows.Forms.OpenFileDialog();
dialog.Filter = "Image Files (*.jpg,*.jpeg,*.png,*.gif)|*.jpg;*.jpeg;*.png;*.gif|All Files (*.*)|*.*";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (track.Path.EndsWith(".mp3"))
{
tagController.AddPicture(track, dialog.FileName);
}
else
{
track.ImagePath = dialog.FileName;
trackController.Save(track);
}
}
}
}
catch (Exception ex)
{
log.Error("MediaPropertyView.ChangePictureButton_Click", ex);
MessageBox.Show("There was an error trying to add a picture to this track.\n\n" + ex.Message, "Could Not Add Picture To Track");
}
}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:28,代码来源:MediaPropertyView.xaml.cs
示例4: GetProperyField
public override FrameworkElement GetProperyField()
{
var pan = new DockPanel();
t = (new TextBox());
try
{
t.Text = GetVaueAsType<ImageSource>().ToString();
}
catch { }//Null value
t.TextChanged += delegate(object sender, TextChangedEventArgs e) { SetString(t.Text); };
var btn = new Button();
btn.Content = "...";
btn.Click += delegate
{
var fpd = new System.Windows.Forms.OpenFileDialog();
fpd.Filter = "Images|*.jpg;*.jpeg;*.png;*.gif;*.tif;*.bmp";
if (fpd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
t.Text = fpd.FileName;
}
};
DockPanel.SetDock(btn, Dock.Right);
pan.Children.Add(btn);
pan.Children.Add(t);
return pan;
}
开发者ID:byteit101,项目名称:ZomB-Dashboard-System,代码行数:26,代码来源:ImageSourceDesigner.cs
示例5: UploadNewAvatar
private async void UploadNewAvatar(object sender, MouseButtonEventArgs e)
{
var dialog = new System.Windows.Forms.OpenFileDialog
{
DefaultExt = ".png",
InitialDirectory = Environment.SpecialFolder.MyPictures.ToString(),
Title = "Select a new avatar",
Filter = "Image files | *.png; *.jpg; *.bmp"
};
dialog.ShowDialog();
var mimeType = "image/";
if (String.IsNullOrEmpty(dialog.FileName)) return;
if (dialog.SafeFileName == null) return;
if (dialog.SafeFileName.EndsWith(".png")) mimeType += "png";
else if (dialog.SafeFileName.ToLower().EndsWith(".jpg")) mimeType += "jpg";
else if (dialog.SafeFileName.EndsWith(".bmp")) mimeType += "bmp";
else
{
dialog.Dispose();
App.Connection.NotificationController.Notification.Notify("That's not a supported file type! Please try again.");
return;
}
await App.Connection.SessionController.CurrentSession.UploadAvatar(
new FileStream(dialog.FileName, FileMode.Open), mimeType);
dialog.Dispose();
}
开发者ID:Conji,项目名称:Cloudsdale-Win7,代码行数:31,代码来源:Settings.xaml.cs
示例6: CreateContent
public UIElement CreateContent(string fileName)
{
Grid grid_main = new Grid();
grid_main.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(100.0, GridUnitType.Star) });
grid_main.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
m_textBox_fileName = new TextBox();
m_textBox_fileName.TextChanged += (sender, args) => { FileName = m_textBox_fileName.Text; };
m_textBox_fileName.Text = fileName;
grid_main.SetGridRowColumn(m_textBox_fileName, 0, 0);
Button button_openFile = new Button() { Content = "Select file ..." };
button_openFile.Click += (x, y) =>
{
System.Windows.Forms.OpenFileDialog openFileDialog =
new System.Windows.Forms.OpenFileDialog()
{
CheckFileExists = false,
CheckPathExists = true
};
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
m_textBox_fileName.Text = openFileDialog.FileName;
};
grid_main.SetGridRowColumn(button_openFile, 0, 1);
return grid_main;
}
开发者ID:ianeller-romey,项目名称:GinTub_TLATEOTH,代码行数:27,代码来源:Window_SelectFile.cs
示例7: LoginDoor
public LoginDoor()
{
InitializeComponent();
var ass = System.Reflection.Assembly.GetExecutingAssembly().GetName();
Title = (ass.Name + " v" + ass.Version) + " 登陆界面";
DataContext = this;
//portTextBox.Text = TextBox_TextChanged_1"0";
//new Window1().Show();
IsHallMode = true;
ResetOptions();
IsRoomGained = false;
voiceEntry = new Voice.VoiceEntry();
voiceEntry.Play("voiceFmxy");
md_openDialog = new System.Windows.Forms.OpenFileDialog()
{
Multiselect = false, RestoreDirectory = true,
Filter = "PSG|*.psg"
};
SetSelTrigger();
SetLvTrigger();
//SetTeamTrigger();
LoadFromConfig();
}
开发者ID:palome06,项目名称:psd48,代码行数:27,代码来源:LoginDoor.xaml.cs
示例8: Execute
static void Execute(ILSpyTreeNode[] nodes)
{
if (!AddNetModuleToAssemblyCommand.CanExecute(nodes))
return;
var dialog = new System.Windows.Forms.OpenFileDialog() {
Filter = ".NET NetModules (*.netmodule)|*.netmodule|All files (*.*)|*.*",
RestoreDirectory = true,
};
if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
return;
if (string.IsNullOrEmpty(dialog.FileName))
return;
var asm = new LoadedAssembly(MainWindow.Instance.CurrentAssemblyList, dialog.FileName);
if (asm.ModuleDefinition == null || asm.AssemblyDefinition != null) {
MainWindow.Instance.ShowMessageBox(string.Format("{0} is not a NetModule", asm.FileName), System.Windows.MessageBoxButton.OK);
asm.TheLoadedFile.Dispose();
return;
}
var cmd = new AddExistingNetModuleToAssemblyCommand((AssemblyTreeNode)nodes[0], asm);
UndoCommandManager.Instance.Add(cmd);
MainWindow.Instance.JumpToReference(cmd.modNode);
}
开发者ID:4058665,项目名称:dnSpy,代码行数:25,代码来源:ModuleCommands.cs
示例9: bLearn_Click
private async void bLearn_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
dialog.CheckFileExists = true;
dialog.CheckPathExists = true;
dialog.Multiselect = true;
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (dialog.FileNames.Length >= 2)
{
string mimeType = getMimeType();
var infoOne = new FileInfo(dialog.FileNames[0]);
var infoTwo = new FileInfo(dialog.FileNames[1]);
var fileType = MimeDetective.LearnMimeType(infoOne, infoTwo, mimeType);
if (fileType != null)
{
//Detective.types.Add(fileType);
await animateLearnSuccess();
}
else
await animateLearnFailure();
}
}
else
await animateLearnFailure();
}
开发者ID:vpanuccio,项目名称:Mime-Detective,代码行数:27,代码来源:MainWindow.xaml.cs
示例10: InitializeMap
public static SharpMap.Map InitializeMap(float angle)
{
using (var ofn = new System.Windows.Forms.OpenFileDialog())
{
ofn.Filter = "All files|*.*";
ofn.FilterIndex = 0;
if (ofn.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var m = new SharpMap.Map();
var l = new SharpMap.Layers.GdiImageLayer(ofn.FileName);
m.Layers.Add(l);
m.ZoomToExtents();
var mat = new System.Drawing.Drawing2D.Matrix();
mat.RotateAt(angle, m.WorldToImage(m.Center));
m.MapTransform = mat;
m.MaximumExtents = m.GetExtents();
m.EnforceMaximumExtents = true;
return m;
}
}
return null;
}
开发者ID:geobabbler,项目名称:SharpMap,代码行数:26,代码来源:GdiImageLayerSample.cs
示例11: AddProjectClick
private void AddProjectClick(object sender, RoutedEventArgs e)
{
var openFileDialog = new System.Windows.Forms.OpenFileDialog();
openFileDialog.Filter = "C# Project files (*.csproj)|*.csproj|VS Project files (*.vcproj)|*.vcproj|Android Project (*.project)|*.project";
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
var newProject = ProjectManager.AddSyncedProject(openFileDialog.FileName);
// If newProject is null, then no project was added
if (newProject != null)
{
ViewModel.Refresh();
}
else
{
GlueGui.ShowMessageBox("The selected project is already a synced project.");
}
GluxCommands.Self.SaveGlux();
ProjectManager.SaveProjects();
}
}
开发者ID:vchelaru,项目名称:FlatRedBall,代码行数:26,代码来源:SyncedProjectsControl.xaml.cs
示例12: CreateContent
public UIElement CreateContent(string fileName, IEnumerable<Filter> filters)
{
Grid grid_main = new Grid();
grid_main.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(100.0, GridUnitType.Star) });
grid_main.ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto });
m_textBox_fileName = new TextBox();
m_textBox_fileName.TextChanged += (sender, args) => { FileName = m_textBox_fileName.Text; };
m_textBox_fileName.Text = fileName;
grid_main.SetRowColumn(m_textBox_fileName, 0, 0);
Button button_openFile = new Button() { Content = "Open file ..." };
button_openFile.Click += (x, y) =>
{
System.Windows.Forms.OpenFileDialog openFileDialog =
new System.Windows.Forms.OpenFileDialog()
{
Filter = (filters != null) ? filters.Select(f => f.ToString()).Aggregate((a,b) => string.Format("{0}|{1}", a, b)) : string.Empty,
CheckFileExists = true,
CheckPathExists = true
};
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
m_textBox_fileName.Text = openFileDialog.FileName;
};
grid_main.SetRowColumn(button_openFile, 0, 1);
return grid_main;
}
开发者ID:ianeller-romey,项目名称:CompJS_TTTD,代码行数:28,代码来源:Window_OpenFile.cs
示例13: bt_browse_Click
public void bt_browse_Click(object sender, EventArgs e)
{
if ((tabControl_modType.SelectedItem as TabItem).Tag.ToString() == "zip")
{
System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
dialog.Filter = "Zipped mod|*.zip";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
tb_path.Text = dialog.FileName;
}
}
else
{
FolderSelectDialog fsd = new FolderSelectDialog();
fsd.ShowDialog();
if (fsd.ShowDialog())
{
tb_path.Text = fsd.FileName;
}
}
/*
string path = null;
if ((((tabControl.SelectedItem as TabItem).Tag) as string) == "zip")
{
System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
dialog.Filter = "Zipped mod|*.zip";
if (dialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
return;
else
path = dialog.FileName;
}
*/
}
开发者ID:Northcode,项目名称:MCM-reboot,代码行数:34,代码来源:NewMod.xaml.cs
示例14: PrepareInsertFromDatabase
public override bool PrepareInsertFromDatabase()
{
bool result = false;
using (System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog())
{
if (string.Compare(PluginSettings.Instance.ActiveDataFile, dlg.FileName, true) != 0)
{
if (string.IsNullOrEmpty(_lastInsertFromFolder))
{
_lastInsertFromFolder = System.IO.Path.GetDirectoryName(PluginSettings.Instance.ActiveDataFile);
}
dlg.InitialDirectory = _lastInsertFromFolder;
dlg.Filter = "*.gpp|*.gpp";
dlg.FileName = "";
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (string.Compare(PluginSettings.Instance.ActiveDataFile, dlg.FileName, true) != 0)
{
_selectedInsertFromFilename = dlg.FileName;
result = true;
}
}
}
}
return result;
}
开发者ID:gahadzikwa,项目名称:GAPP,代码行数:26,代码来源:InsertFrom.cs
示例15: OnClickFindBtn2
private void OnClickFindBtn2(object sender, RoutedEventArgs e)
{
System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
ofd.Filter = "Text Files(*.txt)|*.txt|All Files(*.*)|*.*";
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
textBox2.Text = ofd.SafeFileName;
try
{
System.IO.StreamReader sr = new System.IO.StreamReader(ofd.OpenFile());
string content = sr.ReadToEnd();
sr.Close();
selectTextBeforeValue.Text = content;
content = System.Text.RegularExpressions.Regex.Replace(content, "a", "QQQ");
System.IO.StreamWriter writer = new System.IO.StreamWriter(ofd.FileName);
writer.Write(content);
writer.Close();
sr = new System.IO.StreamReader(ofd.OpenFile());
content = sr.ReadToEnd();
sr.Close();
selectTextAfterValue.Text = content;
}
catch(Exception ex)
{
Console.WriteLine("=-=-=-=Exception : " + ex);
}
}
}
开发者ID:hrSung,项目名称:ModernUITestProject,代码行数:34,代码来源:Home.xaml.cs
示例16: Browse_Click
private void Browse_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog();
ofd.Multiselect = true;
ofd.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*"; //Should change the limit of data type
if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string[] filePath = ofd.FileNames;
string[] safeFilePath = ofd.SafeFileNames;
for (int i = 0; i < safeFilePath.Length; i++)
{
BitmapImage myBitmapImage = new BitmapImage();
myBitmapImage.BeginInit();
myBitmapImage.UriSource = new Uri(@filePath[i]);
myBitmapImage.EndInit();
//set image source
image1.Source = myBitmapImage;
title_tag.Text = safeFilePath[i];
}
}
}
开发者ID:huylu,项目名称:brownuniversitylads,代码行数:26,代码来源:small_window.xaml.cs
示例17: LoadBenchmark
public void LoadBenchmark()
{
System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog();
dialog.ShowDialog();
string pathToLoad = dialog.FileName;
try
{
XmlSerializer serializer = new XmlSerializer(typeof(Benchmark));
FileStream filestream = new FileStream(pathToLoad, FileMode.Open, FileAccess.Read, FileShare.Read);
Benchmark benchmark = (Benchmark)serializer.Deserialize(filestream);
filestream.Close();
// before setting benchmark, clear the screen
// clear screen
global.Verschnittoptimierung.display.Invalidate();
global.benchmark = benchmark;
// also create a basic solution
SolutionManagement solutionManagement = new SolutionManagement();
solutionManagement.CreateBasicSolution(global, global.benchmark);
// show benchmark
Show show = new Show(global);
show.ShowBenchmark(global.benchmark);
System.Windows.Forms.MessageBox.Show("Benchmark was loaded successfully.");
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show("Benchmark could not be loaded. Please make sure to select the correct file path.");
}
}
开发者ID:Norman2357,项目名称:Verschnittoptimierung,代码行数:35,代码来源:SaveAndLoad.cs
示例18: btnSelectHex_Click
private void btnSelectHex_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.OpenFileDialog openHexFileDialog = new System.Windows.Forms.OpenFileDialog();
openHexFileDialog.Filter = "Hex Files (.hex)|*.hex";
openHexFileDialog.FilterIndex = 1;
openHexFileDialog.Multiselect = false;
openHexFileDialog.ShowDialog();
if (openHexFileDialog.FileName != "")
{
HexFileName = openHexFileDialog.FileName;
if (ConnectedToBootloader == true)
{
string s = "Upload: " + System.IO.Path.GetFileNameWithoutExtension(HexFileName);
Console.WriteLine(s);
}
else
{
Console.WriteLine("You must select to connect to the bootloader");
}
btnUploadHex.IsEnabled = false;
FileSelected = true;
}
}
开发者ID:TechJect,项目名称:DragonFly_SDK,代码行数:27,代码来源:Bootloader.xaml.cs
示例19: tbAbrirNor_Click
/// <summary>
/// ABRINDO A NOR
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void tbAbrirNor_Click(object sender, RoutedEventArgs e)
{
System.Windows.Forms.OpenFileDialog openFile = new System.Windows.Forms.OpenFileDialog();
openFile.Filter = "BIN Files (.bin)|*.bin|All Files (*.*)|*.*";
openFile.FilterIndex = 1;
openFile.Title = ("Abrir arquivo dump.bin");
openFile.FileName = ("dump.bin");
if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
tbNor.Text = openFile.FileName;
try
{
BinaryReader read = new BinaryReader(new FileStream(openFile.FileName, FileMode.Open));
//Posição da Leitura
read.BaseStream.Position = 0x840;
//Lendo os offset
//metldr = BitConverter.ToString(read.ReadBytes(59680)).Replace("-", null); //reader.ReadBytes(12)
metldr = read.ReadBytes(59680);
ByteArrayToFile("data\\clone\\dump", metldr);
}
catch
{
MessageBox.Show("Sorry the application seems to have encountered a problem", "Error");
}
}
}
开发者ID:VictorOverX,项目名称:VenixODE,代码行数:38,代码来源:clone.xaml.cs
示例20: menuitem_Click
void menuitem_Click(object sender, EventArgs e)
{
System.Windows.Forms.OpenFileDialog of = new System.Windows.Forms.OpenFileDialog();
of.DefaultExt = ".xml";
of.Filter = "XMLファイル(*.xml)|*.xml";
if (of.ShowDialog((System.Windows.Forms.IWin32Window)_host.Win32WindowOwner) == System.Windows.Forms.DialogResult.OK) {
try {
System.Xml.XmlDocument xdoc = new System.Xml.XmlDocument();
xdoc.Load(of.FileName);
// 擬似的に放送に接続した状態にする
_host.StartMockLive("lv0", System.IO.Path.GetFileNameWithoutExtension(of.FileName), DateTime.Now);
// ファイル内のコメントをホストに登録する
foreach (System.Xml.XmlNode node in xdoc.SelectNodes("packet/chat")) {
Hal.OpenCommentViewer.Control.OcvChat chat = new Hal.OpenCommentViewer.Control.OcvChat(node);
_host.InsertPluginChat(chat);
}
_host.ShowStatusMessage("インポートに成功しました。");
}catch(Exception ex){
NicoApiSharp.Logger.Default.LogException(ex);
_host.ShowStatusMessage("インポートに失敗しました。");
}
}
}
开发者ID:nico-lab,项目名称:niconama-ocv,代码行数:29,代码来源:Importer.cs
注:本文中的System.Windows.Forms.OpenFileDialog类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论