Esempio n. 1
0
        /// <summary>
        /// Delete all bookmarks with same value
        /// </summary>
        /// <param name="bmItem"></param>
        /// <returns></returns>
        public bool DeleteAllBookmarks(BookmarkItem bmItem)
        {
            try
            {
                for (int i = 0; i < bmItem.Items.Count; i++)
                {
                    DeleteBookmarkWithPair(bmItem.Items[i]);
                }
                return(true);
            }
            catch (BaseException srvExp)
            {
                Services.ServiceException newSrvExp = new Services.ServiceException(ErrorCode.ipe_DeleteBookmarkError);
                newSrvExp.Errors.Add(srvExp);

                throw newSrvExp;
            }
            catch (Exception ex)
            {
                ServiceException srvExp = new ServiceException(ErrorCode.ipe_DeleteBookmarkError,
                                                               MessageUtils.Expand(Properties.Resources.ipe_DeleteBookmarkError, ex.Message), ex.StackTrace);
                return(false);

                throw srvExp;
            }
        }
        public async Task <ActionResult <BookmarkItem> > AddBookmarkItem(BookmarkItem item)
        {
            _context.BookmarkItems.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetBookmarkItem), new { id = item.Id }, item));
        }
Esempio n. 3
0
        private BookmarkViewModel ToBookmarkViewModel(BookmarkItem bookmark)
        {
            int pageNumber = this.document.Pages.IndexOf(bookmark.Destination.Page) + 1;
            BookmarkViewModel bookmarkViewModel = new BookmarkViewModel(pageNumber, bookmark);

            return(bookmarkViewModel);
        }
Esempio n. 4
0
 public void HighLightAllBookmark(BookmarkItem item)
 {
     foreach (Bookmark bm in item.Items)
     {
         HighlightWithPair(bm);
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Get Next Bookmark from the cursor.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private Bookmark GetNextBookmark(BookmarkItem item)
        {
            string          srvKey = string.Empty;
            ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey);

            GetCurrentSelection(srvKey);
            Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey);
            int cursorPosition = srvPro.ContentService.WSelection.Start;
            int min            = int.MaxValue;
            int index          = 0;

            if ((cursorPosition >= GetLastBookmark(item).Start))
            {
                return(GetFirstBookmark(item));
            }

            for (int i = 0; i < item.Items.Count; i++)
            {
                if (item.Items[i].Start > cursorPosition)
                {
                    if (item.Items[i].Start < min)
                    {
                        min   = item.Items[i].Start;
                        index = i;
                    }
                }
            }

            return(item.Items[index]);
        }
