本文整理汇总了C#中System.Windows.Forms.OpenFileDialog.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# OpenFileDialog.Dispose方法的具体用法?C# OpenFileDialog.Dispose怎么用?C# OpenFileDialog.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.OpenFileDialog
的用法示例。
在下文中一共展示了OpenFileDialog.Dispose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addImagesToolStripMenuItem_Click
private void addImagesToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog FileOpen = new OpenFileDialog();
FileOpen.Title = "Open Image File";
FileOpen.Multiselect = true;
FileOpen.Filter = "All (*.*)|*.*|JPEG (*.jpg)|*.jpg|Bitmap (*.bmp)|*.bmp|TIFF (*.tiff)|*.tiff";
DialogResult Result = FileOpen.ShowDialog();
if (Result == DialogResult.OK)
{
foreach (String img in FileOpen.FileNames)
{
PictureBox p = new PictureBox();
p.Image = Image.FromFile(img);
if (images.Count > 0)
{
if (p.Image.Height != images[0].Image.Height
|| p.Image.Width != images[0].Image.Width)
{
MessageBox.Show(img + " posiada inne wymiary niz pierwszy wczytany obraz!");
FileOpen.Dispose();
UpdateImages();
return;
}
}
images.Add(p);
p.Click += previevImageClick;
p.SizeMode = PictureBoxSizeMode.Zoom;
}
UpdateImages();
}
else FileOpen.Dispose();
}
示例2: OpenFile
/// <summary>
/// Open a new file. Will ask for the file name in a dialog.
/// </summary>
public void OpenFile()
{
OpenFileDialog dlg = new OpenFileDialog ();
if (dlg.ShowDialog () == DialogResult.OK)
OpenFile (dlg.FileName);
dlg.Dispose ();
}
示例3: openToolStripMenuItem_Click
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
// Create a dialog to ask the user for the full path of a file.
OpenFileDialog dlg = new OpenFileDialog();
// Initialize the dialog with some values before displaying it.
dlg.Title = "Open File";
dlg.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
dlg.InitialDirectory =
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
// Display the dialog.
if (dlg.ShowDialog() == DialogResult.OK && dlg.FileName != string.Empty)
{
try
{
// Open and display the file.
StreamReader reader = new StreamReader(dlg.FileName);
textBoxDocument.Text = reader.ReadToEnd();
reader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
dlg.Dispose();
}
示例4: OnClickBrowse
private void OnClickBrowse(object sender, EventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Multiselect = false;
string type = "txt";
switch (comboBox1.SelectedIndex)
{
case 0: type = "txt";
break;
case 1: type = "uoa";
break;
case 2: type = "uoab";
break;
case 3: type = "wsc";
break;
}
dialog.Title = String.Format("Choose {0} file to import", type);
dialog.CheckFileExists = true;
if (type == "uoab")
dialog.Filter = "{0} file (*.uoa)|*.uoa";
else
dialog.Filter = String.Format("{0} file (*.{0})|*.{0}", type);
if (dialog.ShowDialog() == DialogResult.OK)
textBox1.Text = dialog.FileName;
dialog.Dispose();
}
示例5: mnuOpen_OnClick
void mnuOpen_OnClick(object sender, EventArgs e)
{
var dlg = new OpenFileDialog {InitialDirectory = "C:\\", Filter = @"CSV|*.csv"};
dlg.ShowDialog(this);
OpenFile(dlg.FileName);
dlg.Dispose();
}
示例6: button3_Click
private void button3_Click(object sender, EventArgs e)
{
DbWorker dbWorker;
OpenFileDialog ofdOpen = new OpenFileDialog();
if (ofdOpen.ShowDialog() != DialogResult.OK)
return;
dbWorker = new DbWorker("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ofdOpen.FileName);
ofdOpen.Dispose();
try
{
dbWorker.OpenDB();
}
catch (TypeInitializationException error)
{
MessageBox.Show(error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
dbWorker.WriteLessonsDb(tableProcessor.ListLessons,1);
dbWorker.CloseDB();
}
示例7: AbrirGuardarImg
public string AbrirGuardarImg(string LlaveImg, PictureBox Contenedor, string Ruta)
{
if (!(Contenedor.Image == null)) Contenedor.Image.Dispose();
String Archivo = "";
string NombreArchivo = "";
var fdAttach = new OpenFileDialog();
fdAttach.Filter = "Imagen|*.jpg;*.jpeg;*.gif;*.png;*.bmp;";
//fdAttach.Filter = "Tipos de archivo|*.doc?;*.xls?;*.ppt?;*.pps?;*.pdf;*.txt;*.jpg;*.jpeg;*.gif;*.png;*.bmp;";
fdAttach.Title = "Ruta del archivo a importar";
if (fdAttach.ShowDialog() == DialogResult.OK)
//if (fdAttach.ShowDialog(Principal.Instance) == DialogResult.OK)
Archivo = fdAttach.FileName;
fdAttach.Dispose();
if (Archivo != "")
{
Bitmap Img;
// string Ruta = RutaGlobal; //GlobalClass.ConfiguracionGlobal.pathImagenes;
Ruta = Ruta + "\\(" + LlaveImg + ").jpg";
var Cuadro = new System.Drawing.Size(130, 100);
Img = (Bitmap)resizeImage(Image.FromFile(Archivo, true), Cuadro);
saveJpeg(Ruta, Img, 150);
NombreArchivo = fdAttach.FileName;
NombreArchivo = NombreArchivo.Substring(NombreArchivo.LastIndexOf("\\") + 1).ToLower();
}
return NombreArchivo;
}
示例8: buttonImport_Click
private void buttonImport_Click(object sender, EventArgs e)
{
Equipment temp = new Equipment(equipment);
try
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "EquipmentFile (*.eqp)|*.eqp|All files (*.*)|*.*";
ofd.FilterIndex = 1;
if (ofd.ShowDialog() != DialogResult.OK)
{
ofd.Dispose();
return;
}
byte[] fileData = File.ReadAllBytes(ofd.FileName);
if (fileData.Length != Constants.SIZEOF_EQUIPMENT)
{
MessageBox.Show("Invalid Equipment", "Error");
return;
}
this.equipment.EquipmentBytes = fileData;
loadData();
ofd.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Loading Error");
this.equipment = temp;
}
}
示例9: btnLoadImage_Click
private void btnLoadImage_Click(object sender, EventArgs e)
{
btnLoadImage.Enabled = false;
OpenFileDialog dlg = new OpenFileDialog();
_WhitePix = 0;
_NonWhitePix = 0;
dlg.Title = "Open Image";
dlg.Filter = "JPG|*.jpg;*.jpeg|PNG|*.png|"
+ "All Graphics Types|*.jpg;*.jpeg;*.png;";
if (dlg.ShowDialog() == DialogResult.OK)
{
_imagePath = dlg.FileName;
imgSource.Image = Image.FromFile(dlg.FileName);
}
dlg.Dispose();
DataTable dt = new DataTable();
dt.Clear();
dt.Columns.Add("Image_Source");
dt.Rows.Add(new object []{_imagePath});
GenerateSummary(dt, false);
btnLoadImage.Enabled = true;
}
示例10: button2_Click
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog openfile = new OpenFileDialog();
if (openfile.ShowDialog() == DialogResult.OK && (openfile.FileName != ""))
{
pictureBox1.ImageLocation = openfile.FileName;
openfile.Dispose();
}
}
示例11: loadITI
public ITI loadITI()
{
OpenFileDialog OFD = new OpenFileDialog();
OFD.Filter = "ITI|*.iti";
OFD.ShowDialog();
string bon = OFD.FileName;
OFD.Dispose();
return new ITI(bon);
}
示例12: button1_Click
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "Application|*.exe";
ofd.FilterIndex = 0;
if (ofd.ShowDialog() == DialogResult.OK)
txtApp.Text = ofd.FileName;
ofd.Dispose();
}
示例13: buttonBrowseBgImage_Click
private void buttonBrowseBgImage_Click(object sender, EventArgs e)
{
OpenFileDialog fd = new OpenFileDialog();
if (fd.ShowDialog() == DialogResult.OK)
{
textBoxBgImage.Text = fd.FileName;
}
fd.Dispose();
}
示例14: Parse
public static bool Parse()
{
if (Program.CommandLineFile == null)
{
// Before we try to parse, let's make sure CurrentList is in the Keywords
// Dict. Someone could have deleted it in the editor!
if (Program.Keys.KeywordDict.ContainsKey(Program.Keys.CurrentList) == false)
{
MessageBox.Show("You must have deleted the Keyword List you was using in the editor! Please Refresh and try again.");
return false;
}
OpenFileDialog dialog = new OpenFileDialog();
dialog.AddExtension = true;
dialog.Filter = "Log files (*.log)|*.log|All files (*.*)|*.*";
dialog.InitialDirectory = Program.opt.DefaultLogPath.ToString();
if (dialog.ShowDialog() != DialogResult.OK)
{
MessageBox.Show("Error Reading Log File or no Log File Selected!");
return false;
}
Program.CommandLineFile = dialog.FileName.ToString();
dialog.Dispose();
}
StreamReader LogFile = File.OpenText(Program.CommandLineFile);
LogParsed = Program.CommandLineFile;
// LogLine is the text line read in
// We use a StringBuilder here to build the output for the text window.
string LogLine = "";
// Let's reset these so they are clean! :)
Results.Clear();
while ((LogLine = LogFile.ReadLine()) != null)
{
foreach (string TheKeyword in Program.Keys.KeywordDict[Program.Keys.CurrentList])
{
string NewLogLine = LogLine;
string NewKeyword = TheKeyword;
if (Program.opt.CaseParse)
{
NewLogLine = LogLine.ToLower();
NewKeyword = TheKeyword.ToLower();
}
if (NewLogLine.IndexOf(NewKeyword) != -1)
{
// We found a match!
AddMatch(TheKeyword, LogLine.ToString());
}
}
}
LogFile.Close();
return true;
}
示例15: btnBuscarCsv_Click
private void btnBuscarCsv_Click(object sender, EventArgs e)
{
var frmCsv = new OpenFileDialog();
frmCsv.Filter = "(*.csv)|*.csv";
frmCsv.Title = "Ruta del archivo Csv a importar";
if (frmCsv.ShowDialog(Principal.Instance) == DialogResult.OK)
this.txtRutaCsv.Text = frmCsv.FileName;
frmCsv.Dispose();
}