示例#1
0
        private void AddBookmark(string text, TextRenderData first, TextRenderData last, Color color)
        {
            BookmarkModel bookmark = _bookmarkRepository.AddBookmark(
                ViewModel.BookId,
                PageCanvas.Bookmarks,
                text,
                ColorHelper.ToInt32(color),
                first.TokenID,
                last.TokenID);

            var previousPageWord = PageCanvas.PreviousTexts.LastOrDefault() ?? new TextRenderData();

            if (first.TokenID == previousPageWord.TokenID)
            {
                PageCanvas.Highlight(PageCanvas.GetPrevPagePanel(), previousPageWord.Rect, previousPageWord.Rect, bookmark, color);
            }

            var nextPageWord = PageCanvas.NextTexts.FirstOrDefault() ?? new TextRenderData();

            if (last.TokenID == nextPageWord.TokenID)
            {
                PageCanvas.Highlight(PageCanvas.GetNextPagePanel(), nextPageWord.Rect, nextPageWord.Rect, bookmark, color);
            }

            PageCanvas.Highlight(PageCanvas.GetCurrentPagePanel(), first.Rect, last.Rect, bookmark, color);
        }
示例#2
0
        private static Image GetVerseBookmarkImage(int bibleId, string verseKey)
        {
            string bibleKey = Formatters.IsBiblesKey(verseKey) ?
                              verseKey : $"{bibleId}||{verseKey}";

            BookmarkModel model = BiblesData.Database.GetBookmark(bibleKey);

            if (model == null)
            {
                return(null);
            }

            ModelsBookmark bookmark = model.CopyToObject(new ModelsBookmark()).To <ModelsBookmark>();

            string imgToolTip = bookmark.BookMarkName.IsNullEmptyOrWhiteSpace() && bookmark.Description.IsNullEmptyOrWhiteSpace() ?
                                bookmark.SelectedVerse : bookmark.BookMarkName.IsNullEmptyOrWhiteSpace() ?
                                $"{bookmark.SelectedVerse}{Environment.NewLine}{bookmark.Description}" :
                                $"{bookmark.SelectedVerse}{Environment.NewLine}{bookmark.BookMarkName}{Environment.NewLine}{Environment.NewLine}{bookmark.Description}";

            Image img = new Image
            {
                Source  = IconSets.ResourceImageSource("BookmarkSmall", 16),
                ToolTip = imgToolTip,
                Opacity = 0.5,
                Tag     = bibleKey
            };

            img.PreviewMouseLeftButtonUp += BibleLoader.Bookmark_Selected;

            return(img);
        }
示例#3
0
        private static void Bookmark_Selected(object sender, MouseButtonEventArgs e)
        {
            try
            {
                Image item = (Image)sender;

                string verseKey = item.Tag.ParseToString();

                BookmarkModel bookmarkModel = BiblesData.Database.GetBookmark(verseKey);

                ModelsBookmark model = bookmarkModel.CopyToObject(new ModelsBookmark()).To <ModelsBookmark>();

                model.SetVerse(verseKey);

                if (ModelView.ShowDialog("Bookmark", model).IsFalse())
                {
                    return;
                }

                BookmarkModel dbModel = model.CopyToObject(new BookmarkModel()).To <BookmarkModel>();

                BiblesData.Database.InsertBookmarkModel(dbModel);
            }
            catch (Exception err)
            {
                ErrorLog.ShowError(err);
            }
        }
示例#4
0
 public ActionResult AddBookmark(BookmarkModel bookmark)
 {
     try
     {
         if (ModelState.IsValid)
         {
             manager.collectionService.AddBookmark(bookmark.ToServiceBookmark());
             var model = Bookmark.GetBookmarkList(bookmark.CollectionBookID);
             if (Request.IsAjaxRequest())
             {
                 return(PartialView("_BookmarkListView", model));
             }
             else
             {
                 return(RedirectToAction("Details", new { id = bookmark.CollectionBookID }));
             }
         }
         return(RedirectToAction("Details", new { id = bookmark.CollectionBookID }));
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         return(View("Error"));
     }
 }
示例#5
0
 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();
     }
 }
示例#6
0
        public HttpResponseMessage AddBookmark([FromBody] Bookmark bookmark)
        {
            if (bookmark != null)
            {
                var  bookmarkModel = new BookmarkModel();
                bool isBookmark    = bookmarkModel.CheckBookmark(bookmark.PersonId, bookmark.PersonIdBookmark);
                if (bookmark.PersonId == bookmark.PersonIdBookmark)
                {
                    return(ResponseFail(StringResource.You_have_bookmark_this_person));
                }
                else if (isBookmark)
                {
                    return(ResponseFail(StringResource.You_have_bookmark_this_person));
                }
                else
                {
                    var accountModel = new AccountModel();
                    var account      = accountModel.GetAccountById(bookmark.PersonIdBookmark);
                    if (account != null)
                    {
                        var book = new CoMS.Entities_Framework.Bookmark();
                        book.PERSON_ID          = bookmark.PersonId;
                        book.PERSON_ID_BOOKMARK = bookmark.PersonIdBookmark;
                        book.NAME_BOOKMARK      = Utils.GetFullName(account.CURRENT_FIRST_NAME, account.CURRENT_MIDDLE_NAME, account.CURRENT_LAST_NAME);
                        book.IMAGE_BOOKMARK     = account.Image;
                        book.DESCRIPTION        = account.CURRENT_HOME_ORGANIZATION_NAME;
                        book.CREATE_DATE        = DateTime.Now;

                        bool result = bookmarkModel.AddBookmark(book);
                        if (result)
                        {
                            return(ResponseSuccess(StringResource.Success));
                        }
                        else
                        {
                            return(ResponseFail(StringResource.Sorry_an_error_has_occurred));
                        }
                    }
                    else
                    {
                        return(ResponseFail(StringResource.Account_does_not_exist));
                    }
                }
            }
            else
            {
                return(ResponseFail(StringResource.Data_not_received));
            }
        }
示例#7
0
 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);
     }
 }
示例#8
0
        public HttpResponseMessage DeleteBookmark([FromBody] Bookmark bookmark)
        {
            var bookmarkModel = new BookmarkModel();
            var book          = new CoMS.Entities_Framework.Bookmark();

            book.PERSON_ID          = bookmark.PersonId;
            book.PERSON_ID_BOOKMARK = bookmark.PersonIdBookmark;
            bool result = bookmarkModel.RemoveBookmark(book);

            if (result)
            {
                return(ResponseSuccess(StringResource.Success));
            }
            else
            {
                return(ResponseFail(StringResource.Sorry_an_error_has_occurred));
            }
        }