Esempio n. 6
0
        /// <summary>
        /// Get Previous from the cursor.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private Bookmark GetPreviousBookmark(BookmarkItem item)
        {
            string          srvKey = string.Empty;
            ServicesProfile srvPro = Wkl.MainCtrl.ServiceCtrl.CreateProfile(out srvKey);

            GetCurrentSelection(srvKey);
            Wkl.MainCtrl.ServiceCtrl.RemoveDataObject(srvKey);
            int cursorPosition = srvPro.ContentService.WSelection.Start;
            int max            = -1;
            int index          = -1;

            for (int i = 0; i < item.Items.Count; i++)
            {
                if (item.Items[i].Start <cursorPosition && item.Items[i].Start> max)
                {
                    max   = item.Items[i].Start;
                    index = i;
                }
            }

            if (index > -1)
            {
                return(item.Items[index]);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 7
0
        internal void UpdateBookmarkItem(RadFixedPage page)
        {
            if (this.BookmarkItem == null)
            {
                this.BookmarkItem = new BookmarkItem(this.Title, new Location());
            }

            BookmarkItem currentBookmark = this.BookmarkItem;

            byte red   = Convert.ToByte(this.TextColorR);
            byte green = Convert.ToByte(this.TextColorG);
            byte blue  = Convert.ToByte(this.TextColorB);

            currentBookmark.TextColor  = new RgbColor(red, green, blue);
            currentBookmark.Title      = this.Title;
            currentBookmark.IsExpanded = this.IsExpanded;
            currentBookmark.TextStyle  = this.TextStyle;

            Location destination = (Location)currentBookmark.Destination;

            destination.Top  = this.Top;
            destination.Left = this.Left;
            destination.Zoom = this.Zoom;
            destination.Page = page;
        }
Esempio n. 8
0
        public ArrayList GetBookmarksChildren(long idparent, long type = -1)
        {
            //TODO: check if title is empty and fetch the one from moz_places if necessary
            var reader = ExecuteQuery(
                "SELECT moz_bookmarks.id AS id, moz_bookmarks.title AS title, parent, type, url, content, dateAdded, lastModified"
                + " FROM (moz_bookmarks LEFT JOIN moz_places ON moz_bookmarks.fk=moz_places.id)"
                + " LEFT JOIN "
                + "(SELECT item_id, anno_attribute_id, content FROM moz_items_annos WHERE anno_attribute_id=2) mia"
                + " ON moz_bookmarks.id=mia.item_id"
                + " WHERE parent = @idparent"
                + (type == -1 ? "" : " and type = " + type)
                + " ORDER BY position ASC",
                new[] { new SQLiteParameter("idparent", idparent) });

            var ret = new ArrayList();

            while (reader.Read())
            {
                var bkm = new BookmarkItem
                {
                    Id           = (long)reader["id"],
                    Parent       = (long)reader["parent"],
                    Title        = reader["title"].ToString(),
                    Type         = reader.GetInt32(reader.GetOrdinal("type")),
                    Location     = reader["url"].ToString(),
                    Description  = reader["content"].ToString(),
                    LastModified = (long)reader["lastModified"],
                    DateAdded    = (long)reader["dateAdded"]
                };
                ret.Add(bkm);
            }
            _conn.Close();
            return(ret);
        }
Esempio n. 9
0
        private void LoadMarks()
        {
            mlist.Items.Clear();
            this.mark = GetMark();

            foreach (var mark in this.mark.Marks)
            {
                ChapterMark  tmp  = mark;
                BookmarkItem item = new BookmarkItem();
                item.DataContext = tmp;

                item.Click += (sender, ex) =>
                {
                    Progress progress = null;

                    IsolatedStorageSettings.ApplicationSettings.TryGetValue <Progress>("current", out progress);
                    if (progress == null)
                    {
                        progress = new Progress();
                    }
                    progress.Chapter = tmp.ChapterNo;
                    progress.Page    = tmp.Current;
                    progress.Percent = tmp.Percent;
                    IsolatedStorageSettings.ApplicationSettings["current"] = progress;

                    Dispatcher.BeginInvoke(() =>
                    {
                        (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/View/Viewer.xaml", UriKind.Relative));
                    });
                };

                this.mlist.Items.Add(item);
            }
        }
Esempio n. 10
0
        static string DumpBookmarkItem(BookmarkItem bookmarkItem, int level, bool detail = false)
        {
            var stringBuilder = new StringBuilder();

            stringBuilder.Append(SpaceChars(level * 5));
            stringBuilder.AppendFormat("{0,-4}|{1}", bookmarkItem.Id, bookmarkItem.Description);

            if (detail)
            {
                var location = bookmarkItem.GetLocation();
                if (location != null)
                {
                    stringBuilder.AppendFormat("|{0}|{1}", location.FileLocation, location.LocateLineNumber);
                }
            }

            if (bookmarkItem.ChildItems != null && bookmarkItem.ChildItems.Count > 0)
            {
                foreach (var childItem in bookmarkItem.ChildItems)
                {
                    stringBuilder.AppendLine();
                    stringBuilder.Append(DumpBookmarkItem(childItem, level + 1, detail));
                }
            }

            return(stringBuilder.ToString());
        }
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            var newItem = new BookmarkItem();

            newItem.URL   = SearchTextBox.Text;
            newItem.Title = webBrowser1.DocumentTitle;
            BookmarkManager.AddItem(newItem);
        }
Esempio n. 12
0
        ///////////////////////////////////////////////////
        // ADDS A BOOKMARK TO THE DATABASE WHEN CLICKED //
        /////////////////////////////////////////////////
        private void bookmarkButton_Click(object sender, EventArgs e)
        {
            var bookmarkItem = new BookmarkItem();

            bookmarkItem.URL   = addressTextBox.Text;
            bookmarkItem.Title = browser1.DocumentTitle;
            BookmarkManager.AddItem(bookmarkItem);
        }
Esempio n. 13
0
        /// <summary>
        /// 点击右键菜单项,删除链接项目
        /// </summary>
        private void DeleteMenuItem_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            BookmarkItem sitem = (sender as MenuItem).DataContext as BookmarkItem;

            App.localFileCache.DeleteBookmark(sitem);
            App.pocketApi.DeleteItem(sitem);
            //UpdateUI();
        }
        private void addBookmark_Click(object sender, EventArgs e)
        {
            var page = new BookmarkItem();

            page.URL  = webBrowser1.Url.ToString();
            page.Name = HistoryManager.UrlToName(webBrowser1.Url.ToString());
            BookmarkManager.AddBookmark(page);
        }
Esempio n. 15
0
        //Add a bookmark
        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            BookmarkItem bookmark = new BookmarkItem();

            bookmark.Title = webBrowser1.DocumentTitle;
            bookmark.URL   = webBrowser1.Url.ToString();

            BookmarkManager.AddBookmarkItem(bookmark);
        }
