private void MoveNodeDown()
        {
            CsgNodeTreeViewItem item = nodeView.SelectedItem as CsgNodeTreeViewItem;

            if (item == null)
            {
                return;
            }
            CsgGroupTreeViewItem parent = item.Parent as CsgGroupTreeViewItem;

            if (parent == null)
            {
                return;
            }
            int newIndex; for (newIndex = parent.Group.ChildrenCount - 1; newIndex >= 0; newIndex--)

            {
                if (parent.Group.Group[newIndex] == item.Node.Node)
                {
                    break;
                }
            }
            newIndex++;
            if (newIndex < 0)
            {
                newIndex = 0;
            }
            parent.Group.MoveChild(item.Node, newIndex);
            item.IsSelected = true;
        }
Exemple #2
0
        public void RefreshChildren()
        {
            List <CsgNodeTreeViewItem> newNodes = new List <CsgNodeTreeViewItem>();

            foreach (CsgNodeWrapper wrapper in group.Children)
            {
                CsgNodeTreeViewItem view;
                if (!nodes.TryGetValue(wrapper, out view))
                {
                    if (wrapper is CsgCubeWrapper)
                    {
                        view = new CsgCubeTreeViewItem(owner, (CsgCubeWrapper)wrapper);
                    }
                    else if (wrapper is CsgTranslateWrapper)
                    {
                        view = new CsgTranslateTreeViewItem(owner, (CsgTranslateWrapper)wrapper);
                    }
                    else if (wrapper is CsgScaleWrapper)
                    {
                        view = new CsgScaleTreeViewItem(owner, (CsgScaleWrapper)wrapper);
                    }
                    else if (wrapper is CsgRotateWrapper)
                    {
                        view = new CsgRotateTreeViewItem(owner, (CsgRotateWrapper)wrapper);
                    }
                    else if (wrapper is CsgUnionWrapper)
                    {
                        view = new CsgUnionTreeViewItem(owner, (CsgUnionWrapper)wrapper);
                    }
                    else if (wrapper is CsgSubtractWrapper)
                    {
                        view = new CsgSubtractTreeViewItem(owner, (CsgSubtractWrapper)wrapper);
                    }
                    else if (wrapper is CsgIntersectWrapper)
                    {
                        view = new CsgIntersectTreeViewItem(owner, (CsgIntersectWrapper)wrapper);
                    }
                    else if (wrapper is CsgGroupWrapper)
                    {
                        view = new CsgGroupTreeViewItem(owner, (CsgGroupWrapper)wrapper);
                    }
                }
                if (view == null)
                {
                    view = new CsgNodeTreeViewItem(owner, wrapper);
                }
                newNodes.Add(view);
            }
            nodes.Clear();
            Items.Clear();
            foreach (CsgNodeTreeViewItem node in newNodes)
            {
                Items.Add(node);
                nodes[node.Node] = node;
            }
        }
        private void MoveNodeLast()
        {
            CsgNodeTreeViewItem item = nodeView.SelectedItem as CsgNodeTreeViewItem;

            if (item == null)
            {
                return;
            }
            CsgGroupTreeViewItem parent = item.Parent as CsgGroupTreeViewItem;

            if (parent == null)
            {
                return;
            }
            parent.Group.MoveChild(item.Node, parent.Group.ChildrenCount - 1);
        }
        private void MoveNodeRight()
        {
            CsgNodeTreeViewItem item = nodeView.SelectedItem as CsgNodeTreeViewItem;

            if (item == null)
            {
                return;
            }
            CsgGroupTreeViewItem parent = item.Parent as CsgGroupTreeViewItem;

            if (parent == null)
            {
                return;
            }
            int newIndex; for (newIndex = parent.Group.ChildrenCount - 1; newIndex >= 0; newIndex--)

            {
                if (parent.Group.Group[newIndex] == item.Node.Node)
                {
                    break;
                }
            }
            if (newIndex <= 0)
            {
                return;
            }
            CsgGroupTreeViewItem newParent = null;

            if (newIndex > 0)
            {
                newParent = parent.Items[newIndex - 1] as CsgGroupTreeViewItem;
            }
            if (newParent == null && (newIndex + 1) < parent.Items.Count)
            {
                newParent = parent.Items[newIndex + 1] as CsgGroupTreeViewItem;
            }
            if (newParent != null)
            {
                parent.Group.RemoveChild(item.Node);
                newParent.Group.AddChild(item.Node);
                parent.IsExpanded    = true;
                newParent.IsExpanded = true;
                item            = newParent.Items.Cast <CsgNodeTreeViewItem>().First(x => x.Node == item.Node);
                item.IsSelected = true;
                item.Focus();
            }
        }
        private void DeleteNode()
        {
            CsgNodeTreeViewItem item = nodeView.SelectedItem as CsgNodeTreeViewItem;

            if (item == null)
            {
                return;
            }
            CsgGroupTreeViewItem parent = item.Parent as CsgGroupTreeViewItem;

            if (parent == null)
            {
                return;
            }
            parent.Group.RemoveChild(item.Node);
            RecursiveDelete(item.Node as CsgGroupWrapper);
        }
        private void MoveNodeLeft()
        {
            CsgNodeTreeViewItem item = nodeView.SelectedItem as CsgNodeTreeViewItem;

            if (item == null)
            {
                return;
            }
            CsgGroupTreeViewItem parent = item.Parent as CsgGroupTreeViewItem;

            if (parent == null)
            {
                return;
            }
            CsgGroupTreeViewItem superParent = parent.Parent as CsgGroupTreeViewItem;

            if (superParent == null)
            {
                return;
            }
            int newIndex; for (newIndex = superParent.Group.ChildrenCount - 1; newIndex >= 0; newIndex--)

            {
                if (superParent.Group.Group[newIndex] == parent.Node.Node)
                {
                    break;
                }
            }
            if (newIndex <= 0)
            {
                newIndex = superParent.Group.ChildrenCount - 1;
            }
            parent.Group.RemoveChild(item.Node);
            superParent.Group.AddChild(item.Node);
            newIndex++; if (newIndex >= superParent.Group.ChildrenCount)
            {
                newIndex = superParent.Group.ChildrenCount - 1;
            }
            superParent.Group.MoveChild(item.Node, newIndex);
            parent.IsExpanded = false;
            superParent.Items.Cast <CsgNodeTreeViewItem>().First(x => x.Node == item.Node).IsSelected = true;
        }
