Example #1
0
 // Create a new tree node for a section node and all of its descendants
 private TreeNode CreateTreeNodeForSectionNode(ObiNode node)
 {
     if (InvokeRequired)
     {
         return((TreeNode)Invoke(new NodeInvokation(CreateTreeNodeForSectionNode), node));
     }
     else
     {
         TreeNode n = AddSingleSectionNode(node);
         if (n != null)
         {
             n.EnsureVisible();
             n.ExpandAll();
             ChangeColorUsed(n, mProjectView.ColorSettings);
             if (mProjectView.ObiForm.Settings != null && mProjectView.ObiForm.Settings.Project_BackgroundColorForEmptySection &&
                 node is SectionNode && node.Duration == 0) // @emptysectioncolor
             {
                 EmptySectionBackColor(node, n);
             }
         }
         //if (n != null || node is RootNode)
         if (n != null || node == mProjectView.Presentation.RootNode)//sdk2
         {
             for (int i = 0; i < node.SectionChildCount; ++i)
             {
                 CreateTreeNodeForSectionNode(node.SectionChild(i));
             }
         }
         return(n);
     }
 }
Example #2
0
        /// <summary>
        /// This function displays the find in text form.
        /// </summary>
        //public void StartNewSearch(ContentView strips)
        public void StartNewSearch(TOCView tocView, ContentView contentView, FindViews view)
        {
            m_ContentView    = contentView;
            m_TocView        = tocView;
            m_ViewToSearchIn = view;

            mProjectView.FindInTextVisible = true;
            mFoundFirst     = false;
            mNumberSearched = 0;
            mProjectView.ObiForm.UpdateFindInTextMenuItems();
            mString.SelectAll();
            mString.Focus();
            mProjectView.ObiForm.Status(Localizer.Message("find_in_text_init"));

            if (view == FindViews.ContentView)
            {
                m_SectionActiveInContentView = null;
                if (mProjectView.GetSelectedPhraseSection != null)
                {
                    m_SectionActiveInContentView = mProjectView.GetSelectedPhraseSection;
                }
                if (m_SectionActiveInContentView == null && m_ContentView.ActiveStrip != null)
                {
                    m_SectionActiveInContentView = m_ContentView.ActiveStrip.Node;
                }
            }
            else
            {
                m_SectionsList = ((ObiRootNode)mProjectView.Presentation.RootNode).GetListOfAllSections(); //@singleSection: done at last to allow find control open without delay
            }
            m_FindStartNode = null;                                                                        //@singleSection
        }
Example #3
0
 // Convenience method to add a new tree node for a section. Return the added tree node.
 private TreeNode AddSingleSectionNode(ObiNode node)
 {
     if (InvokeRequired)
     {
         return((TreeNode)Invoke(new NodeInvokation(AddSingleSectionNode), node));
     }
     else
     {
         TreeNode n = null;
         if (node is SectionNode && node.IsRooted)
         {
             if (node.ParentAs <SectionNode>() != null)
             {
                 TreeNode p = FindTreeNode(node.ParentAs <SectionNode>());
                 n = p.Nodes.Insert(node.Index, node.GetHashCode().ToString(), ((SectionNode)node).Label);
             }
             else
             {
                 n = Nodes.Insert(node.Index, node.GetHashCode().ToString(), ((SectionNode)node).Label);
             }
             n.Tag = node;
             ChangeColorUsed(n, mProjectView.ColorSettings);
         }
         return(n);
     }
 }
Example #4
0
        private int mIndex;        // index of the node that we actually want to delete

        public DeleteWithOffset(ProjectView.ProjectView view, ObiNode node, int offset)
            : base(view)
        {
            mNode    = node;
            mParent  = node.ParentAs <ObiNode>();
            mDeleted = null;
            mIndex   = mParent.Children.IndexOf(mNode) + offset;
        }
Example #5
0
 /// <summary>
 /// Add an existing node to a parent node at the given index.
 /// </summary>
 public AddNode(ProjectView.ProjectView view, ObiNode node, ObiNode parent, int index) : base(view, "")
 {
     mNode      = node;
     mParent    = parent;
     mIndex     = index;
     mSelection = view.Selection != null && view.Selection.Control is ProjectView.ContentView ?
                  new NodeSelection(mNode, view.Selection.Control) : view.Selection;
 }
