private void button3_Click(object sender, EventArgs e) { if (listView1.SelectedItems.Count != 1) return; OpenFileDialog od = new OpenFileDialog(); od.Filter = "Bitmap file (*.bmp)|*.bmp"; od.FilterIndex = 0; if (od.ShowDialog() == DialogResult.OK) { Section s = listView1.SelectedItems[0].Tag as Section; try { Bitmap bmp = new Bitmap(od.FileName); s.import(bmp); bmp.Dispose(); pictureBox1.Image = s.image(); listView1.SelectedItems[0].SubItems[3].Text = s.cnt.ToString(); button4.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void btnOpenXml_Click(object sender, EventArgs e) { LoadXML xml = new LoadXML(); string pfad = null; //Öffnet OpenFileDialog OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\"; openFileDialog1.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*"; openFileDialog1.FilterIndex = 1; openFileDialog1.RestoreDirectory = true; DialogResult result = openFileDialog1.ShowDialog(); if (openFileDialog1.ShowDialog() == DialogResult.OK) { if (openFileDialog1.OpenFile() != null) { //Öffnet Explorer und ermittelt den Eingegebenen Dateipfad string file = openFileDialog1.FileName; try { pfad = openFileDialog1.FileName; } //TODO: Ausnahme hinzufügen catch (IOException) { } } //Dateipfad wird an die Klasse ladeXML übergeben Console.WriteLine(result); Console.WriteLine(pfad); xml.ladeXML(pfad); } }
private void button4_Click(object sender, EventArgs e) { OpenFileDialog fileDia = new OpenFileDialog(); fileDia.Title = "Please select the data.dat file to extract."; fileDia.Filter = "data.dat|*.dat"; fileDia.DefaultExt = "*.dat"; fileDia.ShowDialog(); string dataPath = fileDia.FileName; fileDia.Title = "Please select the resource.dat file to extract."; fileDia.Filter = "resource.dat|*.dat"; fileDia.ShowDialog(); string resourcesPath = fileDia.FileName; string targetPath = Application.StartupPath; //System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + "ftldat unpack \"" + dataPath + "\" \"" + targetPath + "\"\\data\\"); System.Diagnostics.Process.Start("cmd", "/c " + "ftldat unpack \"" + dataPath + "\" \"" + targetPath + "\\data\""); System.Diagnostics.Process.Start("cmd", "/c " + "ftldat unpack \"" + resourcesPath + "\" \"" + targetPath + "\\resource\""); tbPathData.Text = targetPath + "\\data\\"; dataPath = targetPath + "\\data\\"; tbPathResources.Text = targetPath + "\\resource\\"; resPath = targetPath + "\\resource\\"; UpdatePaths(); fileDia.Dispose(); }
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(); } } }
static void Main(string[] args) { //Excel worksheet combine example //You will be prompted to select two Excel files. test.xls will be created that combines the sheets //Note: This example does not check for duplicate sheet names. Your test files should have different sheet names. OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Excel document (*.xls)|*.xls"; ofd.Title = "Select first Excel document"; if (ofd.ShowDialog() == DialogResult.OK) { HSSFWorkbook book1 = new HSSFWorkbook(new FileStream(ofd.FileName, FileMode.Open)); ofd.Title = "Select second Excel document"; if (ofd.ShowDialog() == DialogResult.OK) { HSSFWorkbook book2 = new HSSFWorkbook(new FileStream(ofd.FileName, FileMode.Open)); HSSFWorkbook product = new HSSFWorkbook(); for (int i = 0; i < book1.NumberOfSheets; i++) { HSSFSheet sheet1 = book1.GetSheetAt(i) as HSSFSheet; sheet1.CopyTo(product, sheet1.SheetName, true, true); } for (int j = 0; j < book2.NumberOfSheets; j++) { HSSFSheet sheet2 = book2.GetSheetAt(j) as HSSFSheet; sheet2.CopyTo(product, sheet2.SheetName, true, true); } product.Write(new FileStream("test.xls", FileMode.Create, FileAccess.ReadWrite)); } } }
private void Setup() { var configSetup = new NHibernateConfigSetup(); if (!configSetup.VerifyNHConfigFileExist()) { if (MessageBox.Show("El archivo de conexión a la base de datos no existe\n" + "para poder hacer uso del sistema por favor importe el archivo.\n\n", "Inventarios", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { var ofdBuscarArchivo = new OpenFileDialog { InitialDirectory = "c:\\", Filter = "Data files (*.config)|*.config", FilterIndex = 2, RestoreDirectory = false }; if (ofdBuscarArchivo.ShowDialog() == DialogResult.OK) { File.Copy(ofdBuscarArchivo.FileName, "C:\\NHibernateSettings\\" + ofdBuscarArchivo.SafeFileName); } if (ofdBuscarArchivo.ShowDialog() == DialogResult.Cancel) { Application.Exit(); } } else Application.Exit(); } else { configSetup.InitializeNHibernate(); AutoMapperConfiguration.Configure(); } }
// TODO: organise Dialogs.cs #region FileSelectFile /// <summary> /// Displays a standard dialog that allows the user to open or save files. /// </summary> /// <param name="OutputVar">The user selected files.</param> /// <param name="Options"> /// <list type="bullet"> /// <item><term>M</term>: <description>allow muliple files to be selected.</description></item> /// <item><term>S</term>: <description>show a save as dialog rather than a file open dialog.</description></item> /// <item><term>1</term>: <description>only allow existing file or directory paths.</description></item> /// <item><term>8</term>: <description>prompt to create files.</description></item> /// <item><term>16:</term>: <description>prompt to overwrite files.</description></item> /// <item><term>32</term>: <description>follow the target of a shortcut rather than using the shortcut file itself.</description></item> /// </list> /// </param> /// <param name="RootDir">The file path to initially select.</param> /// <param name="Prompt">Text displayed in the window to instruct the user what to do.</param> /// <param name="Filter">Indicates which types of files are shown by the dialog, e.g. <c>Audio (*.wav; *.mp2; *.mp3)</c>.</param> public static void FileSelectFile(out string OutputVar, string Options, string RootDir, string Prompt, string Filter) { bool save = false, multi = false, check = false, create = false, overwite = false, shortcuts = false; Options = Options.ToUpperInvariant(); if (Options.Contains("M")) { Options = Options.Replace("M", string.Empty); multi = true; } if (Options.Contains("S")) { Options = Options.Replace("S", string.Empty); save = true; } int result; if (int.TryParse(Options.Trim(), out result)) { if ((result & 1) == 1 || (result & 2) == 2) check = true; if ((result & 8) == 8) create = true; if ((result & 16) == 16) overwite = true; if ((result & 32) == 32) shortcuts = true; } ErrorLevel = 0; OutputVar = null; if (save) { var saveas = new SaveFileDialog { CheckPathExists = check, CreatePrompt = create, OverwritePrompt = overwite, DereferenceLinks = shortcuts, Filter = Filter }; var selected = dialogOwner == null ? saveas.ShowDialog() : saveas.ShowDialog(dialogOwner); if (selected == DialogResult.OK) OutputVar = saveas.FileName; else ErrorLevel = 1; } else { var open = new OpenFileDialog { Multiselect = multi, CheckFileExists = check, DereferenceLinks = shortcuts, Filter = Filter }; var selected = dialogOwner == null ? open.ShowDialog() : open.ShowDialog(dialogOwner); if (selected == DialogResult.OK) OutputVar = multi ? string.Join("\n", open.FileNames) : open.FileName; else ErrorLevel = 1; } }
static void Main() { var openFileDialog = new OpenFileDialog(); openFileDialog.Title = "Select a file from the files to assemble"; openFileDialog.InitialDirectory = new DirectoryInfo("../../../").FullName; string filePath; if (openFileDialog.ShowDialog() == DialogResult.OK) { filePath = openFileDialog.FileName; } else { throw new ApplicationException("No file selected"); } string slicesDirectroy = new FileInfo(filePath).DirectoryName; List<FileInfo> files = Directory .GetFiles(slicesDirectroy) .OrderBy(name => name) .Select(file => new FileInfo(file)) .ToList(); openFileDialog.Title = "Select a directroy to save the assembled file"; string outputDirectory; if (openFileDialog.ShowDialog() == DialogResult.OK) { filePath = openFileDialog.FileName; } else { throw new ApplicationException("No file selected"); } Console.WriteLine("Assembling Files..."); var sw = new Stopwatch(); sw.Start(); Task asyncTask = AssembleAsync(files, "../../../Assembled"); int left = Console.CursorLeft; double currentSecond = sw.Elapsed.TotalSeconds; while (!asyncTask.IsCompleted) { if (sw.Elapsed.TotalSeconds >= currentSecond + 1) { currentSecond = sw.Elapsed.TotalSeconds; Console.Write("{0}", Math.Floor(currentSecond)); Console.CursorLeft = left; } } Console.WriteLine("Completed... {0}", sw.Elapsed); }
public static string GetPathFromDialog() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Text files (*.csv)|*.csv"; openFileDialog.InitialDirectory = Directory.GetCurrentDirectory(); if (openFileDialog.ShowDialog() == DialogResult.OK || openFileDialog.ShowDialog() == DialogResult.Yes) { return openFileDialog.FileName; } return null; }
private void btnBrowse_Click(object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.ShowDialog(); if (dlg.ShowDialog()== DialogResult.OK ) { string fileName; fileName = dlg.FileName; txtFile.Text = fileName; btnSend2.Enabled = true; } }
private static string[] callOpenFileDialog(string startpath, string fileTypes, bool multiSelect, IWin32Window parentForm, ScriptEngine engine) { try { OpenFileDialog dlg = new OpenFileDialog(); dlg.InitialDirectory = startpath; dlg.Filter = fileTypes; dlg.Multiselect = multiSelect; DialogResult result = parentForm == null ? dlg.ShowDialog() : dlg.ShowDialog(parentForm); return result == DialogResult.OK ? dlg.FileNames : new string[0]; } catch (Exception ex) { throw ex.convertException(engine); } }
private void Browse(object sender, EventArgs e) { Button b = sender as Button; TextBox t = b.Tag as TextBox; OpenFileDialog ofd = new OpenFileDialog(); SaveFileDialog sfd = new SaveFileDialog(); if (t.Name == "txtInput") { // ofd ofd.Filter = "Bitmap Files (*.bmp)|*.bmp"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return; t.Text = ofd.FileName; } else if (t.Name == "txtOutput") { if (rdbHide.Checked) { // sfd sfd.Filter = "Bitmap Files (*.bmp)|*.bmp"; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return; t.Text = sfd.FileName; } else { // ofd ofd.Filter = "Bitmap Files (*.bmp)|*.bmp"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return; t.Text = ofd.FileName; } } else if (t.Name == "txtData") { if (rdbHide.Checked) { // ofd if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return; t.Text = ofd.FileName; } else { // sfd if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return; t.Text = sfd.FileName; } } }
private static void Main() { Console.WriteLine("Hello World!"); OpenFileDialog dlgOpen = new OpenFileDialog(); Console.WriteLine("Dumaan na dito!"); dlgOpen.ShowDialog(); Console.WriteLine("Ito na ulit!"); if (dlgOpen.ShowDialog() == DialogResult.OK) { string s = dlgOpen.FileName; Console.WriteLine("Filename " + s); Console.WriteLine(" Created at " + File.GetCreationTime(s)); Console.WriteLine(" Accessed at " + File.GetLastAccessTime(s)); } }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog f = new OpenFileDialog(); //création d'une fenetre d'exploration f.Title = "Choisir le fichier à importer"; if (f.ShowDialog() == DialogResult.OK) //si fond est coché { f.Filter = "Images(*.ZIP)|*.ZIP"; //filtre le type de fichier autorisé f.ShowDialog(); //affiche la boite de dialogue theme = f.FileName; } else { MessageBox.Show("Erreur"); } }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog abrir = new OpenFileDialog(); abrir.ShowDialog(); textBox1.Text = abrir.SafeFileName; }
private void OnClickSelect(object sender, EventArgs e) { DicomFile file1 = null; while (true) { var ofd = new OpenFileDialog(); ofd.Title = "Choose first DICOM file"; ofd.Filter = "DICOM Files (*.dcm;*.dic)|*.dcm;*.dic|All Files (*.*)|*.*"; if (ofd.ShowDialog(this) == DialogResult.Cancel) return; try { file1 = DicomFile.Open(ofd.FileName); break; } catch (Exception ex) { MessageBox.Show( this, ex.Message, "Error opening DICOM file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } DicomFile file2 = null; while (true) { var ofd = new OpenFileDialog(); ofd.Title = "Choose second DICOM file"; ofd.Filter = "DICOM Files (*.dcm;*.dic)|*.dcm;*.dic|All Files (*.*)|*.*"; if (ofd.ShowDialog(this) == DialogResult.Cancel) return; try { file2 = DicomFile.Open(ofd.FileName); break; } catch (Exception ex) { MessageBox.Show( this, ex.Message, "Error opening DICOM file", MessageBoxButtons.OK, MessageBoxIcon.Error); } } _file1 = file1; _file2 = file2; lblFile1.Text = _file1.File.Name; lblFile2.Text = _file2.File.Name; CompareFiles(); }
static void Main(string[] args) { OpenFileDialog OpenFile = new OpenFileDialog(); OpenFile.Multiselect = false; OpenFile.Title = "Cartridge"; OpenFile.Filter = "GBA Files (.gba)|*.gba"; OpenFile.FilterIndex = 1; string Cartridge; Console.WriteLine("Gneiss - Game Boy Advance Cartridge Reader."); Console.CursorVisible = false; if (OpenFile.ShowDialog() == DialogResult.OK) { Cartridge = OpenFile.FileName; BinaryReader BR = new BinaryReader(File.OpenRead(Cartridge)); BR.BaseStream.Seek(0xA0, SeekOrigin.Begin); Console.WriteLine("\n\nCartridge Name: {0}", Encoding.UTF8.GetString(BR.ReadBytes(12))); BR.BaseStream.Seek(0xAC, SeekOrigin.Begin); Console.WriteLine("Serial: {0}", Encoding.UTF8.GetString(BR.ReadBytes(4))); BR.BaseStream.Seek(0x108, SeekOrigin.Begin); Console.WriteLine("Name: {0}", Encoding.UTF8.GetString(BR.ReadBytes(24))); Console.Read(); } }
/// <summary> /// Attaches event handlers related to /// </summary> private void AttachMenuStripEventHandlers() { // File tsmNewProject.Click += (@s, e) => NewProject(); tsmOpenProject.Click += (@s, e) => LoadProject(); // Edit // View tsmShowStartPage.Click += (@s, e) => StartPage.Instance.Show(dockPanel); tsmShowProjectExplorer.Click += (@s, e) => ResourceExplorer.Instance.Show(dockPanel); // Project tsmImportResource.Click += (@s, e) => { var dialog = new OpenFileDialog(); dialog.Filter = "Image File (*.jpg;*.png)|*.jpg;*.png|Animated Image File (*.gif)|*.gif|Animat Resource (*.amt)|*.amt|BarloX Animation (*.bxa;*.ibxa)|*.bxa;*.ibxa"; if (dialog.ShowDialog() == DialogResult.OK) { AnimatProject.Instance.ImportResource(dialog.FileName); } }; // Help tsmAbout.Click += (@s, e) => AboutWindow.Instance.Show(dockPanel, DockState.Document); }
private void btSelecteerFoto_Click(object sender, EventArgs e) { string[] geldigeExtensies = { ".bmp", ".jpg", ".jpeg", ".gif", ".png" }; OpenFileDialog of = new OpenFileDialog(); if (of.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string bestand = of.FileName; string bestandsextensie = (new System.IO.FileInfo(bestand)).Extension.ToLower(); foreach (string ext in geldigeExtensies) { if (ext == bestandsextensie) { tbFoto.Text = bestand; return; } } MessageBox.Show("Het geselecteerde bestandsformaat wordt niet ondersteund!", "Fout:", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void LoadNewPlugin(IAutoWikiBrowser awb) { OpenFileDialog pluginOpen = new OpenFileDialog(); if (string.IsNullOrEmpty(LastPluginLoadedLocation)) LoadLastPluginLoadedLocation(); pluginOpen.InitialDirectory = string.IsNullOrEmpty(LastPluginLoadedLocation) ? Application.StartupPath : LastPluginLoadedLocation; pluginOpen.DefaultExt = "dll"; pluginOpen.Filter = "DLL files|*.dll"; pluginOpen.CheckFileExists = pluginOpen.Multiselect = /*pluginOpen.AutoUpgradeEnabled =*/ true; pluginOpen.ShowDialog(); if (!string.IsNullOrEmpty(pluginOpen.FileName)) { string newPath = Path.GetDirectoryName(pluginOpen.FileName); if (LastPluginLoadedLocation != newPath) { LastPluginLoadedLocation = newPath; SaveLastPluginLoadedLocation(); } } Plugin.LoadPlugins(awb, pluginOpen.FileNames, true); }
private void Add_LeftFile_Click(object sender, EventArgs e) { OpenFileDialog _dialog = new OpenFileDialog(); Stream _readStream = null; if (_dialog.ShowDialog() == DialogResult.OK) { try { if ((_readStream = _dialog.OpenFile()) != null) { using (_readStream) { TextBoxLeft.m_textController.Clear(); TextBoxLeft.m_textController.Setup(File.ReadAllText(_dialog.FileName)); TextBoxLeft.m_path = _dialog.FileName; lbl_fileLeft.Text = _dialog.FileName.ToString(); if (TextBoxRight.m_textController.Lines.Count != 0) { AddHistoryTracking(lbl_fileLeft.Text, lbl_fileRight.Text); } CompareFileAndPresentation(); } } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } }
public void OpenDialog(bool multipleFiles, params FileTypes[] fileTypes) { ofd = new OpenFileDialog(); ofd.Multiselect = multipleFiles; ofd.Filter = Utils.FileTypesToWinFormFilter(fileTypes); result = ofd.ShowDialog(); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { var dialog = new OpenFileDialog { Filter = "JSS document (*.jss)|*.jss|All files (*.*)|*.*", Title = "Open document", }; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { using (var file = new FileStream(dialog.FileName, FileMode.Open)) { var formatter = new BinaryFormatter(); var graph = formatter.Deserialize(file) as Graph; if (graph != null) { button1.SetGraph(graph); Filename = dialog.FileName; } } } catch (Exception ex) { MessageBox.Show("Error during open: " + ex.Message, Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
protected override void mergeTiffToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = imageFolder; openFileDialog1.Title = Properties.Resources.Select + " Input Images"; openFileDialog1.Filter = "Image Files (*.tif;*.tiff)|*.tif;*.tiff|Image Files (*.bmp)|*.bmp|Image Files (*.jpg;*.jpeg)|*.jpg;*.jpeg|Image Files (*.png)|*.png|All Image Files|*.tif;*.tiff;*.bmp;*.jpg;*.jpeg;*.png"; openFileDialog1.FilterIndex = filterIndex; openFileDialog1.RestoreDirectory = true; openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { filterIndex = openFileDialog1.FilterIndex; imageFolder = Path.GetDirectoryName(openFileDialog1.FileName); SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.InitialDirectory = imageFolder; saveFileDialog1.Title = Properties.Resources.Save + " Multi-page TIFF Image"; saveFileDialog1.Filter = "Image Files (*.tif;*.tiff)|*.tif;*.tiff"; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { File.Delete(saveFileDialog1.FileName); ImageIOHelper.MergeTiff(openFileDialog1.FileNames, saveFileDialog1.FileName); MessageBox.Show(this, Properties.Resources.Mergecompleted + Path.GetFileName(saveFileDialog1.FileName) + Properties.Resources.created, strProgName, MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
//select a song private void button1_Click(object sender, EventArgs e) { timer1.Stop(); timer2.Stop(); OpenFileDialog dlg = new OpenFileDialog(); dlg.ShowDialog(); song_path = dlg.FileName.ToString(); textBox1.Text = song_path; try { song.Stop(); } catch (Exception ex) { } try { song = new Audio(song_path); timer1.Interval = (int)(song.Duration * 10); progressBar1.Value = 0; //MessageBox.Show(timer1.Interval.ToString()); } catch (Exception ex) { } }
private void OpenToolStripMenuItemClick(object sender, EventArgs e) { var dataPlanOpenFileDialog = new OpenFileDialog { Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*", FilterIndex = 1, Multiselect = false, RestoreDirectory = true }; if (dataPlanOpenFileDialog.ShowDialog() != DialogResult.OK) return; try { if (File.Exists(dataPlanOpenFileDialog.FileName)) { _file = dataPlanOpenFileDialog.FileName; Text = _file; LoadDataPlan(DataPlan.Load(dataPlanOpenFileDialog.FileName)); } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } }
private void btnOpenfile_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = cmbOpenFiletype.Text + "|" + cmbOpenFiletype.Text; string filter = ofd.Filter; ofd.InitialDirectory = System.Environment.CurrentDirectory; ofd.Title = "打开图像文件"; ofd.ShowHelp = true; if(ofd.ShowDialog()==DialogResult.OK) { string strFileName = ofd.FileName; m_bitmap = new Bitmap(strFileName); if (m_bitmap.Width > m_bitmap.Height) { pictureBox1.Width = m_width0; pictureBox1.Height = (int)((double)m_bitmap.Height * m_width0 / m_bitmap.Width); } else { pictureBox1.Height = m_height0; pictureBox1.Width=(int)((double)m_bitmap.Width*m_height0/m_bitmap.Height); } pictureBox1.Image = m_bitmap; btnSave.Enabled = true; } }
public void Open(FarsiLibrary.Win.FATabStrip faTabStripMain, string path="") { using (OpenFileDialog ofd = new OpenFileDialog()) { if (string.IsNullOrEmpty(path)) { ofd.Filter = "PList(*.plist)|*.plist|All files|*.*"; if (ofd.ShowDialog() == DialogResult.OK) { path = ofd.FileName; } } if (!string.IsNullOrEmpty(path)) { try { PlistInfo p = new PlistInfo(path); bool suc = p.Read(); CreateTab(faTabStripMain, p.Info.Name, p); if (!suc) { MessageBox.Show("Xml format error"); } } catch (Exception ex) { MessageBox.Show(ex.Message); Debug.WriteLine(ex); } } } }
void OnLoadSession(object sender) { this.InitChangeSession(sender); using (var dialog = new OpenFileDialog() { AddExtension = true, CheckFileExists = true, Filter = "DebugOS Session Files (*.dbs)|*.dbs", FilterIndex = 0, Multiselect = false, Title = "Load Saved Session" }) { if (dialog.ShowDialog() == DialogResult.OK) { try { Loader.LoadSession(dialog.FileName); } catch (Exception e) { MessageBox.Show("An error occured while loading the session: " + e.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void add_button_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Multiselect = true; open.Filter = "JPEG Files (.jpg, .png, .bmp, .gif)|*.jpg;*.gif;*.png;*.bmp"; if (open.ShowDialog() == DialogResult.OK) { try { foreach (String file in open.FileNames) { File_listBox.Items.Add(file); Image newImage = Image.FromFile(Path.GetFullPath(file)); images_array.Add(newImage); } } catch { MessageBox.Show("Not a valid file(s)."); foreach (String file in open.FileNames) { File_listBox.Items.Remove(file); } } } }
private void Add_Copy_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string str = dialog.FileName; Start.PutinBB = str; StreamWriter ss = new StreamWriter("PutHH.txt"); ss.WriteLine(Start.PutinBB.ToString()); ss.Close(); DialogResult dialogResult = MessageBox.Show("Путь к файлу задан", "Файл", MessageBoxButtons.OK); if (dialogResult == System.Windows.Forms.DialogResult.OK) { MessageBox.Show(" Файл выбран!"); } } }
private void networkParametersToolStripMenuItem_Click(object sender, EventArgs e) { using (var openFileDialog1 = new System.Windows.Forms.OpenFileDialog { Filter = "Mnist Neural network file (*.nnt)|*.nnt", Title = "Open Neural network File" }) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { _MainMutex.WaitOne(); _mnistWeightsFile = openFileDialog1.FileName; var fsIn = openFileDialog1.OpenFile(); var arIn = new Archive(fsIn, ArchiveOp.load); _NN.Serialize(arIn); fsIn.Close(); _MainMutex.ReleaseMutex(); } } }
private void openClick(object sender, System.EventArgs e) { DialogResult res = openFileDialog.ShowDialog(); if (res == DialogResult.OK) { editor.Editor.LoadFile(openFileDialog.FileName, true, true); modified = false; hasFile = true; library.Filename = openFileDialog.FileName; library.Name = Path.GetFileName(openFileDialog.FileName); Apply(); library.Version = File.GetLastWriteTime(openFileDialog.FileName); Model.Items.Update(library); Reset(); Compiler.Compile(library); } }
string openingFile() { string file = null; try { var FD = new System.Windows.Forms.OpenFileDialog(); FD.Filter = "FirePlay File|*.fps.xml|FirePlay File|*.fps"; if (FD.ShowDialog() == System.Windows.Forms.DialogResult.OK) { file = FD.FileName; } } catch { } return(file); }
/* Settings Change Game Files Location */ private void SettingsGameFiles_Click(object sender, EventArgs e) { System.Windows.Forms.OpenFileDialog changeGameFilesPath = new System.Windows.Forms.OpenFileDialog { InitialDirectory = "C:\\", ValidateNames = false, CheckFileExists = false, CheckPathExists = true, Title = "Select the location to Find or Download nfsw.exe", FileName = "Select Game Files Folder" }; if (changeGameFilesPath.ShowDialog() == DialogResult.OK) { _newGameFilesPath = Path.GetDirectoryName(changeGameFilesPath.FileName); SettingsGameFilesCurrentText.Text = "NEW DIRECTORY"; SettingsGameFilesCurrent.Text = _newGameFilesPath; } }
private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { if (DialogResult.OK == openFileDialog1.ShowDialog()) { bool result = FileSameChaek(openFileDialog1.FileName); if (result == false) { string strFileName = Path.GetFileName(openFileDialog1.FileName); ListViewItem list = new ListViewItem(); list.Text = strFileName; list.SubItems.Add(openFileDialog1.FileName); lstFileList.Items.Add(list); } bIsFileLoad = 1; } }
public TuringInfo GetFile() { TuringInfo ti = new TuringInfo(); System.Windows.Forms.OpenFileDialog openfile = new System.Windows.Forms.OpenFileDialog(); openfile.Filter = "EMT files|*.alg"; var result = openfile.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { ti = Контейнер.GetTuringInfo(openfile.FileName); } else { throw new FileLoadException("file weren't chosen"); } return(ti); }
private string ZgjidhLogo(System.Windows.Forms.OpenFileDialog c, string s) { c.FileName = ""; string result = ""; c.CheckFileExists = true; try { c.Filter = s; c.ShowDialog(); result = c.FileName; return(result); } catch { return(""); } }
private void BtnDesencriptarFichero_Click(object sender, RoutedEventArgs e) { string fichero = string.Empty; F.OpenFileDialog ventana = new F.OpenFileDialog(); if (ventana.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fichero = ventana.FileName; } if (string.IsNullOrWhiteSpace(fichero)) { return; } DesencriptarFichero(fichero); }
private void btnBrowseMSI_Click(object sender, EventArgs e) { string fileToOpen = string.Empty; var FD = new System.Windows.Forms.OpenFileDialog(); if (FD.ShowDialog() == System.Windows.Forms.DialogResult.OK) { fileToOpen = FD.FileName; txtMSILocation.Text = fileToOpen; txtAppName.Text = System.IO.Path.GetFileNameWithoutExtension(fileToOpen); grpPreProcess.Visible = true; grpPostProcess.Visible = true; btnfullDeploy.Visible = true; chkBxApp.Visible = true; chkBxSSO.Visible = true; chkBxIIS.Visible = true; } }
private void BtnIMG_Click(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.InitialDirectory = "C:\\"; DialogResult result = dialog.ShowDialog(); dialog.RestoreDirectory = true; if (result.ToString() == "OK") { file = dialog.FileName; BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.UriSource = new Uri(file); bitmapImage.EndInit(); imgProduct.Source = bitmapImage; } }
private void OnFileOpen(object sender, System.EventArgs e) { if (openFileDialog.ShowDialog() == DialogResult.OK) { fileNames = openFileDialog.FileNames; int imageIndex = 0; foreach (string fileName in fileNames) { using (Image image = Image.FromFile(fileName)) { imageList.Images.Add(image); listViewPictures.Items.Add(fileName, imageIndex++); } } } }
private void SendButton_Copy6_Click(object sender, RoutedEventArgs e) { var fileDialog = new System.Windows.Forms.OpenFileDialog(); var result = fileDialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { var file = fileDialog.FileName; TxtFile.Text = file; way = file; TxtFile.ToolTip = file; } else { TxtFile.Text = null; TxtFile.ToolTip = null; } }
private void button1_Click(object sender, EventArgs e) { var fd = new System.Windows.Forms.OpenFileDialog(); fd.Title = "Select movie to use as Intro."; fd.InitialDirectory = Environment.CurrentDirectory; fd.ShowDialog(); if (System.IO.File.Exists(fd.FileName)) { IntroMoviePath = fd.FileName; moviePathText.Text = new System.IO.FileInfo(fd.FileName).Name; TrinityEdit.CConsole.DebugMsg("Set movie:" + fd.FileName + " as intro movie for level."); SetLevelInfo(); } }
//---------------------------------------------------// private void btnSelectFile_Click(object sender, EventArgs e) { System.Windows.Forms.OpenFileDialog opendlg = new System.Windows.Forms.OpenFileDialog(); opendlg.FileName = System.IO.Path.GetFileNameWithoutExtension(txtFileName.Text); opendlg.AddExtension = true; opendlg.Filter = "All EOS File (*.job;*.cft;*.hpr)|*.job;*.cft;*.hpr|" + "EOS Job File (*.job)|*.job|" + "Config Job File (*.cft)|*.cft|" + "Exposure Config (*.hpr)|*.hpr|" + "All Filetypes (*.*)|*.*"; if (opendlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { txtFileName.Text = opendlg.FileName; } }
private void Select_Image(object sender, RoutedEventArgs e) { // Show File Picker var fileDialog = new swf.OpenFileDialog(); fileDialog.RestoreDirectory = true; var result = fileDialog.ShowDialog(); if (result != swf.DialogResult.OK) { return; } // Display selected image original = new Mat(fileDialog.FileName, Emgu.CV.CvEnum.LoadImageType.Color); imageBox.Source = ToBitmapSource(original); }
private Assembly getAssembly() { using (WinForm.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog()) { if (ofd.ShowDialog() == WinForm.DialogResult.OK) { try { Assembly asm = Assembly.LoadFile(ofd.FileName); return(asm); } catch { return(null); } } return(null); } }
private void button1_Click(object sender, System.EventArgs e) { int l = 0; int RequestID = 0; StringBuilder builder = new StringBuilder(); if (openFileDialog1.ShowDialog() == DialogResult.OK) { RequestID = InitRequest(); string fn = openFileDialog1.FileName; ExecutePHP(RequestID, fn); l = GetResultText(RequestID, builder, 0); builder.Capacity = l; l = GetResultText(RequestID, builder, builder.Capacity + 1); textBox1.Text = builder.ToString(); DoneRequest(RequestID); } }
private void OnImportMsappClick(object sender, RoutedEventArgs e) { if (SavePrompt()) { var fileDialog = new System.Windows.Forms.OpenFileDialog(); var result = fileDialog.ShowDialog(); switch (result) { case System.Windows.Forms.DialogResult.OK: model.OpenThemeFromApp(fileDialog.FileName); break; case System.Windows.Forms.DialogResult.Cancel: default: break; } } }
// Find an image. private void button4_Click(object sender, System.EventArgs e) { openFileDialog1.Multiselect = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { if (openFileDialog1.FileNames != null) { for (int i = 0; i < openFileDialog1.FileNames.Length; i++) { addImage(openFileDialog1.FileNames[i]); } } else { addImage(openFileDialog1.FileName); } } }
private void btnOpenFileDlg_Click(object sender, System.EventArgs e) { if (ofdFile.ShowDialog() == DialogResult.OK) { string file_lower = ofdFile.FileName.ToLower(); string file = ofdFile.FileName; // 어쩔 수 없이 \data 부터 짜른다. OTL int idx = file_lower.LastIndexOf("data\\"); if (idx >= 0) { file = file.Remove(0, idx); } file = file.Replace("\\", "/"); tbValue.Text = file; } }
void mnuFileSystemEncryptSign_Click(Object sender, System.EventArgs e) { if (this.skrSecretKeyRing.SecretKeys.Count == 0) { MessageBox.Show("You cannot sign data because you do not own a private key. Please generate a new key pair, before you sign data.", "Action not possible...", MessageBoxButtons.OK, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button1); return; } System.Windows.Forms.OpenFileDialog ofdOpen = new System.Windows.Forms.OpenFileDialog(); ofdOpen.Multiselect = true; ofdOpen.Filter = "All Files (*.*)|*.*"; ofdOpen.ShowDialog(); if (ofdOpen.FileNames.Length > 0) { EncryptionHelper.EncryptFiles(ofdOpen.FileNames, pkrPublicKeyRing, skrSecretKeyRing, true, true); } }
public void Open() { System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog(); ofd.CheckFileExists = true; ofd.Filter = "Sudoku Files (*.sdk)|*.sdk"; ofd.Multiselect = false; ofd.Title = "Open sudoku file"; System.Windows.Forms.DialogResult r = ofd.ShowDialog(); try { if (r == System.Windows.Forms.DialogResult.OK) { string txt = System.IO.File.ReadAllText(ofd.FileName); for (int i = 0; i < array.GetLength(0); i++) { for (int j = 0; j < array.GetLength(1); j++) { DGV1[j, i].Value = 0; } } int a = 0; int b = 0; for (int i = 0; i < txt.Length; i++) { string ss = txt[i].ToString(); int vl = 0; if (int.TryParse(ss, out vl)) { a = (i / 9); b = i % 9; array[a, b] = vl; } } ShowIt(array); } } catch { System.Windows.Forms.MessageBox.Show("Error opening sudoku file!", "Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } }
private void OpenFile_Click(object sender, EventArgs e) { int size = -1; var FD = new System.Windows.Forms.OpenFileDialog(); DialogResult result = FD.ShowDialog(); // Show the dialog. if (result == DialogResult.OK) // Test result. { string file = FD.FileName; try { using (Stream stream = File.Open(file, FileMode.Open)) { var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); dataList = (List <Data>)bformatter.Deserialize(stream); } PulseLB.Text = dataList[0].pulse; RPMLB.Text = dataList[0].rpm; SpeedLB.Text = dataList[0].speed; DistanceLB.Text = dataList[0].distance; RequestedPowerLB.Text = dataList[0].requestedPower; EnergyLB.Text = dataList[0].energy; ElepsedTimeLB.Text = dataList[0].elapsedTime; ActualPowerLB.Text = dataList[0].actualpower; HistoryChart.Series.Add("speed"); HistoryChart.Series["speed"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; HistoryChart.ChartAreas[0].AxisX.IsMarginVisible = false; HistoryChart.Invoke(new Action(() => { foreach (Data data in dataList) { HistoryChart.Series["speed"].Points.AddY(data.speed); } })); } catch (IOException) { } } Console.WriteLine(size); // <-- Shows file size in debugging mode. Console.WriteLine(result); // <-- For debugging use. }
private void btnSelect_Click(object sender, RoutedEventArgs e) { try { var dialog = new System.Windows.Forms.OpenFileDialog(); dialog.Filter = "FF14版本文件 (ffxivgame.ver)|ffxivgame.ver|FF14可执行文件 (ffxiv.exe)|ffxiv.exe|FF14_DX11可执行文件(ffxiv.exe)|ffxiv_dx11.exe"; dialog.CheckFileExists = true; dialog.CheckPathExists = true; dialog.ValidateNames = true; dialog.ShowHelp = true; dialog.Title = "请选择\"你的安装目录/最终幻想XIV/game/ffxivgame.ver\"或ffxiv.exe"; void _(Object _sender, EventArgs _e) { MessageBox.Show("请选择\"你的安装目录/最终幻想XIV/game/ffxivgame.ver\"或ffxiv.exe"); } dialog.HelpRequest += new EventHandler(_); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { logger.Info($"Game file path selected: {dialog.FileName}"); pathSelect.Text = dialog.FileName; string GamePath = System.IO.Directory.GetParent(pathSelect.Text).ToString(); var versionFile = new System.IO.StreamReader(GamePath + @"/ffxivgame.ver"); gameVersion = versionFile.ReadToEnd(); if (gameVersion.Length == 20) { txtVersion.Text = gameVersion; } else { txtVersion.Text = "ERROR"; logger.Error($"Incorrect game version file detected"); } versionFile.Dispose(); } dialog.Dispose(); } catch (Exception error) { MessageBox.Show(error.Message); logger.Error(error.Message); this.Close(); } }
private void ChangeConfigValue(object sender, bool isFile = false) { if (isFile) { winControls.TextBox textBox = (winControls.TextBox)sender; winForms.OpenFileDialog fileBrowser = new winForms.OpenFileDialog(); fileBrowser.InitialDirectory = Path.GetDirectoryName(textBox.Text); winForms.DialogResult dialogResult = fileBrowser.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { string configKey = GetConfigKey(textBox.Name, textBox.GetType()); string configValue = fileBrowser.FileName; _updatedConfigValues[configKey] = configValue; textBox.Text = configValue; } } else { winControls.TextBox textBox = (winControls.TextBox)sender; winForms.FolderBrowserDialog folderBrowser = new winForms.FolderBrowserDialog(); folderBrowser.SelectedPath = Path.GetFullPath(textBox.Text); winForms.DialogResult dialogResult = folderBrowser.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { string configKey = GetConfigKey(textBox.Name, textBox.GetType()); string configValue = folderBrowser.SelectedPath; _updatedConfigValues[configKey] = configValue; if (configKey == "ScreenshotOnFail") { configValue += @"\template.failed.png"; } textBox.Text = configValue; } } }
private void menuItem2_Click(object sender, System.EventArgs e) //Opens openfile dialog to select a DXF file { //Form1 f = new Form1(); //f.Show(); //f.Activate(); //f.Focus(); inputFileTxt = ""; openFileDialog1.InitialDirectory = "c:\\"; //sets the initial directory of the openfile dialog openFileDialog1.Filter = "dxf files (*.dxf)|*.dxf|All files (*.*)|*.*"; //filters the visible files... openFileDialog1.FilterIndex = 1; if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) //open file dialog is shown here...if "cancel" button is clicked then nothing will be done... { inputFileTxt = openFileDialog1.FileName; //filename is taken (file path is also included to this name example: c:\windows\system\blabla.dxf int ino = inputFileTxt.LastIndexOf("\\"); //index no of the last "\" (that is before the filename) is found here newCanvas = new Canvas(); //a new canvas is created... newCanvas.MdiParent = this; //...its mdiparent is set... newCanvas.Text = inputFileTxt.Substring(ino + 1, inputFileTxt.Length - ino - 1); //...filename is extracted from the text...(blabla.dxf)... newCanvas.MinimumSize = new Size(500, 400); //...canvas minimum size is set... if (inputFileTxt.Length > 0) { newCanvas.ReadFromFile(inputFileTxt); //the filename is sent to the method for data extraction and interpretation... } newCanvas.Show(); //the canvas is displayed... newCanvas.Activate(); newCanvas.Focus(); } openFileDialog1.Dispose(); }
private void bttOpenFile_Click(object sender, EventArgs e) { System.Windows.Forms.OpenFileDialog sOpenFileD = new System.Windows.Forms.OpenFileDialog(); sOpenFileD.CheckFileExists = true; sOpenFileD.CheckPathExists = true; sOpenFileD.Multiselect = true; sOpenFileD.Title = "选择数据源"; sOpenFileD.Filter = "Excel 97-2003 工作薄 (*.xls)|*.xls|Excel 工作薄(*.xlsx)|*.xlsx|JPEG (*.jpg)|*.jpg"; int m = 1; if (sOpenFileD.ShowDialog() == DialogResult.OK) { string[] strFileName = sOpenFileD.FileNames; for (int j = 0; j < strFileName.Length; j++) { for (int i = 0; i < dataGrid.RowCount; i++) { if (strFileName[j].ToString() == dataGrid.Rows[i].Cells["CmnPath"].Value.ToString()) { if (MessageBox.Show("该数据已经存在,是否再次添加", "提示!", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { break; } else { m = 0; break; } } } if (m == 1) { dataGrid.Rows.Add(true, strFileName[j].ToString(), "未上传"); } } } if (dataGrid.RowCount > 0) { bttRemove.Enabled = true; bttAllRemove.Enabled = true; } }
public static string OpenSelectFolderDialog(string Title) { // We use open file since it is a better UI than folder selection, the user can type at the address and naviagte quicker - more user friendly var OFD = new System.Windows.Forms.OpenFileDialog(); OFD.FileName = "Folder Selection"; OFD.Title = Title; OFD.Filter = "Folder|Folder"; OFD.ValidateNames = false; OFD.CheckFileExists = false; OFD.CheckPathExists = true; if (OFD.ShowDialog() == DialogResult.OK) { string p = OFD.FileName; p = p.Replace(System.IO.Path.GetFileName(p), ""); return(p); } return(null); }
private void changeImage(TextBlock tbImageButton, string screenName, out String imageName) { imageName = ""; if (tbImageButton.Text == "Set image") { System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog(); openFileDialog.Filter = "Image Files (*.png;*.jpg)|*.png;*.jpg"; openFileDialog.Title = "Image file to use for " + screenName; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { imageName = openFileDialog.FileName; tbImageButton.Text = "Stop using image"; } } else { tbImageButton.Text = "Set image"; } }