public void DeleteBookmark(BookmarkModel data)
 {
     using (BookDataContext context = BookDataContext.Connect())
     {
         BookmarkModel model = context.Bookmarks.FirstOrDefault(t => t.BookmarkID == data.BookmarkID);
         context.Bookmarks.DeleteOnSubmit(model);
         context.SubmitChanges();
     }
 }
 public BookmarkItemDataModel CreateBookmarkDataModel(BookmarkModel bookmark, string bookTitle = null)
 {
     var dataModel = new BookmarkItemDataModel();
     dataModel.BookmarkText = bookmark.Text;
     dataModel.Color = new SolidColorBrush(ColorHelper.ToColor(bookmark.Color));
     dataModel.Bookmark = bookmark;
     dataModel.BookTitle = bookTitle;
     return dataModel;
 }
 public BookmarkSearchResultDaraModel CreateBookmarkSearchDataModel(BookmarkModel bookmark, string searchQuery, string bookTitle = null)
 {
     var dataModel = new BookmarkSearchResultDaraModel();
     dataModel.BookmarkText = bookmark.Text;
     dataModel.SearchQuery = searchQuery;
     dataModel.BookId = bookmark.BookID;
     dataModel.TokenOffset = bookmark.TokenID;
     dataModel.BookTitle = bookTitle;
     dataModel.Color = new SolidColorBrush(ColorHelper.ToColor(bookmark.Color));
     return dataModel;
 }
 public BookmarkModel AddBookmark(string bookId, ICollection<BookmarkModel> bookmarks, string text, int color, int startTokenID, int endTokenID = -1)
 {
     using (BookDataContext bookDataContext = BookDataContext.Connect())
     {
         var entity = new BookmarkModel
         {
             BookID = bookId,
             TokenID = startTokenID,
             EndTokenID = endTokenID,
             Text = text,
             Color = color
         };
         bookDataContext.Bookmarks.InsertOnSubmit(entity);
         bookDataContext.SubmitChanges();
         bookmarks.Add(entity);
         return entity;
     }
 }
Exemple #5
0
        private static Polygon RenderHighlight(BookmarkModel bookmarkModel, Panel canvas, PageRenderData context)
        {
            int tokenID = bookmarkModel.TokenID;
            TextRenderData firstHighlightedText = context.Texts.FirstOrDefault(t => t.TokenID == tokenID) ??
                                        (context.Texts).FirstOrDefault();

            if (firstHighlightedText == null) 
                return null;

            int endTokenID = bookmarkModel.EndTokenID;
            TextRenderData lastHighlightedText = context.Texts.LastOrDefault(t => t.TokenID == endTokenID) ??
                                                    (context.Texts).LastOrDefault();
            if (lastHighlightedText == null) 
                return null;

            Rect firtstRect = firstHighlightedText.Rect;
            Rect lastRect = lastHighlightedText.Rect;
            var pointCollection = SelectionHelper.GetSelectionPolygon(
                firtstRect, 
                lastRect,
                canvas.ActualWidth, 
                context.OffsetX,
                Convert.ToDouble(AppSettings.Default.FontSettings.FontInterval));

            var polygon = new Polygon
                              {
                                  Width = canvas.ActualWidth,
                                  Height = canvas.ActualHeight,
                                  Fill = new SolidColorBrush(ColorHelper.ToColor(bookmarkModel.Color)) {Opacity = 0.3},
                                  Points = pointCollection,
                                  Visibility = Visibility.Visible
                              };
            return polygon;
            
        }
 public BookmarkRemoved(BookmarkModel bookmarkModel)
 {
     Bookmark = bookmarkModel;
 }