/// <summary> /// Initializes a new instance of the <see cref="NoteViewPageViewModel"/> class. /// </summary> /// <param name="navigationService"> /// The navigation service. /// </param> /// <param name="noteListViewSessionService"> /// The note list view session service. /// </param> /// <param name="messageBox"> /// The message box. /// </param> /// <param name="logManager"> /// The log manager. /// </param> public NoteViewPageViewModel(INavigationService navigationService, INoteSessionService noteSessionService, IMessageBoxService messageBox, ILogManager logManager) { _navigationService = navigationService; _noteSessionService = noteSessionService; _messageBox = messageBox; _logManager = logManager; EditCommand = new RelayCommand<Note>(EditAction); }
/// <summary> /// Initializes a new instance of the <see cref="NoteListPageViewModel"/> class. /// </summary> /// <param name="navigationService"> /// The navigation service. /// </param> /// <param name="noteListViewSessionService"> /// The note list view session service. /// </param> /// <param name="messageBox"> /// The message box. /// </param> /// <param name="logManager"> /// The log manager. /// </param> public NoteListPageViewModel(INavigationService navigationService, INoteSessionService noteSessionService, IMessageBoxService messageBox, ILogManager logManager) { _navigationService = navigationService; _noteSessionService = noteSessionService; _messageBox = messageBox; _logManager = logManager; ViewCommand = new RelayCommand<Note>(ViewAction); DeleteCommand = new RelayCommand<Note>(DeleteAction); EmailCommand = new RelayCommand<Note>(EmailAction); PinCommand = new RelayCommand( () => { System.Diagnostics.Debug.WriteLine("Here we need to pin the select note..."); }); Messenger.Default.Register<NotificationMessage>(this, (message) => { if (message.Notification == "UpdateNoteList") { GetRuiNoteList(); } }); }
//private readonly INotebookSessionService _notebookSessionService; public ContentPageViewModel(INavigationService navigationService, ILogManager logManager, IAuthenticationSessionService authenticationService, INoteSessionService noteSessionService) // Rui: 2015.07.05: notebook folder to be implemented in the future. I already wrote the source codes in // Services folder, but I got exception! To investigate it later! //INotebookSessionService notebookSessionService) { _navigationService = navigationService; _logManager = logManager; _authenticationSessionService = authenticationService; _noteSessionService = noteSessionService; //_notebookSessionService = notebookSessionService; LogoutCommand = new RelayCommand( () => { _authenticationSessionService.Logout(); // goto MainPage, and remove any saved seesion data _navigationService.Navigate<MainPage>(); }); AddNewNoteCommand = new RelayCommand( () => { // goto NewNotePage, pass the note list count as ID for the new note! _navigationService.Navigate<NewNotePage>(NoteList.Count); }); DeleteNoteCommand = new RelayCommand<Note>(DeleteNoteAction); EditNoteCommand = new RelayCommand<Note>(EditNoteAction); AddNewNoteFolderCommand = new RelayCommand( () => { // goto NewNoteFolderPage System.Diagnostics.Debug.WriteLine("Here we need to goto NewNoteFolderPage..."); }); ViewAllNotesCommand = new RelayCommand( () => { // goto NoteListPage _navigationService.Navigate<NoteListPage>(); }); Messenger.Default.Register<NotificationMessage>(this, (message) => { switch (message.Notification) { case "UpdateNoteList": GetRuiNoteList(); break; case "AppBarButtonNewNotebookVisiable": // Rui: using converter for boolean to visibility // in xmal: xmlns:conv="using:RuiNote.Helpers" // create a new help class: BooleanToVisibilityConverter.cs // then group the appBarButtons /* <Page.Resources> <conv:BooleanToVisibilityConverter x:Key="MyConverter"/> </Page.Resources> * Visibility="{Binding AppBarButtonNewNotebookVisibility, Converter={StaticResource MyConverter}}"/> * */ AppBarButtonNewNotebookVisibility = true; AppBarButtonNewNoteVisibility = false; break; case "AppBarButtonNewNoteVisiable": AppBarButtonNewNotebookVisibility = false; AppBarButtonNewNoteVisibility = true; break; default: break; } }); }
/// <summary> /// Initializes a new instance of the <see cref="NewNotePageViewModel"/> class. /// </summary> /// <param name="navigationService"> /// The navigation service. /// </param> /// <param name="noteCompositionSessionService"> /// The note composition session service. /// </param> /// <param name="messageBox"> /// The message box. /// </param> /// <param name="logManager"> /// The log manager. /// </param> public NewNotePageViewModel(INavigationService navigationService, INoteSessionService noteSessionService, IMessageBoxService messageBox, ILogManager logManager) { _navigationService = navigationService; _noteSessionService = noteSessionService; _messageBox = messageBox; _logManager = logManager; AddCommand = new RelayCommand( () => { // here we need to save the new added note, // including title, cotent and time AddNoteAction(); }); CancelCommand = new RelayCommand( () => { CancelAction(); }); _note = new Note(); Messenger.Default.Register<NotificationMessage>(this, (message) => { // We need to get the note list count right after the NewNotePage is navigated to // We can't get the note list count when back button is pressed // Because, we don't get the instance of navigation service is already been destroyed when back button is fired. if (message.Notification == "GetNoteListCount") { id = (int)_navigationService.CurrentParameter; } if (message.Notification == "NewNotePageBackButtonPressed") { if (_note.NoteTitle == null && _note.NoteContent == null) { // we don't save the empty note. System.Diagnostics.Debug.WriteLine("note is empty we don't save..."); } else { AddNoteAction(); } } }); }