Exemplo n.º 1
0
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //create bookmarks
            Bookmarks bookmarks = new Bookmarks();
            Bookmark childBookmark1 = new Bookmark();
            childBookmark1.PageNumber = 1;
            childBookmark1.Title = "First Child";
            Bookmark childBookmark2 = new Bookmark();
            childBookmark2.PageNumber = 2;
            childBookmark2.Title = "Second Child";

            bookmarks.Add(childBookmark1);
            bookmarks.Add(childBookmark2);

            Bookmark bookmark = new Bookmark();
            bookmark.Action = "GoTo";
            bookmark.PageNumber = 1;
            bookmark.Title = "Parent";

            bookmark.ChildItems = bookmarks;

            //create PdfBookmarkEditor class
            PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();
            //bind PDF document
            bookmarkEditor.BindPdf(dataDir+ "input.pdf");
            //create bookmarks
            bookmarkEditor.CreateBookmarks(bookmark);
            //save updated document
            bookmarkEditor.Save(dataDir+ "output.pdf");
        }
        private void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            if (NameText == null)
            {
                return;
            }
            var bookmark = new BookmarkNode
            {
                IsFolder = false,
                Name     = NameText,
                URL      = AppCore.CurrentURL,
                Children = new ObservableCollection <BookmarkNode>()
            };
            var parent = Tree.SelectedItem;

            if (parent == null)
            {
                Bookmarks.Add(bookmark);
            }
            else
            {
                ((BookmarkNode)parent).Children.Add(bookmark);
            }
            WriteBookmarks();
        }
Exemplo n.º 3
0
        protected Guid InternalGetBookmark()
        {
            Guid result = Guid.NewGuid();

            _bookmarks.Add(result, _sourceTable.GetBookmark());
            return(result);
        }
Exemplo n.º 4
0
        public BookmarksViewModel()
        {
            _storage = new BookmarksStorage();

            foreach (var bookmark in _storage.Bookmarks)
            {
                var viewModel = new BookmarkViewModel(bookmark);

                viewModel.Deleting += OnBookmarkDeleting;
                viewModel.Editing  += OnBookmarkEditing;

                Bookmarks.Add(viewModel);
            }

            AddBookmarkCommand = new RelayCommand(arg => {
                var bookmarkViewModel = (BookmarkViewModel)arg;

                bookmarkViewModel.Deleting += OnBookmarkDeleting;
                bookmarkViewModel.Editing  += OnBookmarkEditing;

                _storage.Add(bookmarkViewModel.Bookmark);

                Bookmarks.Add(bookmarkViewModel);
            });
        }
Exemplo n.º 5
0
        public void CopyBookmark(string sourcePath, string targetPath)
        {
            if (sourcePath.Equals(targetPath, StringComparison.InvariantCulture))
            {
                return;
            }

            BookmarkNode sourceBookmark;

            if (!Bookmarks.TryGetValue(sourcePath, out sourceBookmark))
            {
                return;
            }

            RegisterPath(targetPath);

            string       value    = sourceBookmark.Value;
            string       fullPath = string.IsNullOrEmpty(targetPath) ? value : string.Format(CultureInfo.InvariantCulture, "{0}/{1}", targetPath, value);
            BookmarkNode bookmark = new BookmarkNode();

            bookmark.Path  = fullPath;
            bookmark.Value = sourceBookmark.Value;
            bookmark.Text  = sourceBookmark.Text;

            Bookmarks.Add(fullPath, bookmark);

            OnItemAdded(new BookmarkItemChangeEventArgs(fullPath, bookmark));
        }
 /// <summary>
 ///     Creates a new instance of <see cref="BookmarkManagerMemento" />
 /// </summary>
 public BookmarkManagerMemento(XmlElement element)
 {
     foreach (XmlElement el in element.ChildNodes)
     {
         Bookmarks.Add(int.Parse(el.Attributes["line"].InnerText));
     }
 }
Exemplo n.º 7
0
        private void Bookmark()
        {
            if (SelectedCity != null)
            {
                bool removed = false;
                foreach (Bookmark b in Bookmarks)
                {
                    if (b.City.id == SelectedCity.id)
                    {
                        Bookmarks.Remove(b);
                        OnPropertyChanged("Bookmarks");
                        removed = true;
                        CheckBookmarkIcon();
                        break;
                    }
                }

                if (!removed)
                {
                    Bookmarks.Add(new Bookmark(SelectedCity));
                    CheckBookmarkIcon();
                    OnPropertyChanged("Bookmarks");
                }
            }
        }