Example #6
0
        // Fill in the fields of the view when the form is loaded.
        private void SectionProperties_Load(object sender, EventArgs e)
        {
            m_txtName.Text     = mNode.Label;
            m_txtName.ReadOnly = mView.ObiForm.Settings.Project_ReadOnlyMode;
            int maxLevel = mNode.PrecedingSection == null ? 1 : mNode.PrecedingSection.Level + 1;

            for (int i = 1; i <= maxLevel; ++i)
            {
                m_comboLevel.Items.Add(i);
            }
            m_comboLevel.SelectedIndex = mNode.Level - 1;
            if (mNode.Level == 1)
            {
                m_lbParentsList.Items.Insert(0, Localizer.Message("top_level_section"));
            }
            else
            {
                for (SectionNode parent = mNode.ParentAs <SectionNode>(); parent != null; parent = parent.ParentAs <SectionNode>())
                {
                    m_lbParentsList.Items.Insert(0, string.Format(Localizer.Message("section_level"),
                                                                  parent.Label, parent.Level));
                }
            }
            m_comboLevel.Enabled  = !mView.ObiForm.Settings.Project_ReadOnlyMode;
            m_txtTimeLength.Text  = Program.FormatDuration_Long(mNode.Duration);
            m_txtPhraseCount.Text = mNode.PhraseChildCount.ToString();
            m_chkUsed.Checked     = mNode.Used;
            for (ObiNode n = mNode.FirstLeaf; n != null && n.FollowingNode != null; n = n.FollowingNode)
            {
                if (n is EmptyNode && ((EmptyNode)n).Role_ == EmptyNode.Role.Page)
                {
                    if (m_txtPagesInSection.Text.Trim() == string.Empty)
                    {
                        m_txtPagesInSection.Text += "#" + ((EmptyNode)n).PageNumber.ToString();
                    }
                    else
                    {
                        m_txtPagesInSection.Text += ", #" + ((EmptyNode)n).PageNumber.ToString();
                    }
                }
                if (n.Parent != n.FollowingNode.Parent)
                {
                    break;
                }
            }

            if (mView != null && mView.Selection != null && mView.Selection.Node is SectionNode)
            {
                SectionNode secNode = (SectionNode)mView.Selection.Node;
                if (secNode != null && secNode.PrecedingNode != null && secNode.PrecedingSection is SectionNode)
                {
                    CalculateSectionTime((SectionNode)secNode.PrecedingSection);
                }
            }
            m_txtSectionTimePosition.Text = Program.FormatDuration_Long(m_TotalSectionTime);
        }
Example #7
0
        /// <summary>
        /// Select and start renaming a section node.
        /// </summary>
        public void SelectAndRename(ObiNode node)
        {
            SectionNode section = (SectionNode)node;

            DoToNewNode(section, delegate()
            {
                mProjectView.Selection = new TextSelection(section, this, section.Label);
                FindTreeNode(section).BeginEdit();
            });
        }
