Exemplo n.º 1
0
Arquivo: Delete.cs Projeto: 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));
        }
Exemplo n.º 2
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);
     }
 }
Exemplo n.º 3
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));
        }