private static void initializeNotes() { string[] fileNames = Directory.GetFiles(DirectoryName); StreamReader file; foreach (string name in fileNames) { file = new StreamReader(name); var note = new Note(); fillNote(note, name); AllNotes.Add(note); file.Close(); } void fillNote(Note note, string name) { string textLine; note.Categories = takeCategories(file); note.Date = takeDate(file); note.DateFormatted = note.Date.ToString("MM/dd/yyyy"); note.Title = name.Substring(name.LastIndexOf('\\') + 1, name.LastIndexOf('.') - name.LastIndexOf('\\') - 1); note.FileType = name.Substring(name.LastIndexOf('.') + 1); note.IsMarkdown = note.FileType != "txt"; while ((textLine = file.ReadLine()) != null) { note.Content += textLine; } } }
private void NewNote(NoteType noteType) { Modified = true; ClearFilter(); // Create new note and update model list NoteModel noteModel = new NoteModel(); noteModel.NoteType = noteType; noteModel.BackgroundColorHex = _settingsService.LoadSettingsOrDefault().DefaultNoteColorHex; // Update view model list NoteViewModel noteViewModel = new NoteViewModel(_navigationService, Language, Icon, Theme, _webviewBaseUrl, _searchableTextConverter, _repositoryService, _feedbackService, null, _noteCryptor, _model.Safes, _model.CollectActiveTags(), noteModel); NoteInsertionMode insertionMode = _settingsService.LoadSettingsOrDefault().DefaultNoteInsertion; switch (insertionMode) { case NoteInsertionMode.AtTop: var lastPinned = AllNotes.LastOrDefault(x => x.IsPinned == true); var index = lastPinned == null ? 0 : AllNotes.IndexOf(lastPinned) + 1; _model.Notes.Insert(index, noteModel); AllNotes.Insert(index, noteViewModel); break; case NoteInsertionMode.AtBottom: _model.Notes.Add(noteModel); AllNotes.Add(noteViewModel); break; default: throw new ArgumentOutOfRangeException(nameof(insertionMode)); } ShowNoteCommand.Execute(noteViewModel.Id); }
public MainPageViewModel() { EraseCommand = new Command(() => { TheNote = ""; }); SaveCommand = new Command(() => { AllNotes.Add(TheNote); TheNote = ""; }); }
public void SaveNewNote() { if (!String.IsNullOrEmpty(NewTextTitle)) { AllNotes.Add(new Note(NewTextTitle, NewTextNote, DateTime.Now)); _navigationService.GoBack(); NewTextTitle = String.Empty; NewTextNote = String.Empty; } }
/// <summary> /// Update the notes when Notes event is triggered /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnDataServiceChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == "Notes") { AllNotes.Clear(); foreach (Note n in DataService.Instance.Notes) { AllNotes.Add(n); } } }
public void AddNote() { AllNotes.Add(new NoteModel() { InputTxt = EditorInput, ImgSource = "https://picsum.photos/200/?random=" + new Random().Next().ToString() }); ToNotesFile(); EditorInput = ""; NotifyPropertyChanged(EditorInput); }
public void Refresh() { AllNotes.Clear(); foreach (var n in _context.Notes) { AllNotes.Add(n); } Categories.Clear(); foreach (var c in _context.NoteCategories) { Categories.Add(c); } }
static void initializeNotes() { string[] fileNames = Directory.GetFiles(DirectoryName); StreamReader file; Note newNote; string categoryHeader, dateHeader, textLine; int day, month, year; foreach (string name in fileNames) { newNote = new Note(); file = new StreamReader(name); checkFormat(); if (isFormatProper()) { fillNote(name); AllNotes.Add(newNote); file.Close(); } } AllNotes = AllNotes.OrderBy(note => note.ValidityDate.Day).ToList(); void checkFormat() { categoryHeader = file.ReadLine(); dateHeader = file.ReadLine(); } bool isFormatProper() => categoryHeader.Substring(0, 9) == "category:" && dateHeader.Substring(0, 5) == "date:"; void fillNote(string fileName) { year = Int32.Parse(dateHeader.Substring(11)); month = Int32.Parse(dateHeader.Substring(5, 2)); day = Int32.Parse(dateHeader.Substring(8, 2)); newNote.ValidityDate = new DateTime(year, month, day); newNote.Category = categoryHeader.Substring(9); newNote.Title = fileName.Substring(fileName.LastIndexOf('/') + 1); newNote.Content = ""; while ((textLine = file.ReadLine()) != null) { newNote.Content += textLine; } } }
public MainPageViewModel() { EraseCommand = new Command(() => { TheNote = string.Empty; }); SaveCommand = new Command(() => { AllNotes.Add(new Notes { Note = TheNote }); SavedNotes.Add(new Notes { Note = TheNote }); TheNote = string.Empty; }); EraseNoteCommand = new Command(() => { AllNotes.Clear(); }); UndoClearCommand = new Command(() => { AllNotes = SavedNotes; }); }
public MainPageViewModel() { EraseCommand = new Command(() => { TheNote = string.Empty; }); // I think we really need too better grok the big arrow syntax because it's useful in all sorts of ways SaveCommand = new Command(() => { AllNotes.Add(TheNote); System.Diagnostics.Debug.WriteLine("god save the queen"); TheNote = string.Empty; }); AllNotes = new ObservableCollection <string>(); }
public MainPageViewModel() { MessagingCenter.Subscribe <NoteDetailsViewModel>(this, "Unselect", (sender) => { SelectedNote = null; }); AddCommand = new Command(() => { if (NewNote != "" && NewNote != null) { NoteItem item = new NoteItem(); if (AllNotes.Count == 0) { item.Id = 1; } else { item.Id = AllNotes.LastOrDefault().Id + 1; } item.NoteText = NewNote; AllNotes.Add(item); AddToDB(item); NewNote = string.Empty; } }); SelectedNoteCommand = new Command(async() => { if (SelectedNote != null) { var noteDetailsVM = new NoteDetailsViewModel(SelectedNote, AllNotes, ApiURL); var noteDetailsPage = new NoteDetails(); noteDetailsPage.BindingContext = noteDetailsVM; await Application.Current.MainPage.Navigation.PushAsync(noteDetailsPage); } }); }
public MainPageViewModel() { SelectedNoteChangedCommand = new Command(async() => { var detailVM = new DetailPageViewModel(SelectedNote); var detailPage = new DetailPage(); detailPage.BindingContext = detailVM; await Application.Current.MainPage.Navigation.PushModalAsync(detailPage); }); EraseCommand = new Command(() => { TheNote = string.Empty; }); SaveCommand = new Command(() => { AllNotes.Add(TheNote); TheNote = string.Empty; }); }
DocumentPanel CreateNewNote() { Note note = new Note() { Caption = "Untitled", Book = ActiveBook }; NotePage page = new NotePage() { Caption = "Untitled" }; note.Pages.Add(page); DocumentPanel notePanel = CreateNoteDocument(note); bool result = dockManager.DockController.Insert( notesContainer, notePanel, notesContainer.Items.Count - 1 ); if (result) { AllNotes.Add(note); } return(result ? notePanel : null); }
private void NewNote(NoteType noteType) { Modified = true; ClearFilter(); // Create new note and update model list NoteModel noteModel = new NoteModel(); noteModel.NoteType = noteType; noteModel.HtmlContent = "<h1> </h1>"; // Start with header format. noteModel.BackgroundColorHex = _settingsService.LoadSettingsOrDefault().DefaultNoteColorHex; // Update view model list NoteViewModel noteViewModel = new NoteViewModel(_navigationService, Language, Icon, Theme, _webviewBaseUrl, _searchableTextConverter, _repositoryService, _feedbackService, null, _noteCryptor, _model.Safes, noteModel); NoteInsertionMode insertionMode = _settingsService.LoadSettingsOrDefault().DefaultNoteInsertion; switch (insertionMode) { case NoteInsertionMode.AtTop: _model.Notes.Insert(0, noteModel); AllNotes.Insert(0, noteViewModel); FilteredNotes.Insert(0, noteViewModel); break; case NoteInsertionMode.AtBottom: _model.Notes.Add(noteModel); AllNotes.Add(noteViewModel); FilteredNotes.Add(noteViewModel); break; default: throw new ArgumentOutOfRangeException(nameof(insertionMode)); } ShowNote(noteViewModel.Id); }