public override FileInfo SelectFile(string prompt, string patternDescription, string pattern) { var openDir = new OpenDialog(prompt, "Directory") { AllowsMultipleSelection = false, AllowedFileTypes = pattern == null ? null : new [] { pattern.TrimStart('*') } }; Application.Run(openDir); var selected = openDir.FilePaths.FirstOrDefault(); return(selected == null ? null : new FileInfo(selected)); }
public void ImportSql() { string file = OpenDialog.GetSqlFile(); if (string.IsNullOrEmpty(file)) { return; } m_models.Clear(); var tables = m_importer.Import(file); m_models.AddRange(tables.Where(table => table.Rows.Count > 0).Select(table => new GridViewModel(table))); NotifyOfPropertyChange(nameof(Models)); }
// Watch what happens when I try to introduce a newline after the first open brace // it introduces a new brace instead, and does not indent. Then watch me fight // the editor as more oddities happen. public static void Open() { var d = new OpenDialog("Open", "Open a file") { AllowsMultipleSelection = true }; Application.Run(d); if (!d.Canceled) { MessageBox.Query(50, 7, "Selected File", string.Join(", ", d.FilePaths), "Ok"); } }
private static void OpenCommonSecretsFile() { var d = new OpenDialog("Open", "Open a CommonSecrets file") { AllowsMultipleSelection = false }; Application.Run(d); if (!d.Canceled) { fullFilePath = d.FilePaths[0]; } }
private void MenuFileOpen_Click(object sender, EventArgs e) { OpenDialog.Title = "Select a file containing songs."; OpenDialog.Filter = "Supported Files|*.iso;*.wod;*.mdf;*.ark;*.hdr;*.rwk;*.rba;*.bin|All Files|*"; OpenDialog.Multiselect = true; if (OpenDialog.ShowDialog(this) == DialogResult.Cancel) { return; } foreach (string filename in OpenDialog.FileNames) { Open(filename); } }
private void fromTextFileToolStripMenuItem_Click(object sender, EventArgs e) { bool oldValue = ListCheck.Checked; ListCheck.Checked = true; OpenDialog.Filter = "Text Files (*.txt)|*.txt"; if (OpenDialog.ShowDialog() == DialogResult.OK) { ProcessListURLs(File.ReadAllLines(OpenDialog.FileName)); } ListCheck.Checked = oldValue; }
private void OpenReport() { var ofd = new OpenDialog("Load CSV Report", "Enter file path to load") { AllowedFileTypes = new[] { ".csv" }, CanChooseDirectories = false, AllowsMultipleSelection = false }; Application.Run(ofd); var f = ofd.FilePaths?.SingleOrDefault(); OpenReport(f, (e) => ShowException("Failed to Load", e)); }
static void NewAccount() { var openDlg = new OpenDialog("New Account", "Select a directory to save your Account details:") { CanChooseDirectories = true, CanChooseFiles = false, CanCreateDirectories = true, DirectoryPath = Directory.GetCurrentDirectory(), FilePath = null, }; Application.Run(openDlg); // _cwd.Text = "CWD: " + openDlg.DirectoryPath; }
private void ChooseKeyPairButton_Click(object sender, EventArgs e) { OpenDialog.Filter = ToolsHub.KeysFilter; if (OpenDialog.ShowDialog() == DialogResult.OK) { KeyPairFilenameBox.Text = OpenDialog.FileName; AsymmetricCipherKeyPair KeyPair = CryptoAdapter.LoadKeyPairFromDiskBouncy(KeyPairFilenameBox.Text); if (KeyPair == null) { MessageBox.Show("Unable to load key pair from disk, make sure it is in a supported format (xml or pkcs 12 key store)", Config.AppDisplayName, MessageBoxButtons.OK, MessageBoxIcon.Error); KeyPairFilenameBox.Text = ""; } } }
private void OpenPack() { var dialog = new OpenDialog("Open", "Open a pack") { FilePath = "ThimbleweedPark.ggpack1", AllowedFileTypes = new string[] { ".ggpack1", ".ggpack2" } }; Application.Run(dialog); if (dialog.FilePaths.Count > 0) { var path = Path.Combine(dialog.DirectoryPath.ToString(), dialog.FilePath.ToString()); OpenPack(path); } }
private void Open() { var d = new OpenDialog("Open", "Open a file") { AllowsMultipleSelection = false }; Application.Run(d); if (!d.Canceled) { _fileName = d.FilePaths [0]; LoadFile(); } }
private void menuItem5_Click(object sender, EventArgs e) { if (Derma.GetPanels().Count > 0) { DialogResult reply = MessageBox.Show("Are you sure you want to open a saved project?\nAny unsaved data in the current project will be lost.", "Open project", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (reply != DialogResult.Yes) { return; } } DSave.SetDialogDefaults(); Derma.prop.propertyGrid.SelectedObject = null; OpenDialog.ShowDialog(); }
private void Open() { var d = new OpenDialog("Open", "Open a file") { AllowsMultipleSelection = false }; Application.Run(d, false); if (!d.Canceled) { _fileName = d.FilePaths [0]; _hexView.Source = LoadFile(); _hexView.DisplayStart = 0; } }
public override DirectoryInfo SelectDirectory(string prompt) { var openDir = new OpenDialog(prompt, "Directory") { AllowsMultipleSelection = false, CanCreateDirectories = true, CanChooseDirectories = true, CanChooseFiles = false, }; Application.Run(openDir); var selected = openDir.FilePath?.ToString(); return(selected == null ? null : new DirectoryInfo(selected)); }
private void Source_Click(object sender, EventArgs e) { if (!DirectoryChkbx.Checked) { if (OpenDialog.ShowDialog(this) == DialogResult.OK) { SourceLbl.Text = OpenDialog.FileName; DirectoryChkbx.Enabled = false; } } else if (DirectoryDialog.ShowDialog(this) == DialogResult.OK) { SourceLbl.Text = DirectoryDialog.SelectedPath; DirectoryChkbx.Enabled = false; } }
private void btn_open_Click(object sender, EventArgs e) { OpenDialog.Title = "Open Your Text"; OpenDialog.Filter = "Text Files|*.txt|Microsoft Word Documents|*.doc"; OpenDialog.FilterIndex = 1; OpenDialog.InitialDirectory = "C:"; OpenDialog.RestoreDirectory = false; OpenDialog.CheckFileExists = true; OpenDialog.CheckPathExists = true; OpenDialog.Multiselect = true; if (OpenDialog.ShowDialog() == DialogResult.OK) { string txt = OpenDialog.FileName; txt_from.Text = File.ReadAllText(txt); } }
// permite la apertura del archivo private void OpenFileSubMenuBtn(object sender, EventArgs e) { if (OpenDialog.ShowDialog() == DialogResult.OK) { //Obtiene el nombre del archivo NameFilePath.Text = Path.GetFileName(OpenDialog.FileName); // se establece la ruta de acceso Fs.Path = OpenDialog.FileName; TextContent.Text = " "; // obtiene el texto del archivo string GetTextFile = Fs.ReadFile(); //coloca el archivo en el RichText TextContent.Text = GetTextFile; //Obtiene el total de palabras encontradas Words.Text = TWords(GetTextFile).ToString(); } }
/// <summary> /// 处理导入角色信息文件 /// </summary> private unsafe void ProcessLoadRcdformFile() { string sLoadFileName; FileStream nFileHandle; THumDataInfo ChrRcd; fixed(sbyte *buff = m_ChrRcd.Data.sChrName) { OpenDialog.FileName = HUtil32.SBytePtrToString(buff, m_ChrRcd.Data.ChrNameLen); } //OpenDialog.FileName = m_ChrRcd.Data.sChrName; OpenDialog.InitialDirectory = ".\\"; if (OpenDialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { return; } sLoadFileName = OpenDialog.FileName; if (!File.Exists(sLoadFileName)) { MessageBox.Show("指定的文件未找到!!!", "错误信息", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); return; } nFileHandle = File.Open(sLoadFileName, FileMode.OpenOrCreate, FileAccess.ReadWrite); if (nFileHandle == null) { MessageBox.Show("打开文件出现错误!!!", "错误信息", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); return; } //@ Unsupported function or procedure: 'FileRead' byte[] BytesChrRcd = new byte[sizeof(THumDataInfo)]; if (nFileHandle.Read(BytesChrRcd, 0, sizeof(THumDataInfo)) != sizeof(THumDataInfo)) { MessageBox.Show("读取文件出现错误!!!\r\r文件格式可能不正确", "错误信息", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); return; } ChrRcd.Header = m_ChrRcd.Header; //日后解决 //ChrRcd.Data.sChrName = m_ChrRcd.Data.sChrName; //ChrRcd.Data.sAccount = m_ChrRcd.Data.sAccount; //m_ChrRcd = ChrRcd; nFileHandle.Close(); RefShow(); MessageBox.Show("人物数据导入成功!!!", "提示信息", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); }
/// <summary> /// Imports this instance. /// </summary> private void Import( ) { bool?result = OpenDialog.ShowDialog( ); if (result == true) { OpenDialog.InitialDirectory = string.Empty; IsBusy = true; var workerThread = new Thread(ImportAsynchronous); workerThread.Start(OpenDialog.FileNames); } else { CloseWindow = true; } }
private void CheckInteraction() { foreach (CharacterBody rigidbody in _currentCharacters) { if (rigidbody == _mainCharacter) { continue; } if (!rigidbody.HasCollisionWith(_mainCharacter)) { continue; } Scene dialogScene = ScenesManager.GetScene(_scene.ID); dialogScene.Dialog = rigidbody.SpawnDialog; OpenDialog?.Invoke(dialogScene); CloseEvent(); } }
// Display a file open dialog and return the path of the user selected file. private void OpenFile() { var d = new OpenDialog("Open", "Open an audio file") { AllowsMultipleSelection = false }; d.DirectoryPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); // This will filter the dialog on basis of the allowed file types in the array. d.AllowedFileTypes = new string[] { ".mp3", ".wav", ".flac" }; Application.Run(d); if (!d.Canceled) { this.player.LastFileOpened = d.FilePath.ToString(); this.player.Play(this.player.LastFileOpened); } }
public static void CreateOpenDialog(string title, string message, string[] allowed_file_types, Action callback) { _OpenDialog = new OpenDialog(title, message); _OpenDialog.Id = "OpenFileDialog"; _OpenDialog.X = Pos.Center(); _OpenDialog.Y = Pos.Center(); _OpenDialog.ColorScheme = Colors.Dialog; _OpenDialog.AllowedFileTypes = allowed_file_types; _OpenDialog.AddButton(new Button("Set Dir...") { Clicked = () => { try { _OpenDialog.DirectoryPath = _OpenDialog.DirectoryPath; } catch (Exception) { /* nothing */ } } }); (_OpenDialog.Subviews.First().Subviews.FirstOrDefault(x => (x as Button ?? new Button("x")).Text == "Open") as Button).Clicked += callback; (_OpenDialog.Subviews.First().Subviews.FirstOrDefault(x => (x as Button ?? new Button("x")).Text == "Cancel") as Button).Clicked += () => Application.Top.SetFocus(Application.Top.MostFocused); Application.Run(_OpenDialog); }
public static void SetNotifycation(OpenDialog oepnItem) { notifyIcon = new NotifyIcon(); //notifyIcon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath); notifyIcon.Icon = new Icon($"{Environment.CurrentDirectory}/Images/Logo.ico"); // 设置图标 notifyIcon.Text = "监视程序"; // 设置鼠标放到上面时显示的文字 notifyIcon.Visible = true; WatchTypeSubItemOne.Click += WatchTypeSubItem_Click; WatchTypeSubItemOne.RadioCheck = true; WatchTypeSubItemOne.Name = "InternalItem"; WatchTypeSubItemTwo.Click += WatchTypeSubItem_Click; WatchTypeSubItemTwo.RadioCheck = true; MenuItem WatchTypeItem = new MenuItem("显示时间模式") { MenuItems = { WatchTypeSubItemOne, WatchTypeSubItemTwo } }; InitWatchType(); MenuItem WatchExeTypeItem = new MenuItem("监视程序设置"); MenuItem StageItem = new MenuItem("等级设置"); MenuItem TimeItem = new MenuItem("程序使用时间"); TimeItem.Click += new EventHandler(oepnItem); StageItem.Click += new EventHandler(oepnItem); WatchExeTypeItem.Name = "watchExeTypeItem"; StageItem.Name = "stageItem"; TimeItem.Name = "timeItem"; MenuItem ExitItem = new MenuItem("退出"); ExitItem.Click += (object sender, EventArgs e) => { RemoveNotifycation(); Environment.Exit(0); }; WatchExeTypeItem.Click += new EventHandler(oepnItem); notifyIcon.ContextMenu = new ContextMenu() { MenuItems = { WatchTypeItem, WatchExeTypeItem, StageItem, TimeItem, ExitItem } }; // 设置右键菜单 }
public static void openFileWindow(Toplevel top, Toplevel ntop) { var o = new OpenDialog("Open", "Open a file"); //o.MouseEvent mouseEvent; Application.Run(o); if (o.FilePath != "") { string filePath = o.DirectoryPath.ToString() + "\\" + o.FilePath.ToString(); string fileContent = FileOperation.openRead(filePath); var tframe = top.Frame; currentOpenedPath = filePath; var win = new Window(o.FilePath ?? "Untitled") { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill() }; var text = new TextView(new Rect(0, 0, tframe.Width - 2, tframe.Height - 3)); text.Text = fileContent; win.Add(text); ntop.Clear(); //Menu*************************************************** displayMenu(top, ntop, text); //end Menu********************************************************* ntop.Add(win); Application.Run(ntop); } }
async void OnOpenFileAsync() { long maxSize = 25 * 1024 * 1024; var openDialog = new OpenDialog("Open", "Open a file") { AllowsMultipleSelection = false, DirectoryPath = GetOpenFileDialogDirectory() }; Application.Run(openDialog); if (openDialog.Canceled) { return; } var fi = new FileInfo(openDialog.FilePath.ToString()); if (!fi.Exists) { return; } var fileName = Path.GetFileName(openDialog.FilePath.ToString()); if (fi.Length > maxSize) { ErrorBox.Show($"File {fileName} has a size of {GetBytesReadable(fi.Length)} but allowed are only {GetBytesReadable(maxSize)}."); return; } if (MessageBox.Query("Send File?", $"{fileName}, {GetBytesReadable(fi.Length)}", Strings.Ok, Strings.Cancel) == 0) { var fileBytes = File.ReadAllBytes(openDialog.FilePath.ToString()); await this.messagesViewModel.SendMessage(MessageType.File, $"{fileName}, {GetBytesReadable(fi.Length)}", fileBytes); _openFileDialogDirectory = openDialog.DirectoryPath.ToString(); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { List <ISerializable> DeserializeObj; if (OpenDialog.ShowDialog() == DialogResult.OK) { BinaryFormatter binFormater = new BinaryFormatter(); using (Stream fstream = File.OpenRead(OpenDialog.FileName)) { try { DeserializeObj = (List <ISerializable>)binFormater.Deserialize(fstream); } catch { MessageBox.Show("Error when opening file!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ClearEdgesList(); Canvas.Controls.Clear(); int Count = DeserializeObj.Count; for (int index = 0; index != Count; index++) { if (DeserializeObj[index] is Edge) { NewEdge = (Edge)DeserializeObj[index]; AddEdge(); } else { NewControl = (BaseControl)DeserializeObj[index]; AddControl(); } } } Canvas.Invalidate(); } }
private void LoadConfigToolStripMenuItem_Click(object sender, EventArgs e) { try { OpenDialog.Filter = "(*.ini)|*.ini"; if (OpenDialog.ShowDialog(this) != DialogResult.OK) { return; } OpenDialog.Filter = ""; LoadConfig(OpenDialog.FileName); } catch (Exception ex) { MessageBox.Show(this, ex.ToString(), "Error: Can not load config.", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//注册事件 void InitializationEvent() { m_Input_ChoiceFile.onClick.AddListener(() => { var path = OpenDialog.OpenFile(); if (!string.IsNullOrEmpty(path)) { m_Inpath_Input.text = path; } }); m_Input_ChoiceDir.onClick.AddListener(() => { var path = OpenDialog.OpenDir(); if (!string.IsNullOrEmpty(path)) { m_Inpath_Input.text = path; } }); m_Output_Choice.onClick.AddListener(() => { var path = OpenDialog.OpenDir(); if (!string.IsNullOrEmpty(path)) { m_Outpath_Input.text = path; } }); m_Outpath_UseSource.onValueChanged.AddListener((isOn) => { m_Outpath_Input.interactable = !isOn; m_Output_Choice.interactable = !isOn; m_Output_Copy.interactable = !isOn; }); m_Output_Copy.onClick.AddListener(() => { if (!string.IsNullOrEmpty(m_Inpath_Input.text)) { m_Outpath_Input.text = Directory.Exists(m_Inpath_Input.text) ? m_Inpath_Input.text : Path.GetDirectoryName(m_Inpath_Input.text); } }); }
private void Open() { var open = new OpenDialog("Open", "Open a file") { AllowsMultipleSelection = true }; Application.Run(open); if (!open.Canceled) { foreach (var path in open.FilePaths) { if (string.IsNullOrEmpty(path) || !File.Exists(path)) { return; } Open(File.ReadAllText(path), new FileInfo(path), Path.GetFileName(path)); } } }
// permite la apertura del archivo private void OpenFileSubMenuBtn(object sender, EventArgs e) { // Obtenemos el nombre de la maquina string name = Environment.MachineName; OpenDialog.InitialDirectory += name + "\\Desktop\\"; OpenDialog.CheckFileExists = true; OpenDialog.Title = "Abrir"; if (OpenDialog.ShowDialog() == DialogResult.OK) { Fs.Path = OpenDialog.FileName; NameFilePath.Text = Path.GetFileName(OpenDialog.FileName); TextContent.Text = ""; // obtiene el texto del archivo string GetTextFile = Fs.ReadFile(); //coloca el archivo en el RichText TextContent.Text = GetTextFile.Trim(); //Obtiene el total de palabras encontradas Words.Text = TWords(GetTextFile).ToString(); } }