Exemple #1
0
        private void coverToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MyNode     node = treeView1.SelectedNode.Tag as MyNode;
            NavDetails nav  = node.Tag as NavDetails;

            OpfDocument doc = new OpfDocument();

            doc.AddCoverRef(nav.File);
        }
Exemple #2
0
 private void AddToTextSelected(NavDetails nav)
 {
     if (!TextSelected.ContainsKey(nav.ContentSrc))
     {
         TextSelected.Add(nav.ContentSrc, nav.Text);
     }
     else
     {
         TextSelected[nav.ContentSrc] = nav.Text;
     }
 }
Exemple #3
0
        void nodeDetectedTexts_ChangesApplied(object sender, EventArgs e)
        {
            MyNode     n   = treeView1.CurrentNode.Tag as MyNode;
            NavDetails nav = n.Tag as NavDetails;

            if (nav.DetectedTexts != null && nav.DetectedTexts.Count > 0)
            {
                nav.Text = nodeDetectedTexts.GetValue(treeView1.CurrentNode).ToString();
                AddToTextSelected(nav);
            }
        }
Exemple #4
0
        void nodeDetectedTexts_EditorShowing(object sender, CancelEventArgs e)
        {
            nodeDetectedTexts.DropDownItems.Clear();
            MyNode     n   = treeView1.CurrentNode.Tag as MyNode;
            NavDetails nav = n.Tag as NavDetails;

            if (nav.DetectedTexts != null && nav.DetectedTexts.Count > 0)
            {
                nodeDetectedTexts.DropDownItems.AddRange(nav.DetectedTexts.ToArray());
            }
        }
Exemple #5
0
        private void SaveInfoIntoNode(XElement item, Node childNode)
        {
            XAttribute attr   = item.Element(ns + "content").Attribute("src");
            string     src    = attr == null ? "deleteME" : attr.Value;
            XAttribute attrid = item.Attribute("id");
            string     id     = attrid == null ? "deleteME" : attrid.Value;

            NavDetails det = new NavDetails(id, src);

            childNode.Tag = det;
        }
Exemple #6
0
        private void ChooseTextInDropDown(SelectDirection dir, bool Incremental)
        {
            using (new HourGlass())
            {
                treeView1.BeginUpdate();
                int Increment = 1;
                foreach (var item in treeView1.SelectedNodes)
                {
                    MyNode     n    = item.Tag as MyNode;
                    NavDetails nav  = n.Tag as NavDetails;
                    int        Base = Incremental ? n.OriginalCount - 1 : 0;
                    if (nav.DetectedTexts == null)
                    {
                        continue;
                    }

                    int QtyMax = n.DetectedCombo.Count - 1;
                    int index  = nav.DetectedTexts.IndexOf(n.DetectedText);
                    if (nav.DetectedTexts.Count > 1)
                    {
                        if (index >= 0 && dir == SelectDirection.Next)
                        {
                            int NewIndex = Incremental ? index + Increment + Base : index + Increment;
                            if (NewIndex > QtyMax)
                            {
                                NewIndex = QtyMax;
                            }

                            nav.Text       = nav.DetectedTexts[NewIndex];
                            n.DetectedText = nav.DetectedTexts[NewIndex];
                        }
                        else
                        {
                            if (index > 0 && index <= QtyMax)
                            {
                                nav.Text       = nav.DetectedTexts[index - Increment];
                                n.DetectedText = nav.DetectedTexts[index - Increment];
                            }
                        }


                        if (Incremental)
                        {
                            Increment++;
                        }
                    }
                    AddToTextSelected(nav);
                }
                treeView1.EndUpdate();
            }
        }
Exemple #7
0
        private void SelectFilesToAdd(System.Collections.ObjectModel.Collection <Node> node)
        {
            foreach (var item in node)
            {
                if (item.IsChecked)
                {
                    NavDetails nav = item.Tag as NavDetails;
                    AddPresentFiles(nav.ContentSrc);

                    FilesToAdd.Add(nav);
                }
                SelectFilesToAdd(item.Nodes);
            }
        }
