示例#1
0
        /// <summary>
        /// The <see cref="Control.Click"/> event handler for the
        /// <see cref="Button"/> <see cref="btnLevelDown"/>.
        /// Move the selected nodes one level down if possible.
        /// Create a new parent node to add the selection, if there
        /// is no child node to move the selected nodes to.
        /// </summary>
        /// <param name="sender">Source of the event.</param>
        /// <param name="e">An empty <see cref="EventArgs"/></param>
        private void btnLevelDown_Click(object sender, EventArgs e)
        {
            NodesCollection nodes = this.trvSlideshow.SelectedNodes;

            nodes.Sort();
            if (nodes.Count > 0)
            {
                TreeNode firstNode = nodes[0];

                // Skip if the node is the root node or at level 1
                if (firstNode.Parent == null || firstNode.Parent.Parent == null)
                {
                    return;
                }

                int insertionIndex = firstNode.Index;

                TreeNode newParent = firstNode.Parent.Parent;
                for (int i = nodes.Count - 1; i >= 0; i--)
                {
                    TreeNode collectionNode = nodes[i];
                    collectionNode.Remove();
                    newParent.Nodes.Insert(insertionIndex, collectionNode);
                }
            }

            this.UpdateListView(this.trvSlideshow.SelectedNodes);
            this.SlideShowModified();
        }
示例#2
0
        /// <summary>
        /// This method moves the given nodes on level up.
        /// They can be marked as a trial using the second parameter.
        /// </summary>
        /// <param name="nodes">A <see cref="NodesCollection"/> with the <see cref="TreeView"/> nodes.</param>
        /// <param name="markAsTrial"><strong>True</strong> if the nodes in the collection
        /// are referred to be one trial in the presentation.</param>
        private void MoveNodesLevelUp(NodesCollection nodes, bool markAsTrial)
        {
            nodes.Sort();
            if (nodes.Count > 0)
            {
                TreeNode firstNode = nodes[0];

                // Skip if the node is the root node
                if (firstNode.Parent == null)
                {
                    return;
                }

                int insertionIndex = firstNode.Index;

                string            parentNodeName = this.slideshow.GetUnusedNodeID();
                SlideshowTreeNode newParent      = new SlideshowTreeNode(parentNodeName);
                newParent.Name = parentNodeName;
                if (markAsTrial)
                {
                    newParent.Tag = "Trial";
                }

                newParent.SetTreeNodeImageKey(newParent);

                firstNode.Parent.Nodes.Insert(insertionIndex, newParent);
                foreach (TreeNode collectionNode in nodes)
                {
                    collectionNode.Remove();
                    newParent.Nodes.Add(collectionNode);
                }
            }

            this.UpdateListView(this.trvSlideshow.SelectedNodes);
            this.SlideShowModified();
        }
示例#3
0
    /// <summary>
    /// This method moves the given nodes on level up.
    /// They can be marked as a trial using the second parameter.
    /// </summary>
    /// <param name="nodes">A <see cref="NodesCollection"/> with the <see cref="TreeView"/> nodes.</param>
    /// <param name="markAsTrial"><strong>True</strong> if the nodes in the collection
    /// are referred to be one trial in the presentation.</param>
    private void MoveNodesLevelUp(NodesCollection nodes, bool markAsTrial)
    {
      nodes.Sort();
      if (nodes.Count > 0)
      {
        TreeNode firstNode = nodes[0];

        // Skip if the node is the root node
        if (firstNode.Parent == null)
        {
          return;
        }

        int insertionIndex = firstNode.Index;

        string parentNodeName = this.slideshow.GetUnusedNodeID();
        SlideshowTreeNode newParent = new SlideshowTreeNode(parentNodeName);
        newParent.Name = parentNodeName;
        if (markAsTrial)
        {
          newParent.Tag = "Trial";
        }

        newParent.SetTreeNodeImageKey(newParent);

        firstNode.Parent.Nodes.Insert(insertionIndex, newParent);
        foreach (TreeNode collectionNode in nodes)
        {
          collectionNode.Remove();
          newParent.Nodes.Add(collectionNode);
        }
      }

      this.UpdateListView(this.trvSlideshow.SelectedNodes);
      this.SlideShowModified();
    }