void IDragDropElement.DragOver(DragContext context) { if (context == null) { return; } var data = context.PayloadData as ReorderItemsDragOperation; if (data != null) { var position = context.GetDragPosition(this); if (this.ShouldReorder(position, data)) { if (this.ListView.swipedItem == data.Item) { this.ClearActionContent(); } var newIndex = this.reorderCoordinator.ReorderItem(data.CurrentSourceReorderIndex, this); data.CurrentSourceReorderIndex = newIndex; } } else if (this.ListView != null && this.ListView.isActionContentDisplayed) { var startPoint = context.GetRelativeStartPosition(); var currentPoint = context.GetDragPosition(this); this.dragX = currentPoint.X - startPoint.X; this.dragY = currentPoint.Y - startPoint.Y; this.UpdateActionContentClipping(this.ListView.Orientation == Windows.UI.Xaml.Controls.Orientation.Horizontal ? this.dragY : this.dragX); } }
protected override bool OnDragDrop(DragContext context, int x, int y, uint time_) { object dragData = context.GetDragData(); ResourceInfoDragData resourceInfoDragData = dragData as ResourceInfoDragData; bool result; if (resourceInfoDragData == null || resourceInfoDragData.Items.Count < 1 || !(resourceInfoDragData.Items.FirstOrDefault <ResourceItem>() is ResourceFile)) { result = false; } else { ResourceFile resourceFile = (ResourceFile)resourceInfoDragData.Items.FirstOrDefault <ResourceItem>(); if (resourceFile != null) { if (this.CheckResource(resourceFile)) { this.SetValue(resourceFile); this.resourceFile = resourceFile; } } result = base.OnDragDrop(context, x, y, time_); } return(result); }
void IDragDropElement.DragEnter(DragContext context) { var positionMode = this.Owner.Orientation == Orientation.Vertical ? DragPositionMode.RailY : DragPositionMode.RailX; DragDrop.SetDragPositionMode(this, positionMode); }
void IDragDropElement.DragOver(DragContext context) { if (context == null) { return; } var data = context.PayloadData as ReorderItemsDragOperation; if (data == null) { return; } var position = context.GetDragPosition(this); if (!this.ShouldReorder(position, data)) { return; } if (this.Owner.swipedItem == data.Item) { this.Owner.ResetActionContent(); } var newIndex = this.reorderCoordinator.ReorderItem(data.CurrentSourceReorderIndex, this); data.CurrentSourceReorderIndex = newIndex; }
protected override void OnDragDataReceived(DragContext context, int x, int y, SelectionData selection_data, uint info, uint time_) { base.OnDragDataReceived(context, x, y, selection_data, info, time_); if (info == 100u) { string fullData = System.Text.Encoding.UTF8.GetString(selection_data.Data); foreach (string individualFile in fullData.Split('\n')) { string file = individualFile.Trim(); if (file.StartsWith("file://")) { file = new Uri(file).LocalPath; if (!CheckImage(file)) { return; } if (project != null) { file = project.GetRelativeChildPath(file); } SelectedProjectFile = file; OnChanged(EventArgs.Empty); } } } }
/// <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); } }
void IDragDropElement.DragOver(DragContext context) { if (context == null) { return; } var data = context.PayloadData as ReorderItemsDragOperation; if (data != null) { var sourceHeader = this.reorderCoordinator.Host.ElementAt(data.CurrentSourceReorderIndex) as DataGridFlyoutHeader; //// TODO: check CanStartReorder parameter ////var canReorder = this.ParentGrid.DragBehavior.CanReorder(sourceHeader.DataContext as GroupDescriptorBase, this.DataContext as GroupDescriptorBase); var canReorder = this.CanReorder(sourceHeader.DataContext, this.DataContext); if (canReorder) { var rect = context.GetDragVisualBounds(this); if ((rect.Bottom > this.ActualHeight / 2 && this.logicalIndex > data.CurrentSourceReorderIndex) || (rect.Y < this.ActualHeight / 2 && this.logicalIndex < data.CurrentSourceReorderIndex)) { var newIndex = this.reorderCoordinator.ReorderItem(data.CurrentSourceReorderIndex, this); data.CurrentSourceReorderIndex = newIndex; } } } }
protected override bool OnDragDrop(DragContext context, int x, int y, uint time) { TreePath path; TreeViewDropPosition pos; if (GetDestRowAtPos(x, y, out path, out pos)) { TreeIter destIter; Project.EventTypes.Remove(draggedEventType); Project.EventTypes.Insert(path.Indices [0], draggedEventType); Model.GetIter(out destIter, path); if (dropPos == TreeViewDropPosition.After) { Model.MoveAfter(srcIter, destIter); } else { Model.MoveBefore(srcIter, destIter); } Refilter(); } Gtk.Drag.Finish(context, true, false, time); return(true); }
protected override void OnDragBegin(DragContext context) { Model.GetIter(out selectedIter, Selection.GetSelectedRows()[0]); selectedPlay = (PlayListPlay)Model.GetValue(selectedIter, 0); preDragPos = Model.GetPath(selectedIter).Indices[0]; Console.WriteLine(Model.GetPath(selectedIter)); base.OnDragBegin(context); }
public static DragAction GetAction(this DragContext args) { #if NETFRAMEWORK return(args.Action); #else return(args.SelectedAction); #endif }
protected override void OnDragLeave(DragContext context, uint time_) { if (!draggingDivider) { GdkWindow.Cursor = null; } base.OnDragLeave(context, time_); }
protected override void OnDragBegin(DragContext context) { Selection.GetSelected(out selectedIter); FillElementAndPlaylist(selectedIter, out dragSourcePlaylist, out dragSourceElement); dragStarted = true; base.OnDragBegin(context); }
public static object GetDragData(DragContext dragContext) { if (DragDataManager.sourceWidget == null && DragDataManager.data is FileDropInfo || DragDataManager.IsSameSourceWidget(dragContext)) { return(DragDataManager.data); } Console.WriteLine("Should set drag data in begin drag event. Then can get drag data."); return((object)null); }
bool IDragDropElement.CanDrop(DragContext dragContext) { if (dragContext == null) { return(false); } return(dragContext.PayloadData is ReorderItemsDragOperation); }
void IDragDropElement.OnDrop(DragContext dragContext) { if (dragContext != null) { var columnContext = dragContext.PayloadData as DataGridColumnHeaderDragOperation; if (columnContext != null) { this.Owner.DragBehavior.GroupBy(columnContext.Column); } } }
void IDragDropElement.DragOver(DragContext context) { if (context != null) { // Ensure that state is correct when dragging multiple items and one leaves the panel. var columnContext = context.PayloadData as DataGridColumnHeaderDragOperation; if (columnContext != null) { this.DropPossible = this.Owner.DragBehavior.CanGroupBy(columnContext.Column); } } }
void DisableDragInto(TreePath path, DragContext context, uint time, TreeViewDropPosition pos) { if (pos == TreeViewDropPosition.IntoOrAfter) { pos = TreeViewDropPosition.After; } else if (pos == TreeViewDropPosition.IntoOrBefore) { pos = TreeViewDropPosition.Before; } SetDragDestRow(path, pos); Gdk.Drag.Status(context, context.SuggestedAction, time); }
void IDragDropElement.OnDrop(DragContext dragContext) { if (dragContext == null) { return; } var data = dragContext.PayloadData as ReorderItemsDragOperation; if (data != null) { this.reorderCoordinator.CommitReorderOperation(data.InitialSourceIndex, data.CurrentSourceReorderIndex); } }
protected override void OnDragEnd(DragContext context) { dragSelect = false; StopDragScroll(); drag_reorder_row_index = -1; drag_reorder_motion_y = -1; InvalidateList(); base.OnDragEnd(context); // HACK: surprise, GTK fails again; it cannot detect the released button on the mac and drag-selection doesn't stop if (PlatformHelper.Platform == Warehouse.Data.PlatformTypes.MacOSX) { pressed_row_index = -1; last_row_index = -1; } }
void IDragDropElement.OnDragging(DragContext dragContext) { if (dragContext == null) { return; } if (dragContext.PayloadData is DragAction && (DragAction)dragContext.PayloadData == DragAction.ItemAction) { var offset = this.ListView.Orientation == Windows.UI.Xaml.Controls.Orientation.Horizontal ? this.dragY : this.dragX; var swipeContext = new ItemSwipingContext(this.DataContext, this, offset); this.ListView.swipedItem = this; this.ListView.commandService.ExecuteCommand(CommandId.ItemSwiping, swipeContext); } }
protected override void OnDragBegin(DragContext context) { base.OnDragBegin(context); if (Selection.Contains(FocusedRow)) { return; } double [] axes; ModifierType modifier; Device.CorePointer.GetState(RootWindow, out axes, out modifier); const ModifierType buttonMask = ModifierType.Button1Mask | ModifierType.Button2Mask | ModifierType.Button3Mask | ModifierType.Button4Mask | ModifierType.Button5Mask; Select(modifier & ~buttonMask, (uint)(modifier & buttonMask), FocusedRow, false); }
bool IDragDropElement.CanDrop(DragContext dragContext) { if (dragContext != null) { var columnContext = dragContext.PayloadData as DataGridColumnHeaderDragOperation; if (columnContext != null) { this.DropPossible = this.Owner.DragBehavior.CanGroupBy(columnContext.Column); return(this.DropPossible); } } return(false); }
protected override bool OnDragDrop(DragContext context, int x, int y, uint time_) { ResourceInfoDragData dragData = context.GetDragData() as ResourceInfoDragData; if (dragData == null) { return(false); } ResourceFile file = dragData.Items.FirstOrDefault <ResourceItem>() as ResourceFile; if (file != null && this.CheckResource(file)) { this.SetValue(file); } return(base.OnDragDrop(context, x, y, time_)); }
bool IDragDropElement.CanDrop(DragContext context) { if (context != null && this.reorderCoordinator != null) { var data = context.PayloadData as ReorderItemsDragOperation; if (data != null) { return(this.ListView.DragBehavior.CanReorder(data.Data, this.DataContext)); } else { if (this.Orientation == Windows.UI.Xaml.Controls.Orientation.Vertical) { switch (this.SwipeDirection) { case ListViewItemSwipeDirection.Forward: return(this.dragX > this.ListView.ItemSwipeThreshold); case ListViewItemSwipeDirection.Backwards: return(this.dragX < 0 && Math.Abs(this.dragX) > this.ListView.ItemSwipeThreshold); case ListViewItemSwipeDirection.All: default: return(Math.Abs(this.dragX) > this.ListView.ItemSwipeThreshold); } } else { switch (this.SwipeDirection) { case ListViewItemSwipeDirection.Forward: return(this.dragY > this.ListView.ItemSwipeThreshold); case ListViewItemSwipeDirection.Backwards: return(this.dragY < 0 && Math.Abs(this.dragY) > this.ListView.ItemSwipeThreshold); case ListViewItemSwipeDirection.All: default: return(Math.Abs(this.dragY) > this.ListView.ItemSwipeThreshold); } } } } return(true); }
bool IDragDropElement.CanDrop(DragContext dragContext) { if (dragContext != null && this.reorderCoordinator != null) { var data = dragContext.PayloadData as ReorderItemsDragOperation; if (data != null) { var sourceElement = this.reorderCoordinator.Host.ElementAt(data.CurrentSourceReorderIndex) as DataGridColumnHeader; return(sourceElement != null && this.Owner.DragBehavior.CanReorder(sourceElement.Column, this.Column)); } return(false); } return(false); }
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); } }
protected override void OnDragEnd(DragContext context) { TreeIter iter; int postDragPos = -1; Model.GetIterFirst(out iter); do { if (Model.GetValue(iter, 0) == selectedPlay) { postDragPos = Model.GetPath(iter).Indices[0]; break; } } while (Model.IterNext(ref iter)); playlist.Reorder(preDragPos, postDragPos); base.OnDragEnd(context); }
protected override bool OnDragMotion(DragContext context, int x, int y, uint time) { DragSelect(y); if (!Reorderable) { StopDragScroll(); drag_reorder_row_index = -1; drag_reorder_motion_y = -1; InvalidateList(); return(false); } drag_reorder_motion_y = y; DragReorderUpdateRow(); OnDragScroll(OnDragVScrollTimeout, Allocation.Height * 0.3, Allocation.Height, y); return(true); }
protected override bool OnDragMotion(DragContext context, int x, int y, uint time) { TreePath path; TreeViewDropPosition pos; TreeIter iter; IPlaylistElement element; Playlist playlist; if (GetDestRowAtPos(x, y, out path, out pos)) { Model.GetIter(out iter, path); FillElementAndPlaylist(iter, out playlist, out element); /* Drag a playlist*/ if (dragSourceElement == null) { if (element == null) { DisableDragInto(path, context, time, pos); return(true); } else { return(false); } } /* Drag an element */ else { if (element != null) { DisableDragInto(path, context, time, pos); return(true); } else { return(false); } } } return(false); }
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); } } }