Exemplo n.º 1
0
        private void Add_Click(object sender, RoutedEventArgs e)
        {
            var dataObject = DataContext as DataObject;

            dataObject.ListOfItems.Add(NewItemInput.Text);
            NewItemInput.Clear();
        }
Exemplo n.º 2
0
        private void OnNewNoteButtonClicked(object sender, RoutedEventArgs e)
        {
            String input = NewItemInput.Text;

            if (input.Length > 0)
            {
                Note myNote = new Note();
                myNote.Name         = input;
                myNote.Content      = "";
                myNote.LastUpdate   = DateTime.Now.ToString();
                myNote.CreationTime = DateTime.Now.ToString();

                myNote.Owner = SettingsProvider.getInstance().LoadedArchive.OwnerEncrypted;

                myNote.save();
                SettingsProvider.getInstance().LoadedArchive.Notes.Add(myNote);

                //using (DalNote dalNote = new DalNote())
                //{
                //    dalNote.CreateNote(oldNoteToCreate);
                //}
                listbox1.SelectedIndex = listbox1.Items.Count - 1;
                Listbox1_SelectionChanged(null, null);

                NewItemInput.Clear();
            }
            else
            {
                MessageBox.Show("Note title cannote be empty", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Exemplo n.º 3
0
        private void Remove_Click(object sender, RoutedEventArgs e)
        {
            if (listbox1.SelectedIndex != -1)
            {
                try
                {
                    int index = listbox1.SelectedIndex;
                    ((Note)listbox1.Items.GetItemAt(index)).delete();

                    SettingsProvider.getInstance().LoadedArchive.Notes.RemoveAt(index);
                    NewItemInput.Clear();
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Unable to delete Note, error: " + exc.Message);
                }
            }
            else
            {
                MessageBox.Show("select oldNote for remove");
            }
        }