//Constructor 
        public NoteViewModel(NoteModel note = null)
        {
            if (note == null)
            {
                _note = new NoteModel();
            }
            else
            {
                _note = note;
            }
            _window = new Note();
            _window.DataContext = this;

            #region Events and commands

            _window.MouseLeftButtonDown += Grid_LeftClick;
            _window.txt_Title.LostFocus += Title_LostFocus;
            _window.HeaderBorder.MouseRightButtonUp += HeaderBorder_RightClick;
            _window.Deactivated += Window_Deactivated;

            CreateCloseCommand();
            CreateNewTaskCommand();

            #endregion

            _window.Show();
            //_window.Topmost = true;
            _window.txt_DataText.Focus();
            HiddenWindow.HideNoteFromAltTab(_window);

            App.Notes.Add(this);
        }
        public static void SaveNote(NoteModel note)
        {
            if (note == null) return;

            string settingsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\" + App.DIRECTORY_NAME;

            if (!Directory.Exists(settingsDirectory))
            {
                Directory.CreateDirectory(settingsDirectory);
            }

            string filename = note.ID + ".json";
            string file = settingsDirectory + @"\" + filename;

            using (FileStream fs = File.Open(file, FileMode.Create))
            using (StreamWriter sw = new StreamWriter(fs))
            using (JsonWriter jw = new JsonTextWriter(sw))
            {
                jw.Formatting = Formatting.Indented;
                var serializer = new JsonSerializer();
                serializer.Serialize(jw, note, typeof(NoteModel));
            }

        }
 virtual public void CloseNote()
 {
     App.Notes.Remove(this);
     _window.MouseLeftButtonDown -= Grid_LeftClick;
     NoteCreator.NoteCreator.DeleteNote(_note);
     _note = null;
     _window.Close();
 }
 public static void DeleteNote(NoteModel note)
 {
     string noteFilename = App.DIRECTORY_FULLPATH + @"\" + note.ID + ".json";
     File.Delete(noteFilename);
 }
 public static NoteViewModel CloneNote(NoteModel note)
 {
     return new NoteViewModel(note);
 }