Esempio n. 16
0
        /// <summary>
        /// 点击右键菜单项,标记收藏
        /// </summary>
        private void StarMenuItem_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            BookmarkItem sitem = (sender as MenuItem).DataContext as BookmarkItem;

            if (sitem.isStar == false)
            {
                sitem.isStar = true;
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Go to previous bookmark from the cursor.
        /// </summary>
        /// <param name="item"></param>
        public void GoPreviousBookmark(BookmarkItem item)
        {
            Bookmark bm = GetPreviousBookmark(item);

            if (bm != null)
            {
                bm.Range.Select();
            }
        }
Esempio n. 18
0
        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            // add a bookmark
            BookmarkItem item = new BookmarkItem();

            item.URL   = currentUrl;
            item.title = webBrowser1.DocumentTitle; // better thing for the title?
            BookmarkManager.AddItem(item);
        }
Esempio n. 19
0
        public int GetPageNo(string name)
        {
            BookmarkItem item = Find(name);

            if (item == null)
            {
                item = Find(name, FFirstPassItems);
            }
            return(item == null ? 0 : item.PageNo + 1);
        }
Esempio n. 20
0
        public void Add(string name, int pageNo, float offsetY)
        {
            BookmarkItem item = new BookmarkItem();

            item.Name    = name;
            item.PageNo  = pageNo;
            item.OffsetY = offsetY;

            FItems.Add(item);
        }
        private void BookmarkBttn_Click(object sender, EventArgs e)
        {
            webBrowser1.Navigate(toolStripTextBox1.Text.ToString());
            var item = new BookmarkItem
            {
                URL   = toolStripTextBox1.Text.ToString(),
                Title = toolStripTextBox1.Text.ToString()
            };

            BookmarkManager.AddItem(item);
        }
Esempio n. 22
0
        /// <summary>
        /// 点击按钮,进入链接阅读
        /// </summary>
        private void ItemBtn_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            BookmarkItem it = (sender as Button).DataContext as BookmarkItem;

            if (it.isUnReaded)
            {
                it.isUnReaded = false;
            }
            string url = LocalFileCache.ContentEncoder(it.href);

            parent.NavigationService.Navigate(new Uri("/Views/BrowserPage.xaml?url=" + url, UriKind.Relative));
        }
Esempio n. 23
0
        private void toolStripButton6_Click(object sender, EventArgs e) //bookmark button
        {
            var itemsForm = new BookmarkManagerForm();

            currentStateUrl = toolStripTextBox1.Text;
            var item = new BookmarkItem();

            item.URL   = toolStripTextBox1.Text;
            item.Title = webBrowser1.DocumentTitle;
            BookmarkManager.AddItem(item);
            itemsForm.ShowDialog();
        }
        public override void Execute(ITerminalCommandChannel terminalCommandChannel, Action <string> prompt)
        {
            if (terminalCommandChannel is BookmarkTerminalCommandChannel)
            {
                Handled = true;
                Result  = "done.";

                var bookmarkTerminalCommandChannel = terminalCommandChannel as BookmarkTerminalCommandChannel;

                var bookmarkPage = bookmarkTerminalCommandChannel.BookmarkContainer.CurrentPage;

                BookmarkItem newerBookmarkItem = null;
                if (TerminalCommandLine.ContainKeys("cat", "idx", "desc", "path", "text", "line"))
                {
                    newerBookmarkItem = new BookmarkItem()
                    {
                        Id          = bookmarkPage.GenerateItemId(),
                        Catalog     = TerminalCommandLine["cat"],
                        Index       = (int)Convert.ChangeType(TerminalCommandLine["idx"], typeof(int)),
                        Description = TerminalCommandLine["desc"],
                    };
                    newerBookmarkItem.Locations.Add(new BookmarkLocation()
                    {
                        FileLocation     = TerminalCommandLine["path"],
                        LocateLineText   = TerminalCommandLine["text"],
                        LocateLineNumber = (int)Convert.ChangeType(TerminalCommandLine["line"], typeof(int)),
                    });
                }

                if (newerBookmarkItem == null)
                {
                    prompt.Invoke("data is incomplete.");
                }

                if (TerminalCommandLine.ContainKeys("id"))
                {
                    var olderBookmarkItem = bookmarkPage.GetItemById((int)Convert.ChangeType(TerminalCommandLine["id"], typeof(int)));
                    if (olderBookmarkItem == null)
                    {
                        prompt.Invoke("id is invalid.");
                    }

                    olderBookmarkItem.ChildItems.Add(newerBookmarkItem);
                }
                else
                {
                    bookmarkPage.RootItems.Add(newerBookmarkItem);
                }

                bookmarkTerminalCommandChannel.BookmarkContainer.Set();
            }
        }
