Exemple #1
0
        private void SetFilesBasedOnAnchors(string file)
        {
            if (AddType == AddWindowType.TOCEdit)
            {
                MyHtmlDocument doc     = new MyHtmlDocument();
                List <string>  Anchors = doc.FindAnchorsInFile(file);

                foreach (var anch in Anchors)
                {
                    string str = file + '#' + anch;

                    if (!PresentAnchors.ContainsKey(str) && PresentFileList.Contains(file))
                    {
                        PresentFileList.Remove(file);
                    }
                }
            }
        }
Exemple #2
0
        private void LoadFiles()
        {
            try
            {
                using (new HourGlass())
                {
                    treeView1.BeginUpdate();

                    if (Model != null && Model.Nodes.Count > 0)
                    {
                        Model.Nodes.Clear();
                    }

                    OpfDocument   OpfDoc       = new OpfDocument();
                    List <string> htmlFileLIst = OpfDoc.GetFilesList("html");
                    List <string> t            = htmlFileLIst;
                    if (!cbShowAll.Checked)
                    {
                        t = (from i in htmlFileLIst
                             where !PresentFileList.Contains(i)
                             select i).ToList();
                    }

                    MyHtmlDocument htmlDoc = new MyHtmlDocument();
                    Dictionary <string, DetectedHeaders> DetectText = htmlDoc.FindHeaderTextInFile(t);

                    foreach (string item in t)
                    {
                        DetectedHeaders det = new DetectedHeaders();
                        DetectText.TryGetValue(item, out det);
                        List <string> text = det != null ? det.Result : null;
                        MyNode        n    = new MyNode(item, text);
                        n.OriginalCount = det != null ? det.OriginalCount : 0;
                        Model.Nodes.Add(n);
                    }

                    SortList();

                    Dictionary <string, string> SrcTag = OpfDoc.GetFilesList();
                    foreach (MyNode item in Model.Nodes)
                    {
                        item.Tag = new NavDetails(Utils.GetId(item.Text, SrcTag), item.Text, item.DetectedCombo);
                        NavDetails nav = item.Tag as NavDetails;

                        if (AddType == AddWindowType.TOCEdit && cbShowAnchors.Checked)
                        {
                            List <string> Anchors = htmlDoc.FindAnchorsInFile(item.Text);

                            if (!cbShowAll.Checked)
                            {
                                Anchors = (from i in Anchors
                                           where !PresentAnchors.ContainsKey(nav.File + "#" + i)
                                           select i).ToList();
                            }

                            Dictionary <string, DetectedHeaders> DetectAnchorText = htmlDoc.FindAchorTextInFile(item.Text, Anchors);
                            item.AddAnchors(Anchors, DetectAnchorText);
                        }
                    }

                    RemoveEmptyNodes();
                    treeView1.EndUpdate();

                    //Utils.RemoveNonExistantNode(Model.Nodes);
                }
            } catch (Exception)
            {
                treeView1.EndUpdate();
            }
        }