private void GroupsTree_DragMotion(object o, DragMotionArgs args) { TreePath path; TreeViewDropPosition pos; if (BusinessDomain.LoggedUser.UserLevel == UserAccessLevel.Operator || !groupsTree.GetDestRowAtPos(args.X, args.Y, out path, out pos)) { args.RetVal = false; return; } if (Drag.GetSourceWidget(args.Context) == groupsTree) { TreeIter selectedRow; if (groupsTree.Selection.GetSelected(out selectedRow)) { if (groupsTree.Model.GetValue(selectedRow, 2) == deletedGroup) { args.RetVal = false; return; } TreePath draggedPath = groupsTree.Model.GetPath(selectedRow); if (!draggedPath.Equals(path) && !draggedPath.IsAncestor(path)) { TreeIter destRow; groupsTree.Model.GetIter(out destRow, path); if (groupsTree.Model.GetValue(destRow, 2) == deletedGroup) { args.RetVal = false; return; } groupsTree.SetDragDestRow(path, pos); } } } else { switch (pos) { case TreeViewDropPosition.Before: groupsTree.SetDragDestRow(path, TreeViewDropPosition.IntoOrBefore); break; case TreeViewDropPosition.After: groupsTree.SetDragDestRow(path, TreeViewDropPosition.IntoOrAfter); break; } } Gdk.Drag.Status(args.Context, args.Context.SuggestedAction, args.Time); args.RetVal = true; }
private void GroupsTree_DragDrop(object o, DragDropArgs args) { if (Drag.GetSourceWidget(args.Context) != groupsTree) { return; } TreePath path; TreeViewDropPosition pos; groupsTree.GetDestRowAtPos(args.X, args.Y, out path, out pos); TreeIter row; groupsTree.Model.GetIter(out row, path); T group = (T)groupsTree.Model.GetValue(row, 2); int insertionIndex = GetInsertionIndex(pos, ref group); TreeIter selectedRow; if (!groupsTree.Selection.GetSelected(out selectedRow)) { args.RetVal = true; Drag.Finish(args.Context, false, false, args.Time); return; } TreePath draggedPath = groupsTree.Model.GetPath(selectedRow); if (draggedPath.Equals(path) || draggedPath.IsAncestor(path)) { args.RetVal = true; Drag.Finish(args.Context, false, false, args.Time); return; } T draggedGroup = RemoveFromOldPosition(group, selectedRow, ref insertionIndex); MoveGroup(draggedGroup, insertionIndex, group); args.RetVal = true; Drag.Finish(args.Context, true, true, args.Time); TreePath movedPath = LoadGroups(false, draggedGroup); groupsTree.ExpandToPath(movedPath); }
public static Widget GetSourceWidget(this DragContext context) { return(Drag.GetSourceWidget(context)); }