Example #1
0
        void notebook_NoteAdded(object sender, NoteEventArgs e)
        {
            if (AllNoteControls.Any(c => c.Note == e.Note))
            {
                return;
            }
            var ctrlNote = new ucNote()
            {
                Note     = e.Note,
                WordWrap = WordWrap
            };

            foreach (var otherCtrlNote in AllNoteControls)
            {
                if (otherCtrlNote.Note.CreatedDate > ctrlNote.Note.CreatedDate)
                {
                    pnlNotes.Children.Insert(pnlNotes.Children.IndexOf(otherCtrlNote), ctrlNote);
                    break;
                }
            }
            if (!pnlNotes.Children.Contains(ctrlNote))
            {
                pnlNotes.Children.Add(ctrlNote);
            }
            //pnlNotes.UpdateLayout();
            scrollNotes.UpdateLayout();
            scrollNotes.ScrollToVerticalOffset(ctrlNote.TranslatePoint(new Point(0, 0), pnlNotes).Y);
        }
Example #2
0
        private void LoadNotes()
        {
            Save();
            var filter = CreateNoteFilter();

            foreach (var ctrlNote in AllNoteControls.ToList())
            {
                ctrlNote.UpdateNote(); // persist current editor changes
                if (!filter(ctrlNote.Note))
                {
                    pnlNotes.Children.Remove(ctrlNote);
                }
            }
            var matchingNotes = _notebook.AllNotes.Where(filter);

            foreach (var note in matchingNotes)
            {
                if (AllNoteControls.Any(nc => nc.Note.Equals(note)))
                {
                    continue;
                }
                var ctrlNote = new ucNote()
                {
                    Note     = note,
                    WordWrap = WordWrap
                };
                foreach (var otherCtrlNote in AllNoteControls)
                {
                    if (otherCtrlNote.Note.CreatedDate > ctrlNote.Note.CreatedDate)
                    {
                        pnlNotes.Children.Insert(pnlNotes.Children.IndexOf(otherCtrlNote), ctrlNote);
                        break;
                    }
                }
                if (!pnlNotes.Children.Contains(ctrlNote))
                {
                    pnlNotes.Children.Add(ctrlNote);
                }
            }
        }