/// <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"); } } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here var dialog = new System.Windows.Forms.OpenFileDialog(); dialog.Filter = "Map file|*.js"; var result = dialog.ShowDialog(); if (result != System.Windows.Forms.DialogResult.OK) { Environment.Exit(0); } map = new Map(this); map.setMapFolder(dialog.FileName.Replace(dialog.SafeFileName, "")); map.LoadMap(dialog.SafeFileName); //shows the windows.forms layout design new Layout(map).Show(); //allows the mouse to show over the game this.IsMouseVisible = true; base.Initialize(); }
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(); } }
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(); }
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; } */ }
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]; } } }
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; }
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; } }
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; }
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); } } }
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"); } }
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; }
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; }
private void select_Click(object sender, System.Windows.RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog(); dialog.Title = "选择图片"; dialog.Filter = "图片文件(*.jpg;*.png)|*.jpg;*.png"; dialog.Multiselect = false; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.StreamSource = System.IO.File.OpenRead(dialog.FileName); bitmap.EndInit(); byte[] data = new byte[bitmap.StreamSource.Length]; bitmap.StreamSource.Position = 0; bitmap.StreamSource.Read(data, 0, (int)bitmap.StreamSource.Length); Value = data; } catch { MessageBox.Show("选择的图片格式错误。", "打开失败", MessageBoxButton.OK, MessageBoxImage.Error); } } }
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(); }
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("インポートに失敗しました。"); } } }
private void btn_filedb_Click(object sender, RoutedEventArgs e) { string path = System.Environment.CurrentDirectory + "\\filepath.txt"; string filepath_db = System.Environment.CurrentDirectory + "\\bd4.mdf"; FileInfo fi1; if (System.IO.File.Exists(path))//проверка на существование файла настроек { fi1 = new FileInfo(path); using (StreamReader sr = fi1.OpenText()) { string s = sr.ReadLine(); if (System.IO.File.Exists(s))//проверка на путь в нем { filepath_db = s; } } } if (!System.IO.File.Exists(filepath_db)) { filepath_db = @"C:\"; } System.Windows.Forms.OpenFileDialog dialog = new System.Windows.Forms.OpenFileDialog(); dialog.InitialDirectory = filepath_db; dialog.Filter = "DB File |*.mdf"; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { filepath_db = dialog.FileName; } else filepath_db = System.Environment.CurrentDirectory + "\\bd4.mdf"; fi1 = new FileInfo(path); using (StreamWriter sr = fi1.CreateText()) { sr.WriteLine(filepath_db); } }
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); }
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; }
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; }
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."); } }
private void btnPickFile_Click(object sender, RoutedEventArgs e) { var dialog = new System.Windows.Forms.OpenFileDialog(); dialog.ShowDialog(); var fileName = dialog.FileName; DisplayImageAndMetadata(fileName); }
private void ChooseFile(TextBox tb) { System.Windows.Forms.OpenFileDialog choose = new System.Windows.Forms.OpenFileDialog(); if (choose.ShowDialog() == System.Windows.Forms.DialogResult.OK && !string.IsNullOrEmpty(choose.FileName)) { tb.Text = choose.FileName; } }
private void Button_Click(object sender, RoutedEventArgs e) { using (System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog()) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) edPath.Text = dlg.FileName; } }
public void loadExisting() { var open = new System.Windows.Forms.OpenFileDialog(); open.SupportMultiDottedExtensions = true; open.DefaultExt = ".9.png"; open.Filter = "Ninepatch files|*.9.png|All files|*"; open.ShowDialog(); }
public void createNew() { var open = new System.Windows.Forms.OpenFileDialog(); open.SupportMultiDottedExtensions = true; open.DefaultExt = ".png"; open.Filter = "PNG files|*.png|All files|*"; open.ShowDialog(); }
private void btnOldBrowse_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog fileBrowseDlg = new System.Windows.Forms.OpenFileDialog(); if (fileBrowseDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { txtOldLocation.Text = fileBrowseDlg.FileName; } }
private void MenuFileOpen_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog oOpenFileDialog = new System.Windows.Forms.OpenFileDialog(); if (oOpenFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.filec.FileName = oOpenFileDialog.FileName; } }
public static string getMapFile() { System.Windows.Forms.OpenFileDialog openFile = new System.Windows.Forms.OpenFileDialog(); openFile.Title = "打开地图文档"; openFile.Filter = "map documents(*.mxd) | *.mxd"; openFile.ShowDialog(); string filePath = openFile.FileName; return filePath; }
private void Add_Button_Click(object sender, MouseButtonEventArgs e) { window = App.Current.MainWindow as MainWindow; System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); dlg.Filter = "(*.mp3)|*.mp3"; dlg.Multiselect = true; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { PlayItem[] item = new PlayItem[dlg.FileNames.Length]; int j = 0; foreach (var i in dlg.FileNames) { item[j] = new PlayItem(TagLib.File.Create(i)); j++; } window.collectionOfPlayLists.playLists.Where(p => p.Name == playListCurrent.Text).ElementAt(0).Items.AddRange(item); window.collectionOfPlayLists.currentPlayList = window.collectionOfPlayLists.playLists.Where(p => p.Name == playListCurrent.Text).ElementAt(0); window.collectionOfPlayLists.currentPlayItem = window.collectionOfPlayLists.currentPlayList.Items[0]; playListView.Items.Clear(); InitPlayListView(window.collectionOfPlayLists.playLists.Where(p => p.Name == playListCurrent.Text).ElementAt(0)); } }
private void btnload_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); openFileDialog1.InitialDirectory = System.Windows.Forms.Application.StartupPath; //初始目录,不赋值也可以 openFileDialog1.Filter = "xml文件(*.xml) | *.xml"; //文件类型 if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.textBlock2.Text = "你选择的文件为:" + openFileDialog1.FileName; XmlSerializer xs = new XmlSerializer(typeof(TableSettings)); StreamReader sr = new StreamReader(openFileDialog1.FileName); var tableSettings = xs.Deserialize(sr) as TableSettings; sr.Close(); if (tableSettings == null) { MessageBox.Show("加载失败"); } tableSettings.FieldSettingsList.ForEach(f => f.Status = "未处理"); this.tableSettings = tableSettings; refreshBind(); } }
private void btnSelectEmergencySoundFile_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); dlg.Filter = "Wave Files (*.wav)|*.wav"; dlg.Multiselect = false; dlg.ValidateNames = true; dlg.CheckFileExists = true; dlg.CheckPathExists = true; dlg.AutoUpgradeEnabled = true; if (string.IsNullOrWhiteSpace((this.DataContext as ViewModels.SettingsViewModel).EmergencyAlarmSoundFile)) { dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.CommonMusic); } else { dlg.InitialDirectory = System.IO.Path.GetDirectoryName((this.DataContext as ViewModels.SettingsViewModel).EmergencyAlarmSoundFile); } if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { (this.DataContext as ViewModels.SettingsViewModel).EmergencyAlarmSoundFile = dlg.FileName; } }
private void ChangePhoto_Click(object sender, RoutedEventArgs e) { if (Account.SelectedIndex == -1) { MessageBox.Show("Create a profile!", "Message", MessageBoxButton.OK, MessageBoxImage.Information); return; } System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog(); ofd.Filter = "|*.jpg|*.png|"; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { this.Photo.Source = new BitmapImage(new Uri(ofd.FileName)); Logic.ChangePhoto(this.Account.SelectedIndex, ofd.FileName); Logic.SaveProfiles(); Logic.GetListProfiles(); } }
private Stream EscolherArquivo() { //Cria uma tela de seleção de arquivo var fileDialog = new System.Windows.Forms.OpenFileDialog(); fileDialog.Filter = "JPG Files (*.jpg)|*.jpg|JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|GIF Files (*.gif)|*.gif"; //Mostra a tela e guarda a resposta no resultado var result = fileDialog.ShowDialog(); switch (result) { //Se o resultado foi: escolheu um arquivo, retorna o arquivo case System.Windows.Forms.DialogResult.OK: this.NomeArquivo = fileDialog.FileName; return fileDialog.OpenFile(); //Se o resultado foi: Cancelou ou qualquer outro(fechou), retorna nulo case System.Windows.Forms.DialogResult.Cancel: default: this.NomeArquivo = string.Empty; return null; } }
private void Button1_Click(object sender, RoutedEventArgs e) { fileDialog.Title = "WPF Open ifc File Dialog"; fileDialog.InitialDirectory = "C:\\Users\\10699\\Desktop"; fileDialog.Filter = "ifc files(*.ifc)|*.ifc|All files(*.*)|*.* "; fileDialog.RestoreDirectory = true;//如果值为true,每次打开这个对话框初始目录不随你的选择而改变,是固定的 if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { textBox1.Text = System.IO.Path.GetFullPath(fileDialog.FileName);//获取文件夹路径 MessageBox.Show("打开成功"); using (var model = IfcStore.Open(fileDialog.FileName)) { //显示Site var ids = from site in model.Instances.OfType <IIfcSite>() select site.GlobalId; foreach (var o in ids) { string id = o; var theSite = model.Instances.FirstOrDefault <IIfcSite>(d => d.GlobalId == id); ComboBox1.Items.Add(theSite.Name); } } } }
private void openFileDialogButton_Click(object sender, RoutedEventArgs e) { using (System.Windows.Forms.OpenFileDialog fd = new System.Windows.Forms.OpenFileDialog()) { fd.Filter = "Драйвер (*.sys)|*.sys|Все файлы (*.*)|*.*"; fd.FilterIndex = 1; if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { using (StreamReader fs = new StreamReader(fd.FileName)) { fs.Close(); } filePathTextBox.Text = fd.FileName; } catch (Exception ex) { MessageBox.Show(ex.Message); } } } }
private void MenuItem_Click_10(object sender, RoutedEventArgs e) { List <string> list_row = new List <string>(); System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog { Filter = "All files (*.*)|*.*" }; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { excelapp = new Microsoft.Office.Interop.Excel.Application(); /* * excelappworkbooks = excelapp.Workbooks; * excelworksheet = (Microsoft.Office.Interop.Excel.Worksheet)excelapp.Workbooks.Open(ofd.FileName, * Type.Missing, Type.Missing, Type.Missing, Type.Missing, * Type.Missing, Type.Missing, Type.Missing, Type.Missing, * Type.Missing, Type.Missing, Type.Missing, Type.Missing, * Type.Missing, Type.Missing).Worksheets.get_Item(1); */ impTimerMax = excelapp.Cells.Cells.SpecialCells(Microsoft.Office.Interop.Excel.XlCellType.xlCellTypeLastCell, Type.Missing).Row - 1; new LoadExcel(ofd.FileName, impTimerMax).Show(); } }
/// <summary> /// 打开文件浏览器 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOpen_Click(object sender, System.Windows.RoutedEventArgs e) { var op = new System.Windows.Forms.OpenFileDialog(); //默认的打开路径 if (!txtInput.Text.IsNullOrEmpty()) { var file = new FileInfo(txtInput.Text); op.InitialDirectory = file.DirectoryName; } op.RestoreDirectory = true; //op.Filter = "所有文件(*.*)|*.* "; var result = op.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { _Value = op.FileName; _FileInfo = new FileInfo(op.FileName); var arge = new MyDownloadEventArge(AfterFileSelectEvent, this); arge._TargetFileInfo = new FileInfo(op.FileName); RaiseEvent(arge); } }
private void BtnPath_Click(object sender, RoutedEventArgs e) { if (MainWindowViewModel.Instance.IsConvertForMultiFile) { var folderDialog = new System.Windows.Forms.FolderBrowserDialog(); folderDialog.ShowDialog(); if (folderDialog.SelectedPath != "") { MainWindowViewModel.Instance.Path = folderDialog.SelectedPath; } } else { var fileDialog = new System.Windows.Forms.OpenFileDialog(); fileDialog.InitialDirectory = MainWindowViewModel.Instance.Path; fileDialog.Filter = "Supported Image Files(*.JPG;*.PNG)|*.JPG;*.PNG"; fileDialog.ShowDialog(); if (fileDialog.FileName != "") { MainWindowViewModel.Instance.Path = fileDialog.FileName; } } }
public bool?ShowFileSelectionDialog(string defaultFile, out string filePath, string defaultExtension) { using (var dialog = new System.Windows.Forms.OpenFileDialog()) { if (File.Exists(defaultFile)) { dialog.InitialDirectory = Path.GetDirectoryName(defaultFile); } dialog.Multiselect = false; dialog.Filter = defaultExtension; System.Windows.Forms.DialogResult result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { filePath = dialog.FileName; return(true); } else { filePath = defaultFile; return(false); } } }
public void LoadWithDialog() { System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog(); if (IsVaridDir(SettingsHolder.Settings.LastScriptDir)) { ofd.InitialDirectory = SettingsHolder.Settings.LastScriptDir; } else { ofd.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory; } ofd.Filter = FileFilter; if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SettingsHolder.Settings.LastScriptDir = System.IO.Path.GetDirectoryName(ofd.FileName); textEditor.Load(ofd.FileName); FileName = ofd.FileName; UpdateTitle(false, true); } }
public void ChoseMovie(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog OpenFileDialog1 = new System.Windows.Forms.OpenFileDialog(); OpenFileDialog1.Title = "选择一个视频"; OpenFileDialog1.FileName = ""; OpenFileDialog1.Filter = "常见视频文件(*.avi, *.mp4, *.mkv, *.mpg, *.rmvb)| *.avi; *.mp4; *.mkv; *.mpg; *.rmvb|其它视频文件((*.rm, *.mov, *.mpeg, *.flv, *.wmv, *.m4v)| *.rm; *.mov; *.mpeg; *.flv; *.wmv; *.m4v|所有文件 (*.*)|*.*"; OpenFileDialog1.FilterIndex = 1; OpenFileDialog1.RestoreDirectory = true; if (OpenFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (!string.IsNullOrEmpty(vieModel.DetailMovie.id)) { vieModel.DetailMovie.filepath = OpenFileDialog1.FileName; vieModel.SaveModel(); new PopupWindow(this, "修改已保存").Show(); vieModel.Query(vieModel.id); } else { vieModel.Refresh(OpenFileDialog1.FileName); } } }
public static string OpenFileDialog(string filter = "", string initialDirectory = "") { var openFileDialog = new System.Windows.Forms.OpenFileDialog(); if (!string.IsNullOrEmpty(filter)) { openFileDialog.Filter = filter; } if (!string.IsNullOrEmpty(initialDirectory)) { openFileDialog.InitialDirectory = initialDirectory; } var result = openFileDialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { return(openFileDialog.FileName); } return(null); }
protected override void LoadContent() { _spritebatch = new SpriteBatch(GraphicsDevice); _backbuffer = new Texture2D(GraphicsDevice, 160, 144); System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog { DefaultExt = ".gb", Filter = "Gameboy ROM Files (.gb)|*.gb", Multiselect = false }; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { var filename = fileDialog.FileName; byte[] bytecode = File.ReadAllBytes(filename); _emulator.LoadROM(bytecode); Window.Title = "Castor - " + _emulator.Cartridge.Title; } }
private async void ButtonAddGames_Click(object sender, RoutedEventArgs e) { using (var dialog = new System.Windows.Forms.OpenFileDialog()) { dialog.Filter = fileFilterList; dialog.Multiselect = true; dialog.CheckFileExists = true; if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { IsBusy = true; var invalid = await Manager.AddGames(dialog.FileNames); if (invalid.Any()) { var w = new TextWindow("Ignored folders/files", string.Join(Environment.NewLine, invalid)); w.Owner = this; w.ShowDialog(); } IsBusy = false; } } }
private void ShowFileDialog(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog() { CheckFileExists = true, CheckPathExists = true, Multiselect = false, Title = "Select SMS ROM", }; ofd.InitialDirectory = Environment.CurrentDirectory + "\\Test ROMs"; ofd.ShowDialog(); if (ofd.FileName.Length > 0) { System.IO.BinaryReader br = new System.IO.BinaryReader(ofd.OpenFile()); byte[] data = br.ReadBytes((int)ofd.OpenFile().Length); StopCPU(); Memory.Load(data); } }
private void selectImageBtn_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog(); dlg.Filter = "Image files (*.jpg, *.jpeg, *.bmp, *.png) | *.jpg; *.jpeg; *.bmp; *.png"; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string shortName = new FileInfo(dlg.FileName).Name; // Копируем в папку приложения Media using (FileStream fs = File.OpenRead(dlg.FileName)) { if (!Directory.Exists(_projectKey)) { Directory.CreateDirectory(_projectKey); } using (FileStream ds = File.Open(System.IO.Path.Combine(_projectKey, shortName), FileMode.Create)) { fs.CopyTo(ds); } } contentImage.Source = new BitmapImage(new Uri(System.IO.Path.Combine(Environment.CurrentDirectory, _projectKey, shortName))); } }
private void selectPathBttn_Click(object sender, System.Windows.RoutedEventArgs e) { using (var filePicker = new System.Windows.Forms.OpenFileDialog()) { Button source = (Button)sender; filePicker.Filter = "Executable|MonsterHunterWorld.exe"; System.Windows.Forms.DialogResult result = filePicker.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { fullGamePath = filePicker.FileName; if (filePicker.FileName.Length > 15) { int i = (fullGamePath.Length / 2) - 10; source.Content = "..." + fullGamePath.Substring(i); source.Focusable = false; return; } source.Content = fullGamePath; } source.Focusable = false; } }
public async override Task <bool> ActionAsync(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 = "*.zip|*.zip|*.gpx|*.gpx"; dlg.Multiselect = true; if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { _filenames = dlg.FileNames; await PerformImport(); } } } } return(result); }
/// <summary> /// Select the Data File /// </summary> /// <param name="sender">The Object sender</param> /// <param name="e"> The Routed arguments</param> private void SelectButton_Click(object sender, RoutedEventArgs e) { var dialog = new System.Windows.Forms.OpenFileDialog(); dialog.Filter = "Text files(*.txt) |*.txt| CSV Text files(*.csv) |*.csv| DBF files(*.dbf)|*.dbf| All files(*.*) | *.*"; System.Windows.Forms.DialogResult result = dialog.ShowDialog(); DataFileTextBox.Text = dialog.FileName; if (ConfigurationManager.AppSettings["datapath"] == null) { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings.Add("datapath", dialog.FileName); config.Save(ConfigurationSaveMode.Full); ConfigurationManager.RefreshSection("appsettings"); } else { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["datapath"].Value = dialog.FileName; config.Save(ConfigurationSaveMode.Full); ConfigurationManager.RefreshSection("appsettings"); } }
private void Btn_Click(object sender, RoutedEventArgs e) { var fileDialog = new System.Windows.Forms.OpenFileDialog(); var result = fileDialog.ShowDialog(); switch (result) { case System.Windows.Forms.DialogResult.OK: var file = fileDialog.FileName; Filepath.Text = file; Filepath.ToolTip = file; SaveProductImage(file); break; case System.Windows.Forms.DialogResult.Cancel: default: Filepath.Text = null; Filepath.ToolTip = null; break; } }
private void button_OpenProvisioningDescription(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog openProvisioningDescriptionFileDialog = new System.Windows.Forms.OpenFileDialog(); //openProvisioningDescriptionFileDialog.InitialDirectory = "c:\\"; openProvisioningDescriptionFileDialog.Filter = "All files (*.*)|*.*|xml files (*.xml)|*.xml"; openProvisioningDescriptionFileDialog.FilterIndex = 2; openProvisioningDescriptionFileDialog.RestoreDirectory = true; if (openProvisioningDescriptionFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { provisioningDescription = XmlHelper.Instance.Deserialize <ProvisioningDescription>(openProvisioningDescriptionFileDialog.FileName); packageList = provisioningDescription.packageDescription.packageList.OrderBy(o => o.name).ToList(); serviceList = ServiceHelper.Instance.GetServiceList(provisioningDescription); FillList(); } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } }
private void BtnLoad_Click(object sender, RoutedEventArgs e) { using (System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog { FileName = "pipeline", Filter = Properties.strings.FileFilter, InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), DefaultExt = "json", }) { if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { using Stream fileStream = ofd.OpenFile(); using var streamReader = new StreamReader(fileStream); GraphicalPipeLineDefinition?pdef = JsonConvert.DeserializeObject <GraphicalPipeLineDefinition>(streamReader.ReadToEnd()); if (pdef != null) { this.Pipeline.FromDefinition(pdef); } } } }
private void LoadButton_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog(); if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string line; currentTextBox.Document.Blocks.Clear(); StreamReader file = new StreamReader(ofd.FileName); while ((line = file.ReadLine()) != null) { Paragraph para = new Paragraph(new Run(line) { Foreground = baseTextColour }) { Background = mainBrush }; currentTextBox.Document.Blocks.Add(para); } file.Close(); } SetUpLineAndFormat(currentTextBox); }
private void AddImagesButton_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog { Multiselect = true, Filter = Utils.IMAGE_FILE_DIALOG_FILTER, RestoreDirectory = true }; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { bool setViewerImage = !Viewer.HasImages(); Viewer.CurrentExercise.AddImagePaths(openFileDialog.FileNames); if (setViewerImage) { Viewer.SetNextImage(); } Editor.GetLoadedValues(); } catch (Exception ex) { System.Windows.MessageBox.Show("Could not open one or more files: " + ex.Message); } } }
/// <summary> /// GUI event handler for selecting hosted application path /// </summary> /// <param name="sender">Sender of event</param> /// <param name="e">Event object</param> private void hostPath_PreviewMouseDown(object sender, MouseButtonEventArgs e) { var dialog = new System.Windows.Forms.OpenFileDialog(); dialog.DefaultExt = ".exe"; dialog.Filter = "Assembly files (*.dll;*.exe)|*.exe;*.dll|All files (*.*)|*.*"; var initialDirectory = _HostPath.Text; if (initialDirectory != null && initialDirectory != "") { initialDirectory = System.IO.Path.GetDirectoryName(initialDirectory); } dialog.InitialDirectory = initialDirectory; var result = dialog.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { HostPath = dialog.FileName; } }
void LoadFile(string dialogueTitle, string modelProcessor, ref int var) { System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog(); // Default to the directory which contains our content files. string assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location; string relativePath = System.IO.Path.Combine(assemblyLocation, "../../../../../../"); string contentPath = System.IO.Path.GetFullPath(relativePath); fileDialog.InitialDirectory = contentPath; fileDialog.Title = dialogueTitle; fileDialog.Filter = "Model Files (*.fbx;*.x)|*.fbx;*.x|" + "FBX Files (*.fbx)|*.fbx|" + "X Files (*.x)|*.x|" + "All Files (*.*)|*.*"; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { LoadModel(fileDialog.FileName, modelProcessor, ref var); } }
private void AddNewImageButton_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.DialogResult dr = openImageDialog.ShowDialog(); if (dr == System.Windows.Forms.DialogResult.OK) { for (int i = 0; i < openImageDialog.FileNames.Count(); i++) { string filePath = openImageDialog.FileNames[i]; string fileName = openImageDialog.SafeFileNames[i]; try { // sprawdzanie czy duplikat nazwy oraz kopiowanie do folderu lokalnego string newFileName = fileName; int number = 0; while (File.Exists(imageDirectory + newFileName)) { number++; newFileName = System.IO.Path.GetFileName(fileName) + "_" + number + System.IO.Path.GetExtension(fileName); } File.Copy(filePath, imageDirectory + newFileName); // dodawanie ścieżki obrazu do xml i do listboxa AddImage(newFileName, true); } catch (System.Security.SecurityException ex) { Console.WriteLine(ex); MessageBox.Show("Brak dostępu do pliku (brak uprawnień użytkownika do zapisu)."); } catch (Exception ex) { Console.WriteLine(ex); MessageBox.Show("Błąd wczytywania pliku (prawdopodobnie ma to związek z uprawnieniami systemu plików)."); } } } }
private void InstallLangB_Click(object sender, RoutedEventArgs e) { string dir = Config.Current.Path[Enums.Path.LanguageDirectory]; if (File.Exists(dir)) { Config.Current.Path.Reset(Enums.Path.LanguageDirectory); dir = Config.Current.Path[Enums.Path.LanguageDirectory]; } if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog(); ofd.Filter = Localize.Get("LOCALIZE_FILE") + "|*.loc"; ofd.FileName = null; ofd.Title = Localize.Get(Strings.Open); if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string Dest = dir + Path.GetFileName(ofd.FileName); if (File.Exists(Dest)) { if (ClearUC.Dialogs.Dialog.ShowMessageBox(ClearUC.Dialogs.Dialog.Buttons.YesNo, Localize.Get("OVERWRITE_T"), Localize.Get("OVERWRITE_M")) == ClearUC.Dialogs.Dialog.ClickedButton.No) { return; } } File.Copy(ofd.FileName, Dest, true); } UpdateLang(); }
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; }