Exemplo n.º 8
0
 private void AddBookmark()
 {
     if (Bookmarks == null)
     {
         Bookmarks = new ObservableCollection <Bookmark>();
     }
     Bookmarks.Add(new Bookmark(InFolder));
     OnPropertyChanged("Bookmarks");
     MessageBox.Show("New Bookmark at path = " + Path);
 }
Exemplo n.º 9
0
 internal void AddBookmark(ulong address, ClrType clrType)
 {
     if (dicoBookmarks != null && !dicoBookmarks.ContainsKey(address))
     {
         var bookmark = new Bookmark(address, clrType.Name);
         dicoBookmarks[address] = bookmark;
         Bookmarks.Add(bookmark);
         Save();
     }
 }
Exemplo n.º 10
0
        private async Task LoadBookmarkList()
        {
            Bookmarks.Clear();
            var lastPage = SettingsUtils.Get <int>(Constants.PREF_LAST_PAGE);

            if (lastPage > 0)
            {
                var lastPageItem = new ItemViewModel();
                lastPageItem.Title   = QuranUtils.GetSurahNameFromPage(lastPage, true);
                lastPageItem.Details = string.Format("{0} {1}, {2} {3}", Resources.quran_page, lastPage,
                                                     QuranUtils.GetJuzTitle(),
                                                     QuranUtils.GetJuzFromPage(lastPage));
                lastPageItem.PageNumber = lastPage;
                lastPageItem.Image      = new BitmapImage(new Uri("ms-appx:///Assets/Images/favorite.png"));
                lastPageItem.ItemType   = ItemViewModelType.Bookmark;
                lastPageItem.Group      = Resources.bookmarks_current_page;
                lastPageItem.Id         = lastPageItem.Group;
                Bookmarks.Add(lastPageItem);
            }

            using (var bookmarksAdapter = new BookmarksDatabaseHandler())
            {
                try
                {
                    var bookmarks = bookmarksAdapter.GetBookmarks(true, BoomarkSortOrder.Location);
                    if (bookmarks.Count > 0)
                    {
                        //Load untagged first
                        foreach (var bookmark in bookmarks)
                        {
                            if (bookmark.Tags == null)
                            {
                                Bookmarks.Add(await CreateBookmarkModel(bookmark));
                            }
                        }

                        //Load tagged
                        foreach (var bookmark in bookmarks)
                        {
                            if (bookmark.Tags != null)
                            {
                                Bookmarks.Add(await CreateBookmarkModel(bookmark));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    telemetry.TrackException(ex, new Dictionary <string, string> {
                        { "Scenario", "LoadingBookmarks" }
                    });
                    QuranApp.NativeProvider.Log("failed to load bookmarks: " + ex.Message);
                }
            }
        }
Exemplo n.º 11
0
        public void AddBookmark(string id, int bookmarkStyleIndex)
        {
            if (Bookmarks.ContainsKey(id))
            {
                Bookmarks.Remove(id);
            }

            Bookmarks.Add(id, bookmarkStyleIndex);

            NotifyOfPropertyChange("BookmarksAvailable");
        }
Exemplo n.º 12
0
        private void LoadBookmarks(Book selectedBook)
        {
            _dbService.LoadBookmarks(selectedBook);

            // update filterable collection view source
            Bookmarks.Clear();
            foreach (var bookmark in selectedBook.Bookmarks)
            {
                Bookmarks.Add(bookmark);
            }
        }
Exemplo n.º 13
0
        private void LoadBookmarks(Book selectedBook)
        {
            _dbService.LoadBookmarks(selectedBook);

            // update filterable collection view source
            Bookmarks.Clear();
            foreach (var bookmark in selectedBook.Bookmarks)
            {
                Bookmarks.Add(bookmark);
            }
            _logger.Info($"{selectedBook.Title}: Loaded {selectedBook.Bookmarks.Count} bookmarks");
        }
Exemplo n.º 14
0
        public AddBookmarkStatus AddBookmark(Bookmark bookmark)
        {
            if (!IsBookmarked(bookmark.SeriesUri))
            {
                Bookmarks.Add(bookmark);

                return(AddBookmarkStatus.Success);
            }
            else
            {
                return(AddBookmarkStatus.Duplicate);
            }
        }
    public TemplateDocumentIssuingIndividualPaymentOrder(string wordSaveAs, string firstName, string lastName, string jik, string price, string Date, bool alsoCreatePdf, string pdfSaveDocumentAsFullPath)
        : base()
    {
        //napravljen je prazan template dokument objekat
        //ovde sada treba da se definisu podaci kao sto su putanja dokumenta, na osnovu kog template-a je napravljen, lista bukmarka
        FullName          = wordSaveAs;
        Template.FullName = pdfSaveDocumentAsFullPath;

        Bookmarks.Add(new Bookmark(@"Payer", firstName + " " + lastName));
        Bookmarks.Add(new Bookmark(@"Date", Date));
        Bookmarks.Add(new Bookmark(@"RequestNo", jik));
        Bookmarks.Add(new Bookmark(@"Price", price));
        Bookmarks.Add(new Bookmark(@"RequestNo1", jik));
    }
Exemplo n.º 16
0
        public async Task ApplyFilters()
        {
            Bookmarks.Clear();
            var filtered = _bookmarksSource
                           .Where(FilterByLastActive)
                           .Where(FilterByName);

            foreach (var b in filtered)
            {
                await Task.Delay(10).ConfigureAwait(false);

                Bookmarks.Add(b);
            }
        }
Exemplo n.º 17
0
        public static void Main()
        {
            // The path to the documents directory.
            string dataDir = Path.GetFullPath("../../../Data/");
            //create bookmarks
            Bookmarks bookmarks      = new Bookmarks();
            Bookmark  childBookmark1 = new Bookmark();

            childBookmark1.PageNumber = 1;
            childBookmark1.Title      = "First Child";
            Bookmark childBookmark2 = new Bookmark();

            childBookmark2.PageNumber = 2;
            childBookmark2.Title      = "Second Child";

            bookmarks.Add(childBookmark1);
            bookmarks.Add(childBookmark2);

            Bookmark bookmark = new Bookmark();

            bookmark.Action     = "GoTo";
            bookmark.PageNumber = 1;
            bookmark.Title      = "Parent";

            bookmark.ChildItems = bookmarks;

            //create PdfBookmarkEditor class
            PdfBookmarkEditor bookmarkEditor = new PdfBookmarkEditor();

            //bind PDF document
            bookmarkEditor.BindPdf(dataDir + "input.pdf");
            //create bookmarks
            bookmarkEditor.CreateBookmarks(bookmark);
            //save updated document
            bookmarkEditor.Save(dataDir + "output.pdf");
        }
Exemplo n.º 18
0
        public void AddTaggedBookmark(int tagId, int pageIndex, string path)
        {
            RegisterPath(path);

            string       value    = string.Format(CultureInfo.InvariantCulture, "tag:{0}:{1}", tagId, pageIndex);
            string       fullPath = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", path, value);
            BookmarkNode bookmark = new BookmarkNode();

            bookmark.Path  = fullPath;
            bookmark.Value = value;
            bookmark.Text  = BookmarkFormatter.GetTaggedSearchText(tagId, pageIndex);

            Bookmarks.Add(fullPath, bookmark);

            OnItemAdded(new BookmarkItemChangeEventArgs(fullPath, bookmark));
        }
Exemplo n.º 19
0
        public void AddQueryBookmark(string query, int pageIndex, string path)
        {
            RegisterPath(path);

            string       value    = string.Format(CultureInfo.InvariantCulture, "search:{0}:{1}", query, pageIndex);
            string       fullPath = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", path, value);
            BookmarkNode bookmark = new BookmarkNode();

            bookmark.Path  = fullPath;
            bookmark.Value = value;
            bookmark.Text  = BookmarkFormatter.GetQuerySearchText(query, pageIndex);

            Bookmarks.Add(fullPath, bookmark);

            OnItemAdded(new BookmarkItemChangeEventArgs(fullPath, bookmark));
        }
Exemplo n.º 20
0
        public void AddLibraryBookmark(int pageIndex, string path)
        {
            RegisterPath(path);

            string       value    = string.Format(CultureInfo.InvariantCulture, "library:{0}", pageIndex);
            string       fullPath = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", path, value);
            BookmarkNode bookmark = new BookmarkNode();

            bookmark.Path  = fullPath;
            bookmark.Value = value;
            bookmark.Text  = BookmarkFormatter.GetLibraryText(pageIndex);

            Bookmarks.Add(fullPath, bookmark);

            OnItemAdded(new BookmarkItemChangeEventArgs(fullPath, bookmark));
        }
Exemplo n.º 21
0
        private async void CreateNewFolder()
        {
            var dialog = new TextInputDialog(LocalizationHelper.Localize("Folder name"));
            var result = await dialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                var bookmark = new BookmarkNode
                {
                    IsFolder = true,
                    Name     = dialog.Text,
                    Children = new ObservableCollection <BookmarkNode>()
                };
                Bookmarks.Add(bookmark);
                WriteBookmarks();
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Builds bookmark object.
        /// </summary>
        public void Build()
        {
            if (_mainComponent.PDFiumBridge == null || !_mainComponent.PDFiumDocument.IsValid)
            {
                return;
            }

            var childBookmarkHandle = _mainComponent.PDFiumBridge.FPDFBookmark_GetFirstChild(_mainComponent.PDFiumDocument, _bookmarkHandle);

            while (childBookmarkHandle.IsValid)
            {
                var newBookmark = new PDFBookmark(_mainComponent, childBookmarkHandle);
                newBookmark.Build();
                Bookmarks.Add(newBookmark);
                childBookmarkHandle = _mainComponent.PDFiumBridge.FPDFBookmark_GetNextSibling(_mainComponent.PDFiumDocument, childBookmarkHandle);
            }
        }
Exemplo n.º 23
0
        public BookmarksStorage()
        {
            if (!File.Exists(Path))
            {
                return;
            }

            var content = File.ReadAllText(Path);

            var bookmarks = JsonConvert.DeserializeObject <Bookmark[]>(content)
                            ?? new Bookmark[0];

            foreach (var bookmark in bookmarks)
            {
                Bookmarks.Add(bookmark);
            }
        }
Exemplo n.º 24
0
        public async Task BookmarksSearch(string filter)
        {
            IsBusy = true;
            IEnumerable <Bookmark> bookmarks = await bookmarkService.Search(filter);

            while (Bookmarks.Any())
            {
                Bookmarks.RemoveAt(Bookmarks.Count - 1);
            }

            foreach (Bookmark f in bookmarks)
            {
                Bookmarks.Add(f);
            }
            IsBusy = false;
            OnPropertyChanged("SelectedMenuItem");
            OnPropertyChanged("Bookmarks");
        }
Exemplo n.º 25
0
    public TemplateDocumentIssuingIndividual(string wordSaveAs, string firstName, string lastName, string jmbg, string jik, string email, string street, string streetNo, string postNo, string place, string phone, bool alsoCreatePdf, string pdfSaveDocumentAsFullPath)
        : base()
    {
        //napravljen je prazan template dokument objekat
        //ovde sada treba da se definisu podaci kao sto su putanja dokumenta, na osnovu kog template-a je napravljen, lista bukmarka
        FullName          = wordSaveAs;
        Template.FullName = pdfSaveDocumentAsFullPath;

        Bookmarks.Add(new Bookmark(@"FirstName", firstName));
        Bookmarks.Add(new Bookmark(@"LastName", lastName));
        Bookmarks.Add(new Bookmark(@"Jmbg", jmbg));
        Bookmarks.Add(new Bookmark(@"Jik", jik));
        Bookmarks.Add(new Bookmark(@"Email", email));
        Bookmarks.Add(new Bookmark(@"Street", street));
        Bookmarks.Add(new Bookmark(@"StreetNo", streetNo));
        Bookmarks.Add(new Bookmark(@"PostNo", postNo));
        Bookmarks.Add(new Bookmark(@"Place", place));
        Bookmarks.Add(new Bookmark(@"Phone", phone));
    }
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        public void DocumentOpened(string file)
        {
            if (_mainComponent.PDFiumBridge == null || !_mainComponent.PDFiumDocument.IsValid)
            {
                return;
            }

            var bookmarkHandle = _mainComponent.PDFiumBridge.FPDFBookmark_GetFirstChild(_mainComponent.PDFiumDocument, FPDF_BOOKMARK.InvalidHandle);

            while (bookmarkHandle.IsValid)
            {
                var newBookmark = new PDFBookmark(_mainComponent, bookmarkHandle);
                newBookmark.Build();
                Bookmarks.Add(newBookmark);
                bookmarkHandle = _mainComponent.PDFiumBridge.FPDFBookmark_GetNextSibling(_mainComponent.PDFiumDocument, bookmarkHandle);
            }

            InvokePropertyChangedEvent(nameof(Bookmarks));
        }
        private async Task Populate(bool global)
        {
            List <Bookmark> bookmarks = new List <Bookmark>();
            BookmarkRepo    repo      = new BookmarkRepo();

            if (global)
            {
                await Task.Run(() =>
                {
                    // 3. Populate global bookmarks
                    foreach (Bookmark bookmark in (new BookmarkRepo()).LoadGlobalBookmarks())
                    {
                        //bookmark.PopulateArticles(User);
                        bookmark.GetArticleCount(User);
                        bookmarks.Add(bookmark);
                    }
                });

                foreach (Bookmark bookmark in bookmarks)
                {
                    GlobalBookmarks.Add(bookmark);
                }
            }
            else
            {
                await Task.Run(() =>
                {
                    // 2. Populate local bookmarks
                    foreach (Bookmark bookmark in repo.LoadBookmarks(User))
                    {
                        // Populate articles colletion for each bookmark
                        //bookmark.PopulateArticles(User);
                        bookmark.GetArticleCount(User);
                        bookmarks.Add(bookmark);
                    }
                });

                foreach (Bookmark bookmark in bookmarks)
                {
                    Bookmarks.Add(bookmark);
                }
            }
        }
Exemplo n.º 28
0
        public void Insert(ref string word, Bookmark bookmark)
        {
            if (word.Length < 2)
            {
                Bookmarks.Add(bookmark);
                return;
            }
            word = word.Substring(1);

            foreach (TrieNode n in Children)
            {
                if (n.Match(word))
                {
                    n.Insert(ref word, bookmark);
                    return;
                }
            }

            Children.Add(new TrieNode(this, ref word, bookmark));
        }
Exemplo n.º 29
0
        public void AddBookmark(int line, int key)
        {
            // Если уже есть на текущей линнии с таким же ключлм, то удаляем совсем и выходим
            if (Bookmarks.RemoveAll(b => b.Line == line && b.Key == key) > 0)
            {
            }
            else
            {
                // Если уже есть на текущей линни, удалим его
                Bookmarks.RemoveAll(b => b.Line == line);

                // Удалим все с текущим ключом
                Bookmarks.RemoveAll(b => b.Key == key);

                Bookmark bookmark = new Bookmark(this, line, key, "");
                Bookmarks.Add(bookmark);
            }

            IsChanged = true;
            OnBookmarksChanged();
        }
Exemplo n.º 30
0
        public void AddDownloadBookmark(Metadata metadata, string path)
        {
            if (metadata == null)
            {
                throw new ArgumentNullException("metadata");
            }

            RegisterPath(path);

            string       value    = string.Format(CultureInfo.InvariantCulture, "download:{0}", metadata.Id);
            string       fullPath = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", path, value);
            BookmarkNode bookmark = new BookmarkNode();

            bookmark.Path  = fullPath;
            bookmark.Value = value;
            bookmark.Text  = BookmarkFormatter.GetDownloadText(metadata);

            Bookmarks.Add(fullPath, bookmark);

            OnItemAdded(new BookmarkItemChangeEventArgs(fullPath, bookmark));
        }
Exemplo n.º 31
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            PropertyDescriptor property = context.DataContext.GetProperties()[WordCreate.GetWordAppTag];
            Application        wordApp  = property.GetValue(context.DataContext) as Application;

            try
            {
                string linkName = LinkName.Get(context);
                string linkMark = LinkMark.Get(context);
                string linkAddr = LinkAddr.Get(context);
                string bookMark = BookMark.Get(context);
                string pic      = Pic.Get(context);

                if (linkName != null)
                {
                    Hyperlinks links = wordApp.Selection.Hyperlinks;
                    links.Add(wordApp.Selection.Range, linkAddr, linkMark, "", linkName, linkMark);
                }
                if (bookMark != null)
                {
                    Bookmarks bookmarks = wordApp.Selection.Bookmarks;
                    bookmarks.Add(bookMark);
                }
                if (pic != null)
                {
                    InlineShapes lineshapes = wordApp.Selection.InlineShapes;
                    InlineShape  lineshape  = lineshapes.AddPicture(pic);
                }
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "Word执行过程出错", e.Message);
                CommonVariable.realaseProcessExit(wordApp);
            }

            m_Delegate = new runDelegate(Run);
            return(m_Delegate.BeginInvoke(callback, state));
        }
Exemplo n.º 32
0
 private static Bookmarks CreateBookmarks(string bookmarkDescription, string url, string keyword) {
     var bookmarks = new Bookmarks();
     if (!string.IsNullOrEmpty(bookmarkDescription)) bookmarks.Add(new Bookmark(bookmarkDescription, url, icon));
     if (!string.IsNullOrEmpty(keyword)) bookmarks.Add(new Bookmark(keyword, url, icon));
     return bookmarks;
 }