Example #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            editNote = NoteManager.GetNoteById((int)e.Parameter);

            initTile();

            editNote.Tags.ForEach(p => TagsList.Add(p));
            tagTexts = new List<string>();
            editNote.Tags.ForEach(p => tagTexts.Add(p.Text));

            if (editNote.Id == 0)
            {
                int colorIndex = (new Random()).Next(ColorBoxes.Count - 1);
                editNote.Color = ColorBoxes[colorIndex].Color;
                editNote.StringColor = ColorBoxes[colorIndex].StringColor;
            }
            LockNoteButton.Label = editNote.LockNoteFlyoutText;
            LockGlyph.Visibility = editNote.Locked ? Visibility.Visible : Visibility.Collapsed;
            PinUnpinButton.Visibility = editNote.Locked || editNote.Id == 0 ? Visibility.Collapsed : Visibility.Visible;
            ShareButton.Visibility = editNote.Id == 0 ? Visibility.Collapsed : Visibility.Visible;

            TitleTextBox.Text = editNote.Title;
            ContentTextBox.Text = editNote.Text;
            colorBoxToSave.Color = editNote.Color;
            colorBoxToSave.StringColor = editNote.StringColor;
            ParentGrid.Background = new SolidColorBrush(editNote.Color);

            SaveNoteButton.IsEnabled = false;

            NoTagsTextBlock.Visibility = tagTexts.Count == 0 ? Visibility.Visible : Visibility.Collapsed;

            if (editNote.Id == 0)
            {
                editNote.Id = NoteManager.NewId();
            }
            SecondaryTileId = editNote.Id + "NoteTile";
            contentChanged = false;
        }
Example #2
0
        public static void UpdateTile(string tileId, Note note)
        {
            SecondaryTile secondaryTile = new SecondaryTile(tileId);

            var noteContent = note.Text;
            var noteTitle = note.Title;

            if (noteContent.Length > 200) noteContent = noteContent.Substring(0, 200);

            var tileContent = CreateTileTemplate();

            XmlDocument doc = tileContent.GetXml();

            XmlNodeList tileTextAttributes = doc.GetElementsByTagName("text");
            tileTextAttributes[0].InnerText = noteTitle;
            tileTextAttributes[1].InnerText = noteContent;
            tileTextAttributes[2].InnerText = noteTitle;
            tileTextAttributes[3].InnerText = noteContent;
            tileTextAttributes[4].InnerText = noteTitle;
            tileTextAttributes[5].InnerText = noteContent;
            tileTextAttributes[6].InnerText = noteTitle;
            tileTextAttributes[7].InnerText = noteContent;

            var tileNotification = new TileNotification(doc);

            TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId).Update(tileNotification);
        }
Example #3
0
        private async void DuplicateNoteFlyoutItem_Click(object sender, RoutedEventArgs e)
        {
            var note = (Note)(e.OriginalSource as FrameworkElement).DataContext;

            Note newNote = new Note { Color = note.Color, Locked = note.Locked,
                                    LockNoteFlyoutText = note.LockNoteFlyoutText, LockVisibility = note.LockVisibility,
                                    NoteVisibility = note.NoteVisibility, PinText = note.PinText, StringColor = note.StringColor,
                                    Tags = note.Tags, Text = note.Text, Title = note.Title };

            newNote.Id = NoteManager.NewId();
            newNote.Date = DateTime.Now;
            newNote.EditDate = NoteManager.FormatDate(newNote.Date);
            Notes.Add(newNote);
            NoteManager.AddNote(newNote);
            await NoteManager.SaveNotes();
            UpdateNotes();
        }
Example #4
0
        private void MainStackPanel_RightTapped(object sender, RightTappedRoutedEventArgs e)
        {
            FrameworkElement senderElement = sender as FrameworkElement;
            FlyoutBase flyoutBase = FlyoutBase.GetAttachedFlyout(senderElement);

            flyoutBase.ShowAt(senderElement);

            var note = (Note)(e.OriginalSource as FrameworkElement).DataContext;

            lockedNote = note;
        }
Example #5
0
        private void MainGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var note = (Note)e.ClickedItem;
            var id = note.Id;

            if (!note.Locked)
            {
                Frame.Navigate(typeof(EditNotePage), id);
            }
            else
            {
                LockInputGrid.Visibility = Visibility.Visible;
                lockedNote = note;
            }
        }
Example #6
0
        public static void UpdateNote(Note note)
        {
            var index = AllNotesList.IndexOf(note);

            AllNotesList[index] = note;
        }
Example #7
0
 public static void AddNote(Note note)
 {
     AllNotesList.Add(note);
 }
Example #8
0
 public static void DeleteNote(Note note)
 {
     AllNotesList.Remove(note);
 }