Exemple #7
0
 protected override void OnMouseMove(MouseEventArgs e)
 {
     if (e.LeftButton == MouseButtonState.Pressed)
     {
         CsgGroupTreeViewItem parent = Parent as CsgGroupTreeViewItem;
         if (parent != null)
         {
             DragDrop.DoDragDrop(this, Node.Id + "|" + parent.Node.Id, DragDropEffects.Move);
             e.Handled = true;
         }
     }
     else if (e.RightButton == MouseButtonState.Pressed)
     {
         CsgGroupTreeViewItem parent = Parent as CsgGroupTreeViewItem;
         if (parent != null)
         {
             DragDrop.DoDragDrop(this, Node.Id + "|" + parent.Node.Id, DragDropEffects.Link);
             e.Handled = true;
         }
     }
     base.OnMouseMove(e);
 }
        private void DuplicateNode()
        {
            CsgNodeTreeViewItem item = nodeView.SelectedItem as CsgNodeTreeViewItem;

            if (item == null)
            {
                return;
            }
            CsgGroupTreeViewItem parent = item.Parent as CsgGroupTreeViewItem;

            if (parent == null)
            {
                return;
            }
            int newIndex; for (newIndex = parent.Group.ChildrenCount - 1; newIndex >= 0; newIndex--)

            {
                if (parent.Group.Group[newIndex] == item.Node.Node)
                {
                    break;
                }
            }
            if (newIndex < 0)
            {
                newIndex = parent.Group.ChildrenCount;
            }
            else
            {
                newIndex++;
            }
            CsgNodeWrapper clone = item.Node.Clone();

            parent.Group.AddChild(clone);
            if (newIndex != (parent.Group.ChildrenCount - 1))
            {
                parent.Group.MoveChild(clone, newIndex);
            }
            parent.Items.Cast <CsgNodeTreeViewItem>().First(x => x.Node == clone).IsSelected = true;
        }