Пример #1
0
        private void OpenClippingWindow(int clippingId)
        {
            var clipping = ClippingDatabase.GetClipping(clippingId);

            OpenClippingWindow(clipping);
        }
Пример #2
0
        private void PopulateTree(IEnumerable <Author> authors)
        {
            var root = new TreeItem
            {
                Key      = "ROOT",
                Text     = "My Clippings",
                Expanded = true
            };

            _treeView.DataStore = root;

            foreach (var author in authors.OrderBy(a => a.Name))
            {
                var authorName = String.IsNullOrEmpty(author.Name) ? "Unknown Author" : author.Name;

                var authorItem = new TreeItem
                {
                    Text     = authorName,
                    Expanded = false,
                    Image    = Common.PersonIcon
                };

                foreach (var book in author.Books.Values.OrderBy(b => b.Name))
                {
                    var bookName = String.IsNullOrEmpty(book.Name) ? "Unknown Book" : book.Name;

                    var bookItem = new TreeItem
                    {
                        Text     = bookName,
                        Expanded = false,
                        Image    = Common.BookIcon
                    };

                    foreach (var clipping in book.Clippings.OrderBy(c => c.BeginningLocation).ThenBy(c => c.BeginningPage))
                    {
                        var id = ClippingDatabase.AddClipping(clipping);

                        var hasPage     = !String.IsNullOrEmpty(clipping.Page);
                        var hasLocation = !String.IsNullOrEmpty(clipping.Location);

                        string clippingText = "";

                        if (hasPage)
                        {
                            clippingText += "Page " + clipping.Page;
                        }
                        else if (hasLocation)
                        {
                            clippingText += "Location " + clipping.Location;
                        }
                        else
                        {
                            clippingText += "Unknown Location";
                        }

                        var preview = Preview(clipping.Text);
                        if (!String.IsNullOrEmpty(preview))
                        {
                            clippingText += ": " + preview;
                        }

                        bookItem.Children.Add(new TreeItem {
                            Text = clippingText, Key = id.ToString(), Image = Common.GetClippingTypeIcon(clipping.ClippingType)
                        });
                    }

                    authorItem.Children.Add(bookItem);
                }

                root.Children.Add(authorItem);
            }

            _treeView.RefreshData();
        }