private void saveAllFiles() { foreach (Form frm in this.MdiChildren) { if (frm.GetType() == typeof(editorForm)) { editorForm editorFrm = (editorForm)frm; editorFrm.saveFile(); } } MessageBox.Show("All files saved succesfully!", "Succesfully saved."); }
private void deleteThisFile() { editorForm child = ActiveMdiChild as editorForm; if (child != null) { child.deleteFile(); } else { MessageBox.Show("No file opened."); } }
private void closeThisFile() { editorForm child = ActiveMdiChild as editorForm; if (child != null) { child.Dispose(); child.Close(); } else { MessageBox.Show("File could not be closed."); } }
private void saveThisFile() { editorForm child = ActiveMdiChild as editorForm; if (child != null) { child.saveFile(); MessageBox.Show("File saved succesfully!", "Succesfully saved."); } else { MessageBox.Show("No file opened."); } }
private void openToolStripMenuItem2_Click(object sender, EventArgs e) { try { TreeNode selectedNode = fileView.SelectedNode; if (selectedNode.Tag.GetType() == typeof(DirectoryInfo)) { Console.WriteLine("Selected file is Directory... expanding..."); //DirectoryInfo selFileInfo = (DirectoryInfo)selectedNode.Tag; //MessageBox.Show("You cant edit folders."); selectedNode.Expand(); } else if (selectedNode.Tag.GetType() == typeof(FileInfo)) { Console.WriteLine("Selected file is File... opening..."); FileInfo selFileInfo = (FileInfo)selectedNode.Tag; editorForm fileForm = new editorForm(); fileForm.FileInfo = selFileInfo; fileForm.MdiParent = this; fileForm.Show(); } else { Console.WriteLine("File is neither File nor Directory. How could this happen?!"); MessageBox.Show("File Type not found."); return; } }catch (Exception ex) { if (ex.GetType() == typeof(System.NullReferenceException)) { Console.WriteLine("ERROR(No File selected): " + ex.Message); MessageBox.Show("Please select a file first."); } else { Console.WriteLine("ERROR: " + ex.Message); MessageBox.Show("An error occurred:" + Environment.NewLine + ex.Message); } } }
private void fileView_DoubleClick(object sender, EventArgs e) { TreeNode selectedNode = fileView.SelectedNode; if (selectedNode.Tag.GetType() == typeof(FileInfo)) { try { if (selectedNode.Tag.GetType() == typeof(DirectoryInfo)) { //DirectoryInfo selFileInfo = (DirectoryInfo)selectedNode.Tag; //MessageBox.Show("You cant edit folders."); selectedNode.Expand(); } else if (selectedNode.Tag.GetType() == typeof(FileInfo)) { FileInfo selFileInfo = (FileInfo)selectedNode.Tag; editorForm fileForm = new editorForm(); fileForm.FileInfo = selFileInfo; fileForm.MdiParent = this; fileForm.Show(); } else { MessageBox.Show("File Type not found."); return; } } catch (Exception ex) { if (ex.GetType() == typeof(System.NullReferenceException)) { MessageBox.Show("Please select a file first."); } else { MessageBox.Show("An error occurred:" + Environment.NewLine + ex.Message); } } } }