示例#1
0
 public TreeMergedEventArgs(URDFTreeView mergedTree, bool success, TreeMerger merger, string csvFilename)
 {
     MergedTree             = mergedTree;
     Success                = success;
     UsedCSVInertial        = merger.UseCSVInertial;
     UsedCSVVisualCollision = merger.UseCSVVisualCollision;
     UsedCSVJointKinematics = merger.UseCSVJointKinematics;
     UsedCSVJointOther      = merger.UseCSVJointOther;
     CSVFilename            = csvFilename;
 }
示例#2
0
        private void TreeViewDrop(object sender, DragEventArgs e)
        {
            URDFTreeView tree    = (URDFTreeView)sender;
            TreeViewItem package = e.Data.GetData(typeof(TreeViewItem)) as TreeViewItem;

            if (!IsValidDrop(tree, package, e))
            {
                return;
            }

            if (e.Source.GetType() == typeof(TreeViewItem))
            {
                // Dropping onto a Tree node
                ProcessDragDropOnItem(tree, (TreeViewItem)e.Source, package);
            }
            else if (e.Source.GetType() == typeof(TreeView))
            {
                // Dropping outside of a node will reorder nodes
                ProcessDragDropOnTree(tree, package, e);
            }
        }
        /// <summary>
        /// When reordering elements, we want to check which one is to the side of the point we drop it at.
        /// We'll put the new one just below it.
        /// </summary>
        /// <param name="items"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        private TreeViewItem GetItemToSideOfPoint(URDFTreeView tree, DragEventArgs e)
        {
            List <TreeViewItem> flattened = tree.Flatten();

            TreeViewItem previous = null;

            foreach (TreeViewItem item in flattened)
            {
                Point pointOnElement = e.GetPosition(item);
                if (pointOnElement.Y < 0)
                {
                    // We went passed it, return the previous one
                    return(previous);
                }

                if (IsPointToSideOfElement(item, pointOnElement))
                {
                    return(item);
                }

                previous = item;
            }
            return(null);
        }
示例#4
0
        /// <summary>
        /// If they don't drop the package directly on an item, and instead drop it on the tree
        /// then that's how things get reordered.
        /// </summary>
        /// <param name="tree"></param>
        /// <param name="package"></param>
        /// <param name="e"></param>
        private void ProcessDragDropOnTree(URDFTreeView tree, TreeViewItem package, DragEventArgs e)
        {
            TreeViewItem closest = GetItemToSideOfPoint(tree, e);

            // If no closest item was found, or if it didn't pass the qualifications then skip
            if (closest == null)
            {
                return;
            }

            if (closest.Items.Count > 0)
            {
                // If they drop it inbetween a parent and its first child, then that means they
                // want to set it as the closest's first item.
                ProcessDragDropOnItem(tree, closest, package, 0);
            }
            else
            {
                // If the closest was found, then add it to its parent at the appropriate index
                TreeViewItem parent       = (TreeViewItem)closest.Parent;
                int          closestIndex = parent.Items.IndexOf(closest);
                ProcessDragDropOnItem(tree, parent, package, closestIndex + 1);
            }
        }