示例#1
0
        private void SceneTreeView_GiveFeedback(object sender, GiveFeedbackEventArgs e)
        {
            // update the position of the visual feedback item
            Win32Point w32Mouse = new Win32Point();

            GetCursorPos(ref w32Mouse);
            var pfs = SceneTreeView.PointFromScreen(new Point(w32Mouse.X, w32Mouse.Y));
            var tb  = SceneTreeView.InputHitTest(pfs) as TextBlock;

            if (tb != null)
            {
                if (tb != old_tb)
                {
                    if (old_tb != start_tb)
                    {
                        old_tb.Background = null;
                    }

                    if (tb != start_tb)
                    {
                        tb.Background = System.Windows.Media.Brushes.DarkGray;
                        var        s1 = System.Windows.Media.VisualTreeHelper.GetParent(tb);
                        StackPanel s2 = (StackPanel)System.Windows.Media.VisualTreeHelper.GetParent(s1);
                        target_drag = (Model)s2.DataContext;  //Set current target drag
                        //Console.WriteLine("Cursor Over " + target_drag.Name);
                    }

                    old_tb = tb;
                }
            }
        }
示例#2
0
        private void SceneTreeView_Drop(object sender, DragEventArgs e)
        {
            var           tv     = sender as TreeView;
            IInputElement target = SceneTreeView.InputHitTest(e.GetPosition(SceneTreeView));

            if (old_tb != start_tb)
            {
                old_tb.Background = null;
            }
            TextBlock tb = (TextBlock)target;

            if (tb == null || target_drag == null)
            {
                return;
            }

            if (init_drag != target_drag)
            {
                //Remove child from parent model node
                ThreadRequest req = new ThreadRequest();
                req.type = THREAD_REQUEST_TYPE.CHANGE_MODEL_PARENT_REQUEST;
                req.arguments.Add(init_drag);
                req.arguments.Add(target_drag);
                glControl.engine.issueRenderingRequest(ref req);

                /*
                 * lock (init_drag)
                 * {
                 *  if (init_drag.parent != null)
                 *  {
                 *      lock (init_drag.parent.Children)
                 *      {
                 *          init_drag.parent.Children.Remove(init_drag);
                 *      }
                 *  }
                 *
                 *  //Add to target node
                 *  init_drag.parent = target_drag;
                 * }
                 *
                 * lock (target_drag.Children)
                 * {
                 *  target_drag.Children.Add(init_drag);
                 * }
                 */

                init_drag   = null;
                target_drag = null;
                e.Handled   = true;
            }
        }