本文整理汇总了C#中System.Windows.Forms.OpenFileDialog.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# OpenFileDialog.Reset方法的具体用法?C# OpenFileDialog.Reset怎么用?C# OpenFileDialog.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.OpenFileDialog
的用法示例。
在下文中一共展示了OpenFileDialog.Reset方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnClick
public void OnClick()
{
if (Application.platform == RuntimePlatform.WindowsPlayer ||
Application.platform == RuntimePlatform.WindowsEditor)
{
System.Windows.Forms.OpenFileDialog opDialog = new System.Windows.Forms.OpenFileDialog();
opDialog.DefaultExt = "*.ogg";
opDialog.Filter = "Audio 파일(*.ogg) |*.ogg|모든 파일(*.*)|*.*";
if (opDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (opDialog.CheckFileExists)
{
if (_mainAudioSource != null)
{
AudioLoad(opDialog.FileName);
}
else if (Debug.isDebugBuild)
{
Debug.LogError("Main Audio Source is NULL!");
}
}
else if (Debug.isDebugBuild)
{
Debug.LogError("Audio File was not Exists!");
}
}
opDialog.Reset();
opDialog.DefaultExt = "*.txt";
opDialog.Filter = "Script Txt 파일(*.txt) |*.txt|모든 파일(*.*)|*.*";
// Load Script
if (opDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (opDialog.CheckFileExists)
{
if (MkManager.Instance != null)
{
MkManager.Instance.AnimeScriptParse(opDialog.FileName);
}
else if (Debug.isDebugBuild)
{
Debug.LogError("MkParser was not Exists!");
}
}
else if (Debug.isDebugBuild)
{
Debug.LogError("Script File was not Exists!");
}
_isLoaded = true;
}
if (_mainAudioSource != null)
{
_mainAudioSource.Play();
}
}
}
示例2: BtnOpenMNistClick
private void BtnOpenMNistClick(object sender, EventArgs e)
{
var dialog = new OpenFileDialog();
dialog.Title = "Выберите файл изображений";
dialog.Filter = "Файл изображений|*.idx3-ubyte";
if (dialog.ShowDialog() != DialogResult.OK) return;
var imagesPath = dialog.FileName;
dialog.Reset();
dialog.Title = "Выберите файл подписей";
dialog.Filter = "Файл подписей|*.idx1-ubyte";
if (dialog.ShowDialog() != DialogResult.OK) return;
var labelsPath = dialog.FileName;
nistImages = MNistFileManager.GetImageSet(labelsPath, imagesPath);
udMNistImageIndex.Maximum = nistImages.Length - 1;
lblMNistInfo.Text = string.Format("{0} элементов", nistImages.Length);
lblMNistInfo.ForeColor = Color.DarkGreen;
UdMNistImageIndexValueChanged(udMNistImageIndex, EventArgs.Empty);
DisablePanels(PanelsState.AllEnabled);
}
示例3: NEWTProfileButton_Click
private void NEWTProfileButton_Click( object sender, EventArgs e )
{
if (_fileProfileDialogOpened) return;
_fileProfileDialogOpened = true;
string newtFolder = Environment.GetEnvironmentVariable("ProgramFiles") + @"\Network Emulator for Windows Toolkit\";
if (newtFolder.IndexOf("(x86)", StringComparison.Ordinal) > 0)
newtFolder = newtFolder.Replace("Program Files (x86)", "Program Files");
string newtProfileFolder = newtFolder + "profiles\\";
_openProfileFileDialog = new OpenFileDialog();
_openProfileFileDialog.Reset();
_openProfileFileDialog.Filter = "XML files(*.xml)|*.xml|config files(*.config)|*.config";
_openProfileFileDialog.FilterIndex = 1;
_openProfileFileDialog.Title = "Load Network Emulation Congifuration File...";
_openProfileFileDialog.InitialDirectory = newtProfileFolder;
_openProfileFileDialog.RestoreDirectory = true;
DialogResult result = _openProfileFileDialog.ShowDialog();
if(result == DialogResult.OK)
{
_newtProfileFile = _openProfileFileDialog.FileName;
int index = _newtProfileFile.LastIndexOf(@"\", StringComparison.Ordinal);
_newtProfileFileName = _newtProfileFile.Substring(index + 1).Replace(".xml","");
this.NetProfileTextBox.Text = _newtProfileFileName;
}
_fileProfileDialogOpened = false;
}
示例4: OpenButton_Click
private void OpenButton_Click( object sender, EventArgs e )
{
if (_fileDialogOpened) return;
_fileDialogOpened = true;
_openFileDialog = new OpenFileDialog();
_openFileDialog.Reset();
_openFileDialog.DefaultExt = ".xml";
_openFileDialog.InitialDirectory = _defaultFolder;
_openFileDialog.RestoreDirectory = true;
_openFileDialog.Filter = "XML files(*.xml)|*.xml|config files(*.config)|*.config";
_openFileDialog.FilterIndex = 1;
_openFileDialog.Title = "Load Custom Bedlam Config File...";
DialogResult result = _openFileDialog.ShowDialog();
if(result == DialogResult.OK)
{
string openFileName = _openFileDialog.FileName;
try
{
Stream s = _openFileDialog.OpenFile();
LoadBedlamValuesFromConfig(s);
s.Close();
}
catch(Exception ex)
{
MessageBox.Show("Oops!\n" + ex.Message + "\n" + openFileName);
}
}
_fileDialogOpened = false;
}
示例5: OpenFileDialogTest
public void OpenFileDialogTest ()
{
ofd = new OpenFileDialog ();
Assert.IsTrue (ofd.AddExtension, "#11");
Assert.IsTrue (ofd.CheckFileExists, "#12");
Assert.IsTrue (ofd.CheckPathExists, "#13");
Assert.AreEqual ("", ofd.DefaultExt, "#14");
Assert.IsTrue (ofd.DereferenceLinks, "#15");
Assert.AreEqual ("", ofd.FileName, "#16");
Assert.IsNotNull (ofd.FileNames, "#17");
Assert.AreEqual (0, ofd.FileNames.Length, "#17a");
Assert.AreEqual ("", ofd.Filter, "#18");
Assert.AreEqual (1, ofd.FilterIndex, "#19");
Assert.AreEqual ("", ofd.InitialDirectory, "#20");
Assert.IsFalse (ofd.Multiselect, "#21");
Assert.IsFalse (ofd.ReadOnlyChecked, "#22");
Assert.IsFalse (ofd.RestoreDirectory, "#23");
Assert.IsFalse (ofd.ShowHelp, "#24");
Assert.IsFalse (ofd.ShowReadOnly, "#25");
Assert.AreEqual ("", ofd.Title, "#26");
Assert.IsTrue (ofd.ValidateNames, "#27");
Assert.AreEqual ("System.Windows.Forms.OpenFileDialog: Title: , FileName: ", ofd.ToString (), "#28");
ofd.DefaultExt = ".TXT";
Assert.AreEqual ("TXT", ofd.DefaultExt, "#29");
ofd.Filter = null;
Assert.AreEqual ("", ofd.Filter, "#30");
ofd.Filter = "Text (*.txt)|*.txt|All (*.*)|*.*";
try {
ofd.Filter = "abcd";
} catch (Exception) {
}
Assert.AreEqual ("Text (*.txt)|*.txt|All (*.*)|*.*", ofd.Filter, "#30a");
ofd.FilterIndex = 10;
Assert.AreEqual (10, ofd.FilterIndex, "#30aa");
ofd.Filter = null;
Assert.AreEqual ("", ofd.Filter, "#30b");
Assert.AreEqual (10, ofd.FilterIndex, "#30ba");
string current_path = Environment.CurrentDirectory;
string current_file = Path.Combine(current_path, "test_file");
if (!File.Exists (current_file))
File.Create (current_file);
ofd.FileName = current_file;
Assert.AreEqual (current_file, ofd.FileName, "#31");
string[] file_names = ofd.FileNames;
Assert.AreEqual (current_file, file_names [0], "#32");
ofd.Title = "Test";
Assert.AreEqual ("System.Windows.Forms.OpenFileDialog: Title: Test, FileName: " + current_file, ofd.ToString (), "#33");
ofd.FileName = null;
Assert.AreEqual ("", ofd.FileName, "#33a");
Assert.IsNotNull (ofd.FileNames, "#33b");
Assert.AreEqual (0, ofd.FileNames.Length, "#33c");
ofd.Reset ();
// check again
Assert.IsTrue (ofd.AddExtension, "#34");
Assert.IsTrue (ofd.CheckFileExists, "#35");
Assert.IsTrue (ofd.CheckPathExists, "#36");
Assert.AreEqual ("", ofd.DefaultExt, "#37");
Assert.IsTrue (ofd.DereferenceLinks, "#38");
Assert.AreEqual ("", ofd.FileName, "#39");
Assert.IsNotNull (ofd.FileNames, "#40");
Assert.AreEqual ("", ofd.Filter, "#41");
Assert.AreEqual (1, ofd.FilterIndex, "#42");
Assert.AreEqual ("", ofd.InitialDirectory, "#43");
Assert.IsFalse (ofd.Multiselect, "#44");
Assert.IsFalse (ofd.ReadOnlyChecked, "#45");
Assert.IsFalse (ofd.RestoreDirectory, "#46");
Assert.IsFalse (ofd.ShowHelp, "#47");
Assert.IsFalse (ofd.ShowReadOnly, "#48");
Assert.AreEqual ("", ofd.Title, "#49");
Assert.IsTrue (ofd.ValidateNames, "#50");
Assert.AreEqual ("System.Windows.Forms.OpenFileDialog: Title: , FileName: ", ofd.ToString (), "#60");
}
示例6: fileLoad
private void fileLoad()
{
OpenFileDialog open = new OpenFileDialog();
Stream stre;
open.DefaultExt = "txt";
open.Filter = "文字檔(*.txt)|*.txt";
open.ReadOnlyChecked = true;
if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
is_file_path2 = open.FileName;
stre = open.OpenFile();
try
{
richTextBox1.LoadFile(stre, RichTextBoxStreamType.PlainText);
}
catch (Exception file_exce)
{
MessageBox.Show(file_exce.ToString(), "錯誤訊息");
}
finally
{
//關閉stream才算關閉這個檔案,只有對openfiledialog做dispose是沒用的,
//還是會出現有人正在使用這個檔案
stre.Close();
open.Reset();
open.Dispose();
open = null;
}
}
}
示例7: btnImgFileName_Click
private void btnImgFileName_Click(object sender, EventArgs e)
{
picSource.Image = null;
picCaptche.Image = null;
OpenFileDialog open = new OpenFileDialog();
open.Reset();
open.ShowDialog();
txtImageFileName.Text = open.FileName;
if (txtImageFileName.Text.Trim() != string.Empty)
{
try
{
picSource.Image = Image.FromFile(txtImageFileName.Text.Trim());
bit = new Bitmap(picSource.Image);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "郁闷!你选的是图片吗?");
}
}
}
示例8: button1_Click
//选择图像
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog open = new OpenFileDialog();
open.Reset();
open.RestoreDirectory = true;
open.ShowDialog();
txtUrlImg.Text = open.FileName;
if (txtUrlImg.Text.Trim() != string.Empty)
{
try
{
picSource.Image = Image.FromFile(txtUrlImg.Text);
img = new Bitmap(picSource.Image);
if (img != null)
{
YanMoCaptche yanmo = new YanMoCaptche();
img = yanmo.GrayImage(img, 180); //灰度化
img = yanmo.ClearNoise(img); //去噪
bit = yanmo.InciseImage(img); //切割
for (int i = 0; i < bit.Length; i++) //冲洗
{
//bit[i].Save("S" + i.ToString() + ".bmp");
bit[i] = yanmo.RinseImage(bit[i]);
//bit[i].Save("H" + i.ToString() + ".bmp");
}
pic1.Image = bit[0];
pic2.Image = bit[1];
pic3.Image = bit[2];
pic4.Image = bit[3];
}
rtxState.Clear();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "郁闷!你选的是图片吗?");
}
}
}