Example #1
0
        private void tvAspects_DragOver(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetDataPresent(Strings.TreeNodeType, false))
                {
                    TreeNode Src = (TreeNode)e.Data.GetData(Strings.TreeNodeType);
                    tvAspects.SelectedNode = Src;

                    int kind = CursorHelper.GetCursorKind(tvAspects, Adapter, Src, e.X, e.Y);

                    if (kind == -1)
                    {
                        e.Effect = DragDropEffects.None;
                    }
                    else
                    {
                        e.Effect = DragDropEffects.Move;
                    }

                    if (OldCursor != kind)
                    {
                        OldCursor = kind;
                        if (kind == -1)
                        {
                            Cursor.Current = Cursors.No;
                        }
                        else if (kind == 0)
                        {
                            Cursor.Current = GetCursor(Strings.CursorNewLevel);
                        }
                        else //if (kind == 1)
                        {
                            Cursor.Current = GetCursor(Strings.CursorInLine);
                        }
                    }
                }
            }
            catch (Exception exc)
            {
                ExceptionInfoHelper.ShowInfo(exc);
            }
        }
Example #2
0
        private void tvAspects_DragDrop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetDataPresent(Strings.TreeNodeType, false))
                {
                    TreeNode newParent;
                    int      pos;
                    CursorHelper.GetPositionToInsert(tvAspects, Adapter, e.X, e.Y, out newParent, out pos);
                    TreeNode NewNode = (TreeNode)e.Data.GetData(Strings.TreeNodeType);
                    Adapter.MoveNode(NewNode, newParent, pos);
                    SynchronizeUndoButtons();
                }
                else if (e.Data.GetDataPresent(DataFormats.FileDrop))
                {
                    string fileName = ((string[])(e.Data.GetData(DataFormats.FileDrop)))[0];
                    try
                    {
                        ParserWrapper   pw        = treeManager.GetParserWrapper();
                        PointOfInterest subAspect = Manager.DeserializeAspect(fileName, pw);
                        treeManager.ReleaseParserWrapper(pw);
                        if (subAspect != null)
                        {
                            Point    pt        = tvAspects.PointToClient(new Point(e.X, e.Y));
                            TreeNode newParent = tvAspects.GetNodeAt(pt);
                            Adapter.InsertNode(newParent, subAspect);
                        }
                    }
                    catch (Exception exc)
                    {
                        SetStatus(Strings.UnsupportedAspectFile);
                    }

                    SynchronizeUndoButtons();
                }
            }
            catch (Exception exc)
            {
                ExceptionInfoHelper.ShowInfo(exc);
            }
        }
Example #3
0
        /// <summary>
        /// Возвращает номер курсора, который нужно показать в данной точке
        /// </summary>
        /// <param name="tv">TreeView, надо которым перемещается узел</param>
        /// <param name="node">Перемещаемый узел</param>
        /// <param name="x">Координаты курсора</param>
        /// <param name="y">Координаты курсора</param>
        /// <returns>-1 - обычный курсор, перемещать в эту точку нельзя
        /// 0 - курсор, указывающий на добавление нового уровня
        /// 1 - курсор, указывающий на добавление узла на том же уровне</returns>
        public static int GetCursorKind(TreeView tv, TreeViewAdapter tva, TreeNode node, int x, int y)
        {
            TreeNode Dst;
            int      pos;

            CursorHelper.GetPositionToInsert(tv, tva, x, y, out Dst, out pos);
            if (!CursorHelper.NestingAllowed(node, Dst) ||// нельзя перемещать узел в своего же потомка
                (Dst == node.Parent && (node.Index == pos || node.Index == pos - 1))   // не надо двигать, если положение и так совпадет
                )
            {
                return(-1);
            }
            if (Dst != null && Dst == tv.GetNodeAt(tv.PointToClient(new Point(x, y))))
            {
                return(0);
            }
            else
            {
                return(1);
            }
        }