Exemple #8
0
        private XElement ConvertToXElement(NavDetails item)
        {
            playOrder++;

            XElement el =
            new XElement(ns + "navPoint",
            new XAttribute("id", item.navPointid),
            new XAttribute("playOrder", playOrder),
            new XElement(ns + "navLabel",
            new XElement(ns + "text", item.Text)),
            new XElement(ns + "content",
            new XAttribute("src", (item.ContentSrc))));

            return el;
        }
Exemple #9
0
        private void tree_DragOver(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(TreeNodeAdv[])) && tree.DropPosition.Node != null)
            {
                TreeNodeAdv[] nodes  = e.Data.GetData(typeof(TreeNodeAdv[])) as TreeNodeAdv[];
                TreeNodeAdv   parent = tree.DropPosition.Node;
                if (tree.DropPosition.Position != NodePosition.Inside)
                {
                    parent = parent.Parent;
                }

                foreach (TreeNodeAdv node in nodes)
                {
                    if (node.Tag.GetType() == typeof(MyNode))
                    {
                        if (this.Name == "frmTocEdit")
                        {
                            MyNode item = node.Tag as MyNode;
                            item.Nodes.Clear();
                            NavDetails nav = item.Tag as NavDetails;
                            string     str = String.IsNullOrEmpty(nav.Text) ? nav.ContentSrc : nav.Text;
                            item.Text      = str;
                            item.IsChecked = true;
                        }
                        else
                        {
                            Node       item = node.Tag as Node;
                            NavDetails nav  = item.Tag as NavDetails;
                            item.Text      = Utils.GetId(nav.ContentSrc);
                            item.IsChecked = true;
                        }
                    }

                    if (!CheckNodeParent(parent, node))
                    {
                        e.Effect = DragDropEffects.None;
                        return;
                    }
                }

                e.Effect = e.AllowedEffect;
            }
        }
Exemple #10
0
        private void ShiftChapter(ArrowDirection direction)
        {
            List <string> CleanedFileName = GetFilenames(Model.Nodes, false);

            for (int i = tree.SelectedNodes.Count - 1; i >= 0; i--)
            {
                Node       n   = tree.SelectedNodes[i].Tag as Node;
                NavDetails nav = n.Tag as NavDetails;

                //TODO+ Use an index selecting technique instead of matching source (what if there is duplicate?)
                int index = CleanedFileName.IndexOf(nav.ContentSrc);

                List <string> Backup         = new List <string>();
                int           newSourceIndex = 0;
                switch (direction)
                {
                //In shift Down the First Item is ignored
                //And the 2 First selected item will be the same
                case ArrowDirection.Down:
                    if (index > 0)
                    {
                        newSourceIndex = index - 1;
                        nav.ShiftChapter(CleanedFileName, newSourceIndex);
                    }
                    break;

                //In shift Up the Last Item is ignored
                //And the 2 last selected item will be the same
                case ArrowDirection.Up:
                    if (index < CleanedFileName.Count - 1)
                    {
                        newSourceIndex = index + 1;
                        nav.ShiftChapter(CleanedFileName, newSourceIndex);
                    }
                    break;

                default:
                    break;
                }
            }
        }
Exemple #11
0
        public static System.Collections.ObjectModel.Collection <Node> RemoveNonExistantNode(System.Collections.ObjectModel.Collection <Node> NodeCollection)
        {
            OpfDocument   opfDoc    = new OpfDocument();
            List <string> htmlFiles = opfDoc.GetFilesList("html");

            for (int i = NodeCollection.Count - 1; i >= 0; i--)
            {
                Node       item = NodeCollection[i];
                NavDetails nav  = item.Tag as NavDetails;

                if (nav.ContentSrc == null || !Utils.VerifyFileExists(nav.File) | !htmlFiles.Contains(nav.File))
                {
                    NodeCollection.Remove(item);
                }

                if (item.Nodes.Count > 0)
                {
                    RemoveNonExistantNode(item.Nodes);
                }
            }

            return(NodeCollection);
        }