Esempio n. 25
0
 public void bookmarkButton_Click(object sender, EventArgs e)
 {
     try
     {
         var newBookmarkItem = new BookmarkItem();
         newBookmarkItem.URL   = webBrowser1.Url.ToString();
         newBookmarkItem.Title = webBrowser1.DocumentTitle;
         BookmarkManager.AddBookmarkItem(newBookmarkItem);
     } catch
     {
         MessageBox.Show("Bookmark URL already exists");
     }
 }
Esempio n. 26
0
        /// <summary>
        /// 点击右键菜单项,标为已读或未读
        /// </summary>
        private void ReadMenuItem_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            BookmarkItem mitem = (sender as MenuItem).DataContext as BookmarkItem;

            if (mitem.isUnReaded)
            {
                mitem.isUnReaded = false;
            }
            else
            {
                mitem.isUnReaded = true;
            }
        }
Esempio n. 27
0
        private void DeleteBookmarks()
        {
            foreach (object bookmark in this.itemsToDelete)
            {
                BookmarksCollection bookmarks         = this.document.Bookmarks;
                BookmarkViewModel   bookmarkViewModel = (BookmarkViewModel)bookmark;
                BookmarkItem        bookmarkToRemove  = bookmarkViewModel.BookmarkItem;

                this.IterateAndRemoveChildren(bookmarkToRemove, bookmarks);
            }

            this.LoadBookmarksFromPdfDocument();
        }
Esempio n. 28
0
        private void IterateAndRemoveChildren(BookmarkItem bookmarkToRemove, BookmarksCollection bookmarks)
        {
            foreach (BookmarkItem bookmarkItem in bookmarks)
            {
                if (bookmarkItem == bookmarkToRemove)
                {
                    bookmarks.Remove(bookmarkItem);
                    break;
                }

                this.IterateAndRemoveChildren(bookmarkToRemove, bookmarkItem.Children);
            }
        }
Esempio n. 29
0
        public static void UpdateBookmarks()
        {
            //if (!NeedsUpdated ()) return;

            XmlTextReader reader = GetXMLFromWebRequest("https://api.del.icio.us/v1/posts/all",
                                                        username, password);

            if (reader == null)
            {
                return;
            }

            if (!Monitor.TryEnter(book_lock))
            {
                return;
            }

            bookmarks.Clear();
            bookmarks ["all bookmarks"] = new List <Item> ();
            try {
                while (reader.Read())
                {
                    if (reader.Name == "post")
                    {
                        BookmarkItem bookmark = new BookmarkItem(
                            reader.GetAttribute("description"), reader.GetAttribute("href"));
                        bookmarks ["all bookmarks"].Add(bookmark);
                        string [] itemTags;
                        itemTags = reader.GetAttribute("tag").Split(' ');
                        foreach (string tag in itemTags)
                        {
                            string t = tag.ToLower();
                            if (string.IsNullOrEmpty(tag))
                            {
                                t = "untagged";
                            }
                            if (!bookmarks.ContainsKey(tag))
                            {
                                bookmarks [t] = new List <Item> ();
                            }
                            bookmarks [t].Add(bookmark);
                        }
                    }
                }
            } catch (NullReferenceException e) {
                Console.Error.WriteLine(e.Message);
            }
            finally {
                Monitor.Exit(book_lock);
            }
        }
        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            var    bookmark = new BookmarkItem();
            string title    = ((HtmlDocument)webBrowser1.Document).Title;

            bookmark.Title = title;
            bookmark.URL   = toolStripTextBox1.Text;
            var AlreadyExists = BookmarkManager.GetItems();

            if (!AlreadyExists.Contains(bookmark))
            {
                BookmarkManager.AddItem(bookmark);
            }
        }