Esempio n. 1
0
 private void deletenote_btn_Click(object sender, RoutedEventArgs e)
 {
     if (Notebook.rememberThis == null)
     {
         return;
     }
     Notebook.Delete(Notebook.rememberThis);
     SyncListView();
     Notebook.rememberThis = null;
 }
Esempio n. 2
0
        private void save_button_Click(object sender, RoutedEventArgs e)
        {
            if (titleTextBox.Text == "")
            {
                return;
            }

            DateTime temp = DateTime.Now;

            if (Notebook.rememberThis != null)
            {
                temp = Notebook.rememberThis.DateCreate;
                if (titleTextBox.Text != Notebook.rememberThis.Title)
                {
                    Notebook.Delete(Notebook.rememberThis);
                }
                else
                {
                    Notebook.RemoveAt(Notebook.IndexOf(Notebook.rememberThis));
                }
            }
            else
            {
                foreach (Note x in Notebook.notebook)
                {
                    if (titleTextBox.Text.ToLower().Equals(x.Title.ToLower()))
                    {
                        MessageBox.Show("Note with same title already exist.");
                        return;
                    }
                }
            }

            Notebook.Add(new Note(titleTextBox.Text, richTextBox.Document, temp, DateTime.Now));
            Notebook.Last().SaveToFile(String.Format("{0}{1}.note", Evennote.path, Notebook.Last().Title));
            File.SetCreationTime(String.Format("{1}{0}.note", Notebook.Last().Title, Evennote.path), temp);
            Notebook.Last().DateChanged = File.GetLastWriteTime(String.Format("{1}{0}.note", Notebook.Last().Title, Evennote.path));
            ((Application.Current.MainWindow as MainWindow).mainframe.Content as menu_page).frame.Source = new Uri("notes_page.xaml", UriKind.Relative);
        }