Esempio n. 1
0
 private void FileSelected(string filePath)
 {
     FileBookmarks.Clear();
     FilePath = filePath;
     ExtLib.Bookmarks.GetBookmarks(filePath).ForEach(x => FileBookmarks.Add(x));
     PageNumber = ExtLib.Bookmarks.GetLastPage(filePath);
 }
Esempio n. 2
0
 private void DeSelectChildrenRecursively(IBookmark mark)
 {
     foreach (IBookmark child in FileBookmarks.Where(x => x.ParentId == mark.Id))
     {
         child.IsSelected = false;
         DeSelectChildrenRecursively(child);
     }
 }
Esempio n. 3
0
        private void BookmarkAdded(IBookmark mark)
        {
            List <IBookmark> originalList = FileBookmarks.ToList();

            List <IBookmark> parents =
                originalList.FindAll(x => x.StartPage <= mark.StartPage && x.EndPage > mark.EndPage);

            if (parents.Count > 0)
            {
                IBookmark parent = parents.First(x => x.Level == parents.Max(x => x.Level));
                mark.Level    = parent.Level + 1;
                mark.ParentId = parent.Id;

                List <IBookmark> siblings = originalList.FindAll(x => x.ParentId == parent.Id);
                if (siblings.Count < 1)
                {
                    FileBookmarks.Insert(FileBookmarks.IndexOf(FileBookmarks.First(x => x.Id == parent.Id)) + 1, mark);
                }
                else
                {
                    IBookmark closestSibling = siblings.FirstOrDefault(x => x.StartPage > mark.StartPage);
                    if (closestSibling == null)
                    {
                        FileBookmarks.Insert(FileBookmarks.IndexOf(FileBookmarks.Last(x => x.ParentId == parent.Id)) + 1, mark);
                    }
                    else
                    {
                        FileBookmarks.Insert(FileBookmarks.IndexOf(FileBookmarks.First(x => x.Id == closestSibling.Id)) - 1, mark);
                    }
                }
            }
            else
            {
                mark.ParentId = Guid.Empty;
                mark.Level    = 1;
                IBookmark next = FileBookmarks.FirstOrDefault(x => x.Level == 0 && x.StartPage > mark.StartPage);
                if (next == null)
                {
                    FileBookmarks.Add(mark);
                }
                else
                {
                    FileBookmarks.Insert(FileBookmarks.IndexOf(next) - 1, mark);
                }
            }
        }
Esempio n. 4
0
        void ExecuteImportBookmarksCommand()
        {
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Title            = "Valitse kirjanmerkkitiedosto";
            openFile.Filter           = "Tekstitiedosto |*.txt";
            openFile.InitialDirectory = Path.GetDirectoryName(FilePath);

            if (openFile.ShowDialog() != true)
            {
                return;
            }

            List <IBookmark> imported = ExtLib.Bookmarks.ImportBookmarks(openFile.FileName, PageNumber);

            FileBookmarks.Clear();
            foreach (IBookmark import in imported)
            {
                FileBookmarks.Add(import);
            }
        }
Esempio n. 5
0
 void ExecuteDeleteCommand()
 {
     FileBookmarks.RemoveAll(x => x.IsSelected);
 }