Example #8
0
File: Delete.cs Project: daisy/obi
        // Determine what the selection will be after deletion
        private NodeSelection GetPostDeleteSelection(bool IsAutoPageGenerationInvoked)
        {
            ObiNode node = null;

            if (mNode is SectionNode)
            {
                if (View.Selection.Control is ProjectView.ContentView)
                {
                    // Select the next strip; if there is no next strip, select the previous one.
                    node = ((SectionNode)mNode).FollowingSection;
                    if (node == null)
                    {
                        node = ((SectionNode)mNode).PrecedingSection;
                    }
                }
                else
                {
                    // TODO: review this.
                    ObiNode parent = mNode.ParentAs <ObiNode>();
                    int     index  = mNode.Index;
                    node = index < parent.SectionChildCount - 1 ?
                           (ObiNode)parent.SectionChild(index + 1) :
                           index > 0 ? (ObiNode)parent.SectionChild(index - 1) :
                           parent == View.Presentation.RootNode ? null : parent;
                }
            }
            else
            {
                SectionNode parent = mNode.ParentAs <SectionNode>();
                int         index  = mNode.Index;
                // Select the next sibling;
                // if last child, select the previous sibling;
                // if first child, select the parent.
                node = index < parent.PhraseChildCount - 1 ?
                       (ObiNode)parent.PhraseChild(index + 1) :
                       index > 0 ? (ObiNode)parent.PhraseChild(index - 1) :
                       (ObiNode)parent;
                if (IsAutoPageGenerationInvoked && node != null && node is EmptyNode)
                {
                    while (node.Parent == parent && (!(node is PhraseNode) || (node is PhraseNode && ((node as PhraseNode).Role_ == PhraseNode.Role.Page)) && node is EmptyNode))
                    {
                        if (node.PrecedingNode != null)
                        {
                            node = node.PrecedingNode;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            return(node == null ? null : new NodeSelection(node, View.Selection.Control));
        }
Example #9
0
 // Set parent and index for the new node
 protected virtual void SetParentAndIndex(ProjectView.ProjectView view)
 {
     if (view.Selection == null)
     {
         mParent = (ObiNode)view.Presentation.RootNode;
         mIndex  = mParent.SectionChildCount;
     }
     else
     {
         mParent = view.Selection.ParentForNewNode(mNode);
         mIndex  = view.Selection.IndexForNewNode(mNode);
     }
 }
Example #10
0
 public Delete(ProjectView.ProjectView view, ObiNode node, ObiNode parent, int index, bool update) : base(view)
 {
     mNode   = node;
     mParent = parent;
     mIndex  = index;
     if (view.Selection != null && view.Selection.Node == node)
     {
         mAfter = GetPostDeleteSelection();
     }
     else
     {
         mAfter = view.Selection;
     }
 }
Example #11
0
        private int GetSectionDepth(SectionNode section)
        {
            int     depth  = 1;
            ObiNode parent = section.ParentAs <ObiNode> ();

            while (parent != mView.Presentation.RootNode)
            {
                section = (SectionNode)parent;
                parent  = section.ParentAs <ObiNode>();
                depth++;
            }
            //Console.WriteLine("section depth: " + depth);
            return(depth);
        }
Example #12
0
File: Delete.cs Project: daisy/obi
 public Delete(ProjectView.ProjectView view, ObiNode node, ObiNode parent, int index, bool update, bool IsAutoPageGenerationInvoked = false)
     : base(view)
 {
     mNode   = node;
     mParent = parent;
     mIndex  = index;
     if (view.Selection != null && view.Selection.Node == node)
     {
         mAfter = GetPostDeleteSelection(IsAutoPageGenerationInvoked);
     }
     else
     {
         mAfter = view.Selection;
     }
 }
        private void CreateStructure(List <int> levelsList, List <string> sectionNamesList, List <int> pagesPerSection)
        {
            List <ObiNode> listOfSectionNodes = new List <ObiNode>();

            listOfSectionNodes.Add((ObiNode)m_Presentation.RootNode);
            int         pageNumber     = 0;
            SectionNode currentSection = null;

            Console.WriteLine("level list  count" + levelsList.Count);
            for (int i = 0; i < levelsList.Count; i++)
            {
                SectionNode section = m_Presentation.CreateSectionNode();
                section.Label = sectionNamesList[i].Trim();
                Console.WriteLine("section " + section.Label + ", level: " + levelsList[i]);
                if (currentSection == null)
                {
                    m_Presentation.RootNode.AppendChild(section);
                }
                else
                {
                    // iterate back in list of sections to find the parent
                    for (int j = listOfSectionNodes.Count - 1; j >= 0; j--)
                    {
                        ObiNode iterationSection = listOfSectionNodes[j];
                        if (iterationSection.Level < levelsList[i])
                        {
                            iterationSection.AppendChild(section);
                            break;
                        }
                    }
                }
                currentSection = section;
                listOfSectionNodes.Add(section);
                if (pagesPerSection[i] > 0)
                {
                    for (int j = 0; j < pagesPerSection[i]; j++)
                    {
                        EmptyNode pageNode = m_Presentation.TreeNodeFactory.Create <EmptyNode>();
                        ++pageNumber;
                        pageNode.PageNumber = new PageNumber(pageNumber, PageKind.Normal);
                        section.AppendChild(pageNode);
                        Console.WriteLine("page : " + pageNode.PageNumber.ToString());
                    }
                }
            }
        }
Example #14
0
 public static void AssignRoleToEmptyNodeSurroundedByCustomRoles(ObiNode roleNode)
 {
     if (roleNode is EmptyNode && ((EmptyNode)roleNode).Role_ == EmptyNode.Role.Plain)
     {
         ObiNode preceeding = roleNode.PrecedingNode;
         ObiNode following  = roleNode.FollowingNode;
         if (preceeding != null && following != null &&
             preceeding is EmptyNode && following is EmptyNode &&
             ((EmptyNode)preceeding).Role_ == EmptyNode.Role.Custom &&
             ((EmptyNode)preceeding).Role_ == ((EmptyNode)following).Role_ &&
             ((EmptyNode)preceeding).CustomRole == ((EmptyNode)following).CustomRole)
         {
             EmptyNode currentNode = (EmptyNode)roleNode;
             currentNode.SetRole(((EmptyNode)preceeding).Role_, ((EmptyNode)preceeding).CustomRole);
         }
     }
 }
Example #15
0
 public void EmptySectionBackColor(ObiNode node, TreeNode treeNodeToSelect) // @emptysectioncolor
 {
     if (node == null || treeNodeToSelect == null)
     {
         return;
     }
     if (mProjectView.ObiForm.Settings.Project_BackgroundColorForEmptySection && node.Duration == 0.0)
     {
         {
             if (!SystemInformation.HighContrast)
             {
                 treeNodeToSelect.BackColor = mProjectView.ObiForm.Settings.ColorSettings.EmptySectionBackgroundColor;
             }
             else
             {
                 treeNodeToSelect.BackColor = mProjectView.ObiForm.Settings.ColorSettingsHC.EmptySectionBackgroundColor;
             }
             treeNodeToSelect.ForeColor = SystemColors.ControlText;
         }
     }
 }
Example #16
0
        private bool mDeleteSelectedBlock;  // flag to require deletion of the previous block

        /// <summary>
        /// Paste a node.
        /// </summary>
        public Paste(ProjectView.ProjectView view)
            : base(view)
        {
            mCopy   = (ObiNode)view.Clipboard.Node.Copy(view.Clipboard.Deep, true);
            mParent = view.Selection.ParentForNewNode(mCopy);
            mIndex  = view.Selection.IndexForNewNode(mCopy);
            // If we paste a phrase node "into" an emtpy node, the empty node must be deleted
            // and its attributes are oved to the pasted node.
            if (mCopy is PhraseNode && view.Selection.Node.GetType() == typeof(EmptyNode))
            {
                mDeleteSelectedBlock = true;
                ((PhraseNode)mCopy).CopyAttributes((EmptyNode)view.Selection.Node);
                mCopy.Used = view.Selection.Node.Used;
            }
            else
            {
                mDeleteSelectedBlock = false;
            }
            mSelection = new NodeSelection(mCopy.LastDescendant, view.Selection.Control);
            SetDescriptions(Localizer.Message(mCopy is EmptyNode ? "paste_phrase" : "paste_section"));
        }
Example #17
0
        // Determine what the selection will be after deletion
        private NodeSelection GetPostDeleteSelection()
        {
            ObiNode node = null;

            if (mNode is SectionNode)
            {
                if (View.Selection.Control is ProjectView.ContentView)
                {
                    // Select the next strip; if there is no next strip, select the previous one.
                    node = ((SectionNode)mNode).FollowingSection;
                    if (node == null)
                    {
                        node = ((SectionNode)mNode).PrecedingSection;
                    }
                }
                else
                {
                    // TODO: review this.
                    ObiNode parent = mNode.ParentAs <ObiNode>();
                    int     index  = mNode.Index;
                    node = index < parent.SectionChildCount - 1 ?
                           (ObiNode)parent.SectionChild(index + 1) :
                           index > 0 ? (ObiNode)parent.SectionChild(index - 1) :
                           parent == View.Presentation.RootNode ? null : parent;
                }
            }
            else
            {
                SectionNode parent = mNode.ParentAs <SectionNode>();
                int         index  = mNode.Index;
                // Select the next sibling;
                // if last child, select the previous sibling;
                // if first child, select the parent.
                node = index < parent.PhraseChildCount - 1 ?
                       (ObiNode)parent.PhraseChild(index + 1) :
                       index > 0 ? (ObiNode)parent.PhraseChild(index - 1) :
                       (ObiNode)parent;
            }
            return(node == null ? null : new NodeSelection(node, View.Selection.Control));
        }
Example #18
0
 private void ParseTOC(XmlNode xNode, ObiNode parentNode)
 {
     if (xNode.Name == "li")
     {
         SectionNode section = m_Presentation.CreateSectionNode();
         parentNode.AppendChild(section);
         parentNode = section;
     }
     else if (xNode is XmlText)
     {
         if (parentNode is SectionNode)
         {
             SectionNode parentSection = (SectionNode)parentNode;
             parentSection.Label = xNode.InnerText;
         }
     }
     else if (xNode.Name == "a")
     {
         if (parentNode is SectionNode)
         {
             XmlNode hrefNode         = xNode.Attributes.GetNamedItem("href");
             string  headingReference = hrefNode.Value;
             if (!m_XmlIdToSectionNodeMap.ContainsKey(headingReference))
             {
                 m_XmlIdToSectionNodeMap.Add(headingReference, (SectionNode)parentNode);
             }
         }
     }
     if (xNode.ChildNodes.Count == 0)
     {
         return;
     }
     foreach (XmlNode n in xNode.ChildNodes)
     {
         ParseTOC(n, parentNode);
     }
 }
Example #19
0
        private string GetPagesInSection(int i)
        {
            string PagesInSection = String.Empty;

            for (ObiNode n = m_SectionList[i].FirstLeaf; n != null && n.FollowingNode != null; n = n.FollowingNode)
            {
                if (n is EmptyNode && ((EmptyNode)n).Role_ == EmptyNode.Role.Page)
                {
                    if (PagesInSection.Trim() == string.Empty)
                    {
                        PagesInSection += " " + Localizer.Message("Pages") + " # " + ((EmptyNode)n).PageNumber.ToString();
                    }
                    else
                    {
                        PagesInSection += ", # " + ((EmptyNode)n).PageNumber.ToString();
                    }
                }
                if (n.Parent != n.FollowingNode.Parent)
                {
                    break;
                }
            }
            return(PagesInSection);
        }
Example #20
0
 /// <summary>
 /// Create a delete node command with no label.
 /// </summary>
 public Delete(ProjectView.ProjectView view, ObiNode node) : this(view, node, "")
 {
 }
Example #21
0
 public AddEmptyNode(ProjectView.ProjectView view, ObiNode node, ObiNode parent, int index)
     : base(view, node, parent, index)
 {
     mControl = view.Selection.Control;
     SetDescriptions(Localizer.Message("add_blank_phrase"));
 }
Example #22
0
        protected override TreeNode CreateTreeNodeForAudioNode(TreeNode navPointTreeNode, bool isHeadingNode, XmlNode smilNode, string fullSmilPath)
        {
            PhraseNode audioWrapperNode = m_Presentation.CreatePhraseNode();

            if (smilNode == null || !m_SmilXmlNodeToTreeNodeMap.ContainsKey(smilNode))
            {
                ((SectionNode)navPointTreeNode).AppendChild(audioWrapperNode);

                XmlNode seqParent = smilNode != null ? smilNode.ParentNode : null;
                while (seqParent != null)
                {
                    if ((seqParent.Name == "seq" || seqParent.Name == "par") && (seqParent.Attributes != null && seqParent.Attributes.GetNamedItem("customTest") != null))
                    {
                        break;
                    }
                    seqParent = seqParent.ParentNode;
                }

                string strClass = null;

                if (seqParent != null && seqParent.Attributes.GetNamedItem("class") != null &&
                    (strClass = seqParent.Attributes.GetNamedItem("class").Value) != null &&
                    (strClass == EmptyNode.Annotation || strClass == EmptyNode.EndNote || strClass == EmptyNode.Footnote ||
                     strClass == EmptyNode.ProducerNote || strClass == EmptyNode.Sidebar || strClass == EmptyNode.Note))
                {
                    audioWrapperNode.SetRole(EmptyNode.Role.Custom, strClass);
                    if (!m_Skippable_IdMap.ContainsKey(audioWrapperNode))
                    {
                        ObiNode preceedingNode = audioWrapperNode.PrecedingNode;
                        if (preceedingNode == null || preceedingNode is SectionNode || ((EmptyNode)preceedingNode).CustomRole != audioWrapperNode.CustomRole)
                        {
                            m_Skippable_IdMap.Add(audioWrapperNode, new List <string>());
                            XmlNode seqChild = seqParent;
                            while (seqChild != null && seqChild != smilNode)
                            {
                                if (seqChild.Attributes.GetNamedItem("id") != null)
                                {
                                    m_Skippable_IdMap[audioWrapperNode].Add(Path.GetFileName(fullSmilPath) + "#" + seqChild.Attributes.GetNamedItem("id").Value);
                                }
                                seqChild = seqChild.FirstChild;
                            }


                            AssignSkippableToAnchorNode();
                        }
                    }
                }
                else if (seqParent != null && seqParent.Attributes != null && seqParent.Attributes.GetNamedItem("customTest") != null)
                {
                    XmlNode anchorNode = XmlDocumentHelper.GetFirstChildElementOrSelfWithName(seqParent, true, "a", seqParent.NamespaceURI);
                    if (anchorNode != null)
                    {
                        string strReference = anchorNode.Attributes.GetNamedItem("href").Value;
                        audioWrapperNode.SetRole(EmptyNode.Role.Anchor, null);
                        if (!m_AnchorNodeSmilRefMap.ContainsKey(audioWrapperNode))
                        {
                            string[] refArray = strReference.Split('#');
                            if (refArray.Length == 1 || string.IsNullOrEmpty(refArray[0]))
                            {
                                strReference = Path.GetFileName(fullSmilPath) + "#" + refArray[refArray.Length - 1];
                            }
                            m_AnchorNodeSmilRefMap.Add(audioWrapperNode, strReference);
                        }
                    }
                }
            }
            else
            {
                ((SectionNode)navPointTreeNode).InsertAfter(audioWrapperNode, m_SmilXmlNodeToTreeNodeMap[smilNode]);
                m_SmilXmlNodeToTreeNodeMap[smilNode] = audioWrapperNode;
            }

            return(audioWrapperNode);
        }
Example #23
0
 public SetPageNumber(PageNumber number, bool renumber, bool canSetNumberOfPages, ObiNode selectedNode, Settings settings)
     : this(number, renumber, canSetNumberOfPages, settings) //@fontconfig
 {
     m_SelectedNode = selectedNode;
 }
Example #24
0
        private void m_chkAutoFillPages_CheckedChanged(object sender, EventArgs e)
        {
            if (m_SelectedNode != null)
            {
                EmptyNode startingPage = null;
                EmptyNode lastPage     = null;
                // find previous page node
                ObiNode nodeSelected = m_SelectedNode;
                if (m_SelectedNode is SectionNode && ((SectionNode)m_SelectedNode).PhraseChildCount > 0)
                {
                    nodeSelected = ((SectionNode)m_SelectedNode).PhraseChild(((SectionNode)m_SelectedNode).PhraseChildCount - 1);
                }
                for (ObiNode n = nodeSelected;
                     n != null;
                     n = n.PrecedingNode)
                {
                    if (n is EmptyNode && ((EmptyNode)n).Role_ == EmptyNode.Role.Page)
                    {
                        startingPage = (EmptyNode)n;
                        break;
                    }
                }

                // Find the next page node
                for (ObiNode n = nodeSelected.FollowingNode;
                     n != null;
                     n = n.FollowingNode)
                {
                    if (n is EmptyNode && ((EmptyNode)n).Role_ == EmptyNode.Role.Page)
                    {
                        lastPage = (EmptyNode)n;
                        break;
                    }
                }

                if (startingPage == null)
                {
                    if (m_chkAutoFillPages.Checked)
                    {
                        MessageBox.Show(Localizer.Message("SetPageNumber_PrecedingPageNotFound"), Localizer.Message("Caption_Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        m_chkAutoFillPages.Checked = false;
                    }
                    return;
                }
                if (lastPage == null)
                {
                    if (m_chkAutoFillPages.Checked)
                    {
                        MessageBox.Show(Localizer.Message("SetPageNumber_NextPageNotFound"), Localizer.Message("Caption_Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        m_chkAutoFillPages.Checked = false;
                    }
                    return;
                }

                if (startingPage.PageNumber.Number >= lastPage.PageNumber.Number ||
                    startingPage.PageNumber.Kind != lastPage.PageNumber.Kind)
                {
                    if (m_chkAutoFillPages.Checked)
                    {
                        MessageBox.Show(Localizer.Message("SetPageNumber_PageOutOfOrder"), Localizer.Message("Caption_Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        m_chkAutoFillPages.Checked = false;
                    }
                    return;
                }

                if (startingPage.PageNumber.Number == lastPage.PageNumber.Number - 1)
                {
                    if (m_chkAutoFillPages.Checked)
                    {
                        MessageBox.Show(Localizer.Message("SetPageNumber_PageInConsecutiveOrder"), Localizer.Message("Caption_Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        m_chkAutoFillPages.Checked = false;
                    }
                    return;
                }
                // fill in the page count
                int pageCount = lastPage.PageNumber.Number - startingPage.PageNumber.Number - 1;
                mNumberOfPagesBox.Text = pageCount.ToString();
                if (m_chkAutoFillPages.Checked)
                {
                    mRenumber.Checked = false;
                }
            }
        }
Example #25
0
        /// <summary>
        /// Create the phrase detection command.
        /// </summary>
        public static CompositeCommand GetPhraseDetectionCommand(ProjectView.ProjectView view, ObiNode node,
                                                                 long threshold, double gap, double before, bool mergeFirstTwoPhrases, ObiPresentation presentation = null)
        {
            List <PhraseNode> phraseNodesList = new List <PhraseNode> ();

            if (node is PhraseNode)
            {
                phraseNodesList.Add((PhraseNode)node);
            }
            else if (node is SectionNode)
            {
                SectionNode section = (SectionNode)node;
                for (int i = 0; i < section.PhraseChildCount; i++)
                {
                    if (section.PhraseChild(i) is PhraseNode && ((PhraseNode)section.PhraseChild(i)).Role_ != EmptyNode.Role.Silence)
                    {
                        phraseNodesList.Add((PhraseNode)section.PhraseChild(i));
                    }
                }
            }
            List <List <PhraseNode> > phrasesToMerge = new List <List <PhraseNode> >();
            CompositeCommand          command        = null;

            if (view.Presentation == null && presentation != null)
            {
                command = presentation.CreateCompositeCommand(Localizer.Message("phrase_detection"));
            }
            else
            {
                command = view.Presentation.CreateCompositeCommand(Localizer.Message("phrase_detection"));
            }

            // if phrase is selected but phrase detection node is section,select section
            if (node is SectionNode && view.GetSelectedPhraseSection != null &&
                view.GetSelectedPhraseSection == node)
            {
                command.ChildCommands.Insert(command.ChildCommands.Count, new UpdateSelection(view, new NodeSelection(node, view.Selection.Control)));
            }

            ObiNode parent = node is SectionNode ? node : node.ParentAs <ObiNode> ();
            int     index  = 0;

            if (phraseNodesList.Count > 0)
            {
                view.TriggerProgressChangedEvent(Localizer.Message("phrase_detection"), 0);
            }
            for (int j = 0; j < phraseNodesList.Count; j++)
            {
                PhraseNode phrase = phraseNodesList[j];

                if (j == 0)
                {
                    index = phrase.Index + 1;
                }
                System.Collections.Generic.List <PhraseNode> phrases = null;
                if (view.Presentation == null && presentation != null)
                {
                    phrases = presentation.CreatePhraseNodesFromAudioAssetList(
                        Obi.Audio.PhraseDetection.Apply(phrase.Audio.Copy(), threshold, gap, before));
                }
                else
                {
                    phrases = view.Presentation.CreatePhraseNodesFromAudioAssetList(
                        Obi.Audio.PhraseDetection.Apply(phrase.Audio.Copy(), threshold, gap, before));
                }
                for (int i = 0; i < phrases.Count; ++i)
                {
                    // Copy page/heading role for the first phrase only
                    if (i == 0 || (phrase.Role_ != EmptyNode.Role.Page && phrase.Role_ != EmptyNode.Role.Heading))
                    {
                        phrases[i].CopyAttributes(phrase);
                    }
                    phrases[i].Used = phrase.Used;
                    phrases[i].TODO = phrase.TODO;
                    if (i == 0 && phrase.TODO && (phrase as EmptyNode).CommentText != null)
                    {
                        (phrases[i] as EmptyNode).CommentText = (phrase as EmptyNode).CommentText;
                    }
                    if (phrases[i].Role_ == EmptyNode.Role.Heading && i > 0)
                    {
                        phrases[i].Role_ = EmptyNode.Role.Plain;
                    }

                    // in following add node constructor, update selection is made false, to improve performance (19 may, 2010)
                    command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.AddNode(view, phrases[i], parent, index, false));
                    index++;
                }
                // add first 2 phrases to the list if the merge flag is true
                if (phrases.Count >= 2 && mergeFirstTwoPhrases &&
                    phrases[0] is PhraseNode && phrases [1] is PhraseNode)
                {
                    List <PhraseNode> mergeList = new List <PhraseNode>();
                    mergeList.Add(phrases[0]);
                    mergeList.Add(phrases[1]);
                    phrasesToMerge.Add(mergeList);
                }

                if (node is PhraseNode && phrases.Count > 0 && view.Selection != null)
                {
                    //command.append ( new UpdateSelection ( view, new NodeSelection ( node, view.Selection.Control ) ) );
                    command.ChildCommands.Insert(command.ChildCommands.Count, new UpdateSelection(view, new NodeSelection(phrases[0], view.Selection.Control)));    //uncommenting this because unexecute for update selection can handle null unexecute now
                }
                Commands.Node.Delete deleteCmd = new Commands.Node.Delete(view, phrase, false);
                command.ChildCommands.Insert(command.ChildCommands.Count, deleteCmd);//@singleSection: moved delete command last for improve undo selection

                if (Obi.Audio.PhraseDetection.CancelOperation)
                {
                    break;
                }
                // skip to next indexes if the two consequtive phrases in phrase list are not consequitive according to phrase index in the parent section
                if (j < phraseNodesList.Count - 1 &&
                    phrase.Index + 1 < phraseNodesList[j + 1].Index)
                {
                    EmptyNode empty = null;
                    for (int i = phrase.Index + 1; i < phraseNodesList[j + 1].Index; ++i)
                    {
                        empty = phrase.ParentAs <SectionNode>().PhraseChild(i);
                        command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.Delete(view, empty, false));
                        command.ChildCommands.Insert(command.ChildCommands.Count, new Commands.Node.AddNode(view, empty, parent, index, false));
                        index++;
                    }
                    //index = index + (phraseNodesList[j + 1].Index - (phrase.Index + 1));
                }
                view.TriggerProgressChangedEvent(Localizer.Message("phrase_detection"), (100 * j) / phraseNodesList.Count);
            }
            if (phrasesToMerge.Count > 0)
            {
                for (int i = 0; i < phrasesToMerge.Count; i++)
                {
                    List <PhraseNode>        mergeList = phrasesToMerge[i];
                    Commands.Node.MergeAudio mergeCmd  = new MergeAudio(view, mergeList[0], mergeList[1]);
                    mergeCmd.UpdateSelection = false;
                    command.ChildCommands.Insert(command.ChildCommands.Count, mergeCmd);
                }
            }
            return(command);
        }
Example #26
0
 public ObiNodeEventArgs(ObiNode node)
 {
     mNode = node;
 }
Example #27
0
        private bool mOriginalStatus;  // original used status of the node

        /// <summary>
        /// Change the used status of a single node.
        /// </summary>
        public ToggleNodeUsed(ProjectView.ProjectView view, ObiNode node)
            : base(view)
        {
            mNode           = node;
            mOriginalStatus = node.Used;
        }
Example #28
0
 public AddNode(ProjectView.ProjectView view, ObiNode node, ObiNode parent, int index, bool update)
     : this(view, node, parent, index)
 {
     UpdateSelection = update;
 }
Example #29
0
 /// <summary>
 /// Add an existing node to its parent at its index.
 /// </summary>
 public AddNode(ProjectView.ProjectView view, ObiNode node)
     : this(view, node, node.ParentAs <ObiNode>(), node.Index)
 {
 }
Example #30
0
 /// <summary>
 /// Create a delete node command with no label and update selection flag (normally to be set to false.)
 /// </summary>
 public Delete(ProjectView.ProjectView view, ObiNode node, bool update)
     : this(view, node, "")
 {
     UpdateSelection = update;
 }