コード例 #1
0
        /// <summary> 拖拽开始执行的事件
        /// 做为数据发送者时触发 </summary>
        /// <param name="context"></param>
        protected override void OnDragBegin(DragContext context)
        {
            DragDropJudedArgs args = new DragDropJudedArgs()
            {
                DragContext = context
            };

            OnDragBeginJudgedHandle(args);
            if (!args.Handle)
            {
                var selectviewdatas = new List <T>();
                var selecttreeiters = this.GetAllSelectedTreeIters();
                foreach (var item in selecttreeiters)
                {
                    var isselectparent = selecttreeiters.FirstOrDefault(i => this.IsParent(item, i));
                    if (isselectparent.Equals(TreeIter.Zero))
                    {
                        selectviewdatas.Add(this.GetJisonsTreeIter(item).Data);
                    }
                }

                var dragData = new DragData()
                {
                    SelectionDatas = selectviewdatas,
                    IsDo           = false
                };

                context.SetDragData(dragData);

                //Gtk.Drag.SetIconPixbuf(context, dragPixbuf, 0, 0);

                base.OnDragBegin(context);
            }
        }
コード例 #2
0
 protected void OnOnDragDropJudgedHandle(DragDropJudedArgs args)
 {
     if (this.OnDragDropJudged != null)
     {
         this.OnDragDropJudged(this, args);
     }
 }
コード例 #3
0
 protected void TreeView_OnDragDropJudged(object sender, DragDropJudedArgs e)
 {
     if (this.OnDragDropJudged != null)
     {
         this.OnDragDropJudged(sender, e);
     }
 }
コード例 #4
0
 void TreeView_OnDragMotionJudged(object sender, DragDropJudedArgs e)
 {
     if (this.OnDragMotionJudged != null)
     {
         this.OnDragMotionJudged(this, e);
     }
 }
コード例 #5
0
        protected override bool OnDragDrop(DragContext context, int x, int y, uint time_)
        {
            DragDropJudedArgs args = new DragDropJudedArgs()
            {
                DragContext = context
            };

            OnOnDragDropJudgedHandle(args);
            if (!args.Handle)
            {
                return(base.OnDragDrop(context, x, y, time_));
            }
            else
            {
                return(false);
            }
        }
コード例 #6
0
        protected override bool OnDragMotion(DragContext context, int x, int y, uint time_)
        {
            DragDropJudedArgs args = new DragDropJudedArgs()
            {
                DragContext = context
            };

            OnOnDragMotionJudgedHandle(args);
            if (!args.Handle)
            {
                var dragwidget = context.GetSourceWidget();
                if (dragwidget != null)
                {
                    var dragData = context.GetDragData() as DragData;
                    //内部拖拽
                    if (dragData != null)
                    {
                        return(base.OnDragMotion(context, x, y, time_));
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    //此时拖拽为外部拖拽
                    return(true);
                }
            }
            else
            {
                if (args.AllDrop)
                {
                    return(base.OnDragMotion(context, x, y, time_));
                }
                else
                {
                    return(false);
                }
            }
        }
コード例 #7
0
        /// <summary> 接收具有拖拽数据的事件
        /// 做为数据接收者时触发 </summary>
        /// <param name="context"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="selection_data"></param>
        /// <param name="info"></param>
        /// <param name="time_"></param>
        protected override void OnDragDataReceived(DragContext context, int x, int y, SelectionData selection_data, uint info, uint time_)
        {
            DragDropJudedArgs args = new DragDropJudedArgs()
            {
                DragContext = context
            };

            OnOnDragDataReceivedJudgedHandle(args);
            if (!args.Handle)
            {
                base.OnDragDataReceived(context, x, y, selection_data, info, time_);
                var dragData = context.GetDragData() as DragData;
                //内部拖拽
                if (dragData != null)
                {
                    Gtk.TreePath treePath; Gtk.TreeViewDropPosition dropPostition;
                    var          isDrop = GetDropTargetRow(x, y, out treePath, out dropPostition);

                    #region 结构树内数据项之间拖拽

                    if (isDrop)
                    {
                        dragData.IsDo = true;
                        var iters          = dragData.SelectionDatas as List <T>;
                        var treeiterparent = this.GetTreeIter(treePath);
                        if (iters != null)
                        {
                            var parentjti = this.GetJisonsTreeIter(treeiterparent);
                            if (!iters.Contains(parentjti.Data))
                            {
                                switch (dropPostition)
                                {
                                case TreeViewDropPosition.Before:
                                {
                                    if (iters.All(i => this.RootTreeIter.CanDrop(parentjti.Data, i as object, DropPosition.InsertBefore, false)))
                                    {
                                        this.RootTreeIter.Drop(parentjti.Data, iters.Cast <object>().ToList(), DropPosition.InsertBefore, false);
                                    }
                                    break;
                                }

                                case TreeViewDropPosition.After:
                                {
                                    if (iters.All(i => this.RootTreeIter.CanDrop(parentjti.Data, i as object, DropPosition.InsertAfter, false)))
                                    {
                                        this.RootTreeIter.Drop(parentjti.Data, iters.Cast <object>().ToList(), DropPosition.InsertAfter, false);
                                    }
                                    break;
                                }

                                default:
                                {
                                    if (!iters.Contains(parentjti.Data) && iters.All(i => this.RootTreeIter.CanDrop(parentjti.Data, i as object, DropPosition.Add, false)))
                                    {
                                        this.RootTreeIter.Drop(parentjti.Data, iters.Cast <object>().ToList(), DropPosition.Add, false);
                                    }
                                    break;
                                }
                                }
                            }
                        }
                    }

                    #endregion

                    #region 数据拖动到结构树数据项之外时触发

                    else if (treePath == null)
                    {
                        dragData.IsDo = true;
                        var iters = dragData.SelectionDatas as List <T>;
                        if (iters != null)
                        {
                            foreach (var item in iters)
                            {
                                var jti = this.GetJisonsTreeIter(item);
                                if (this.JisonsTreeIters.Contains(jti) &&
                                    this.GetParentTreeIter(jti.TreeIter).Equals(TreeIter.Zero))
                                {
                                    continue;
                                }

                                if (item != null)
                                {
                                    if (this.RootTreeIter != null && this.RootTreeIter.FirstDepthChildren.FirstOrDefault() != null)
                                    {
                                        this.RootTreeIter.Drop(this.RootTreeIter.FirstDepthChildren.FirstOrDefault(), iters.Cast <object>().ToList(), DropPosition.Add, false);
                                    }
                                }
                            }
                        }
                    }

                    #endregion
                }
            }
        }