Exemple #12
0
        void DuplicateToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            foreach (var item in tree.SelectedNodes)
            {
                Node       n     = item.Tag as Node;
                NavDetails nav   = n.Tag as NavDetails;
                int        index = n.Index + tree.SelectedNodes.Count - 1;

                Node newNode = new Node(n.Text);
                newNode.IsChecked = true;
                NavDetails Newnav = new NavDetails(Guid.NewGuid().ToString(), nav.ContentSrc);
                newNode.Tag = Newnav;

                if (index < n.Parent.Nodes.Count)
                {
                    n.Parent.Nodes.Insert(index + 1, newNode);
                }
                else
                {
                    n.Parent.Nodes.Add(newNode);
                }
            }
        }
Exemple #13
0
        private void node_DrawText(object sender, Aga.Controls.Tree.NodeControls.DrawEventArgs e)
        {
            NavDetails nav = ((e.Node.Tag as MyNode).Tag as NavDetails);

            if (nav != null)
            {
                string anch = "";
                if (PresentAnchors.TryGetValue(nav.ContentSrc, out anch))
                {
                    Font f = new System.Drawing.Font(e.Font, FontStyle.Bold);
                    e.TextColor = Color.DarkGreen;
                    e.Font      = f;
                }

                //Keep expanded status
                bool expand = false;
                IsNodeExpanded.TryGetValue(nav.File, out expand);
                if (expand)
                {
                    SaveExpand = false;
                    e.Node.Expand();
                    SaveExpand = true;
                }
                else
                {
                    e.Node.Collapse();
                }

                //Keep SelectedText
                string text = "";
                if (TextSelected.TryGetValue(nav.ContentSrc, out text))
                {
                    ((MyNode)e.Node.Tag).DetectedText = text;
                }
            }
        }
        void DuplicateToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            foreach (var item in tree.SelectedNodes)
            {
                Node n = item.Tag as Node;
                NavDetails nav = n.Tag as NavDetails;
                int index = n.Index + tree.SelectedNodes.Count - 1;

                Node newNode = new Node(n.Text);
                newNode.IsChecked = true;
                NavDetails Newnav = new NavDetails(Guid.NewGuid().ToString(), nav.ContentSrc);
                newNode.Tag = Newnav;

                if (index < n.Parent.Nodes.Count)
                {
                    n.Parent.Nodes.Insert(index + 1, newNode);
                } else
                {
                    n.Parent.Nodes.Add(newNode);
                }
            }
        }
Exemple #15
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();
            }
        }
 private void AddToTextSelected(NavDetails nav)
 {
     if (!TextSelected.ContainsKey(nav.ContentSrc))
     {
         TextSelected.Add(nav.ContentSrc, nav.Text);
     } else
     {
         TextSelected[nav.ContentSrc] = nav.Text;
     }
 }
        private void SaveInfoIntoNode(XElement item, Node childNode)
        {
            XAttribute attr = item.Element(ns + "content").Attribute("src");
            string src = attr == null ? "deleteME" : attr.Value;
            XAttribute attrid = item.Attribute("id");
            string id = attrid == null ? "deleteME" : attrid.Value;

            NavDetails det = new NavDetails(id, src);

            childNode.Tag = det;
        }
 private void SaveInfoIntoNode(string idRef, Node childNode)
 {
     NavDetails det = new NavDetails(idRef, Utils.GetSrc(idRef));
     childNode.Tag = det;
 }
Exemple #19
0
        private void SaveInfoIntoNode(string idRef, Node childNode)
        {
            NavDetails det = new NavDetails(idRef, Utils.GetSrc(idRef));

            childNode.Tag = det;
        }