Advertisement
aslen

Untitled

May 9th, 2015
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11.  
  12. namespace NoteBook1
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         private bool isFilePass = true;
  17.  
  18.         public Form1()
  19.         {
  20.             InitializeComponent();
  21.         }
  22.  
  23.         private void newToolStripMenuItem_Click(object sender, EventArgs e)
  24.         {
  25.             if (isFilePass)
  26.                 richTextBox1.Text = string.Empty;
  27.             else
  28.                 Close();
  29.         }
  30.         protected override void OnClosing(CancelEventArgs e)
  31.         {
  32.             SaveFileDialog saveAs = new SaveFileDialog();
  33.             DialogResult dialogResult = MessageBox.Show("Do you want to save changes to file?", "My noteBook", MessageBoxButtons.YesNoCancel);
  34.             if (DialogResult.Yes == dialogResult)
  35.             {
  36.                 saveAs.ShowDialog();
  37.             }
  38.             else if (DialogResult.No == dialogResult)
  39.             {
  40.                 Close();
  41.             }
  42.             else
  43.                 e.Cancel = true;
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement