private void abrirToolStripMenuItem_Click(object sender, EventArgs e) { using (OpenFileDialog ofd = new OpenFileDialog()) { try { ofd.Filter = "All files (*.*)|*.*"; ofd.Title = "Abrir arquivo existente"; ofd.Multiselect = false; if (ofd.ShowDialog().Equals(DialogResult.OK)) { _saved = true; fileCreate = true; _pathFile = ofd.FileName; richTxtBText.Text = FileManipulator.Open(_pathFile); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } } }
private void salvarToolStripMenuItem_Click(object sender, EventArgs e) { if (!fileCreate) { SalvarComo(); } else { FileManipulator.Save(_pathFile, richTxtBText.Text); _saved = true; statusStrip1.Items["toolStripStatusLabel1"].Text = "Salvo"; } }
private void MessageSaveChanges() { if (MessageBox.Show("Existem mudanças não salvas ainda deseja salvar?", "Salvar alterações", MessageBoxButtons.YesNo, MessageBoxIcon.Warning).Equals(DialogResult.Yes)) { if (_pathFile.Equals(string.Empty)) { SalvarComo(); } else { FileManipulator.Save(_pathFile, richTxtBText.Text); _saved = true; fileCreate = true; statusStrip1.Items["toolStripStatusLabel1"].Text = "Salvo"; } } }
private void SalvarComo() { using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; if (sfd.ShowDialog().Equals(DialogResult.OK)) { FileManipulator.Save(sfd.FileName, richTxtBText.Text); _pathFile = sfd.FileName; richTxtBText.Text = string.Empty; richTxtBText.Text = FileManipulator.Open(_pathFile); _fileCreate = true; _saved = true; statusStrip1.Items["toolStripStatusLabel1"].Text = "Salvo"; } } }