Example #1
0
        public NoteConfigView(NoteUIModel notes)
        {
            InitializeComponent();
            var notesModel = new NoteConfigViewModel(notes);

            DataContext = notesModel;
        }
Example #2
0
        private async void DeleteNoteExecute(object o)
        {
            LoaderManager.ShowLoader();
            await Task.Run(() =>
            {
                if (SelectedNote == null)
                {
                    return;
                }

                StationManager.CurrentUser.Notes.RemoveAll(uwr => uwr.Guid == SelectedNote.Guid);
                App.Current.Dispatcher.Invoke((Action) delegate
                {
                    DBManager.DeleteNote(SelectedNote.Note);
                    FillNotes();
                    if (Notes.Count < 1)
                    {
                        SelectedNote = null;
                    }
                    OnPropertyChanged(nameof(SelectedNote));
                    OnPropertyChanged(nameof(Notes));
                });
            });

            LoaderManager.HideLoader();
        }
Example #3
0
        public void FillNotes()
        {
            var tmpNotes = new ObservableCollection <NoteUIModel>();

            foreach (var note in StationManager.CurrentUser.Notes)
            {
                tmpNotes.Add(new NoteUIModel(note));
            }
            Notes = tmpNotes;
            if (Notes.Count > 0)
            {
                _selectedNote = Notes[0];
            }
        }
Example #4
0
        private async void AddNoteExecute(object o)
        {
            LoaderManager.ShowLoader();
            await Task.Run(() =>
            {
                Note note = new Note("New Note", "", StationManager.CurrentUser);
                DBManager.AddNote(note);
                App.Current.Dispatcher.Invoke((Action) delegate
                {
                    var noteUIModel = new NoteUIModel(note);
                    _notes.Add(noteUIModel);
                    FillNotes();
                    SelectedNote = noteUIModel;
                });
            });

            LoaderManager.HideLoader();
        }
Example #5
0
 private void OnNoteChanged(NoteUIModel note)
 {
     if (_currentNoteConfigView == null && note != null)
     {
         _currentNoteConfigView           = new NoteConfigView(note);
         _currentNoteConfigView.IsEnabled = true;
         MainGrid.Children.Add(_currentNoteConfigView);
         Grid.SetRow(_currentNoteConfigView, 2);
         Grid.SetRowSpan(_currentNoteConfigView, 3);
         Grid.SetColumn(_currentNoteConfigView, 3);
     }
     else if (_currentNoteConfigView != null && note != null)
     {
         _currentNoteConfigView.DataContext = new NoteConfigViewModel(note);
         _currentNoteConfigView.IsEnabled   = true;
     }
     else
     {
         _currentNoteConfigView.DataContext = null;
         _currentNoteConfigView.IsEnabled   = false;
     }
 }
Example #6
0
 public NoteConfigViewModel(NoteUIModel note)
 {
     _currentNote = note;
 }
Example #7
0
 internal virtual void OnNoteChanged(NoteUIModel note) => NoteChanged?.Invoke(note);