示例#1
0
        protected override void HandleDragOver(sw.DragEventArgs e, DragEventArgs args)
        {
            var lastRow = LastDragRow;

            base.HandleDragOver(e, args);
            var info = LastDragInfo = GetDragInfo(args);

            if (args.Effects != DragEffects.None)
            {
                // show drag indicator!
                var row = GetDataGridRow(GetItemAtRow(info.Index));
                if (row != null)
                {
                    // same position, just return
                    if (lastRow != null && lastRow.IsEqual(row, info.InsertIndex))
                    {
                        return;
                    }

                    lastRow?.Revert();
                    LastDragRow = new GridDragRowState(row, info.InsertIndex);

                    if (info.InsertIndex == -1)
                    {
                        row.Background = sw.SystemColors.HighlightBrush;
                        row.Foreground = sw.SystemColors.HighlightTextBrush;
                    }
                    else
                    {
                        var d  = new swm.GeometryDrawing();
                        var gg = new swm.GeometryGroup();
                        gg.Children.Add(new swm.LineGeometry(new sw.Point(0, 0), new sw.Point(row.ActualWidth, 0)));
                        d.Geometry = gg;
                        d.Brush    = sw.SystemColors.HighlightBrush;
                        d.Pen      = new swm.Pen(sw.SystemColors.HighlightBrush, 1);
                        var b = new swm.DrawingBrush {
                            Drawing = d, TileMode = swm.TileMode.None, Stretch = swm.Stretch.None, AlignmentX = swm.AlignmentX.Left
                        };
                        if (info.InsertIndex == row.GetIndex())
                        {
                            b.AlignmentY        = swm.AlignmentY.Top;
                            row.BorderThickness = new sw.Thickness(0, 1, 0, 0);
                        }
                        else
                        {
                            b.AlignmentY        = swm.AlignmentY.Bottom;
                            row.BorderThickness = new sw.Thickness(0, 0, 0, 1);
                        }

                        row.BorderBrush = b;
                    }
                    return;
                }
            }

            ResetDrag();
        }
示例#2
0
            public override void HandleDragDrop(object o, Gtk.DragDropArgs args)
            {
                // use the info from last drag if it was set
                var info = Handler?.GetDragInfo(DragArgs);

                if (info?.IsChanged == true)
                {
                    _dragInfo = info;
                }
                base.HandleDragDrop(o, args);
                _dragInfo = null;
            }
示例#3
0
            protected override DragEventArgs GetDragEventArgs(Gdk.DragContext context, PointF?location, uint time = 0, object controlObject = null)
            {
                var t = Handler?.Tree;
                GridViewDragInfo dragInfo = _dragInfo;

                if (dragInfo == null && location != null)
                {
                    if (t.GetDestRowAtPos((int)location.Value.X, (int)location.Value.Y, out var path, out var pos))
                    {
                        var item     = Handler.model.GetItemAtPath(path);
                        var indecies = path.Indices;
                        var index    = indecies[indecies.Length - 1];
                        dragInfo = new GridViewDragInfo(Handler.Widget, item, index, pos.ToEto());
                    }
                }

                return(base.GetDragEventArgs(context, location, time, dragInfo));
            }
示例#4
0
        protected override Eto.Forms.DragEventArgs GetDragEventArgs(System.Windows.DragEventArgs data, object controlObject)
        {
            var location = data.GetPosition(Control).ToEto();
            var cell     = Widget.GetCellAt(location);
            var item     = cell.Item;
            int index;
            var row = GetDataGridRow(cell.Item);
            GridDragPosition position;

            if (row != null)
            {
                index = row.GetIndex();

                var rowLocation = row.TransformToAncestor(Control).Transform(new sw.Point(0, 0));
                if (location.Y + 4 > rowLocation.Y + row.ActualHeight - row.BorderThickness.Vertical())
                {
                    position = GridDragPosition.After;
                }
                else if (location.Y < rowLocation.Y + 4 + row.BorderThickness.Top)
                {
                    position = GridDragPosition.Before;
                }
                else
                {
                    position = GridDragPosition.Over;
                }
            }
            else
            {
                item     = null;
                position = GridDragPosition.Over;
                index    = -1;
            }

            controlObject = new GridViewDragInfo(Widget, item, index, position);

            return(base.GetDragEventArgs(data, controlObject));
        }
示例#5
0
 void ResetDrag()
 {
     LastDragInfo = null;
     LastDragRow?.Revert();
     LastDragRow = null;
 }