/// <inheritdoc /> public virtual void StartDrag(IDragInfo dragInfo) { var items = TypeUtilities.CreateDynamicallyTypedList(dragInfo.SourceItems).Cast <object>().ToList(); if (items.Count > 1) { dragInfo.Data = items; } else { // special case: if the single item is an enumerable then we can not drop it as single item var singleItem = items.FirstOrDefault(); if (singleItem is IEnumerable && !(singleItem is string)) { dragInfo.Data = items; } else { dragInfo.Data = singleItem; } } dragInfo.Effects = dragInfo.Data != null ? DragDropEffects.Copy | DragDropEffects.Move | DragDropEffects.Link : DragDropEffects.None; }
private static DragDropPreview GetDragDropPreview(IDragInfo dragInfo, UIElement visualTarget, UIElement sender) { var visualSource = dragInfo?.VisualSource; if (visualSource is null) { return(null); } var hasDragDropPreview = DragDropPreview.HasDragDropPreview(dragInfo, visualTarget ?? visualSource, sender); if (hasDragDropPreview) { var rootElement = TryGetRootElementFinder(sender).FindRoot(visualTarget ?? visualSource); var preview = new DragDropPreview(rootElement, dragInfo, visualTarget ?? visualSource, sender); if (preview.Child != null) { preview.IsOpen = true; return(preview); } } return(null); }
public override void StartDrag(IDragInfo dragInfo) { List <T> items = dragInfo.SourceItems.OfType <T>().ToList(); if (items.Count == 0) { dragInfo.Data = null; } else if (items.Count == 1) { dragInfo.Data = items; } else { // More than 1, we need to sort Dictionary <T, int> indices = GetIndices((IEnumerable <T>)obj.GetValue(prop)); items.Sort((x, y) => indices[x].CompareTo(indices[y])); dragInfo.Data = items; } dragInfo.Effects = (dragInfo.Data != null) ? DragDropEffects.Copy | DragDropEffects.Move : DragDropEffects.None; }
private static void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (HitTestScrollBar(sender, e)) { _dragInfo = null; return; } _dragInfo = new DragInfo(sender, e); var itemsControl = sender as ItemsControl; if (_dragInfo.VisualSourceItem == null || itemsControl == null || !itemsControl.CanSelectMultipleItems()) { return; } var selectedItems = itemsControl.GetSelectedItems(); if (selectedItems.Cast <object>().Contains(_dragInfo.SourceItem)) { // TODO: Re-raise the suppressed event if the user didn't initiate a drag. e.Handled = true; } }
public void StartDrag(IDragInfo dragInfo) { dragInfo.Data = null; dragInfo.Effects = DragDropEffects.None; if (null == dragInfo.SourceItem) { return; } NodeViewModel draggedModel = dragInfo.SourceItem as NodeViewModel; if (null == draggedModel) { throw new Exception("Dragged item is not of type NodeViewModel."); } if (!draggedModel.AllowDrag) { return; } dragInfo.Data = draggedModel; dragInfo.Effects = DragDropEffects.Move; }
public void Drop(IDropInfo dropInfo) { ZawartośćKlockaPionowegoZZawartością docelowaKolekcja = (ZawartośćKlockaPionowegoZZawartością)dropInfo.TargetCollection; KlocekPionowy upuszczanyKlocek = (KlocekPionowy)dropInfo.Data; upuszczanyKlocek.Rodzic = docelowaKolekcja.KlocekPionowyZZawartością; upuszczanyKlocek.ZPrzybornika = false; int indeksDocelowy = dropInfo.InsertIndex; IDragInfo informacjeOPrzeciągnięciu = dropInfo.DragInfo; ZawartośćKlockaPionowegoZZawartością źródło = informacjeOPrzeciągnięciu.SourceCollection as ZawartośćKlockaPionowegoZZawartością; ManipulacjaKlockiemPionowym manipulacja = new ManipulacjaKlockiemPionowym(ManipulacjeKlockiem.Dodanie, upuszczanyKlocek) { IndeksDocelowy = indeksDocelowy, Cel = docelowaKolekcja }; if (źródło != null) { manipulacja.IndeksŹródłowy = informacjeOPrzeciągnięciu.SourceIndex; manipulacja.Źródło = źródło; } docelowaKolekcja.Insert(indeksDocelowy, upuszczanyKlocek); _metodaZachowującaStanAplikacji(manipulacja); }
public void StartDrag(IDragInfo dragInfo) { FileNameItem filenameitem = (FileNameItem)dragInfo.SourceItem; dragInfo.Effects = DragDropEffects.Copy | DragDropEffects.Move; dragInfo.Data = filenameitem; }
public void StartDrag(IDragInfo dragInfo) { backlog.IsDragging = true; dragInfo.Effects = DragDropEffects.Copy | DragDropEffects.Move; dragInfo.Data = dragInfo.SourceItem; }
/// <inheritdoc /> public void DragDropOperationFinished(DragDropEffects operationResult, IDragInfo dragInfo) { if (alreadyDropped || dragInfo == null) { return; } // the drag operation has finished on another app if (operationResult != DragDropEffects.None) { if (operationResult.HasFlag(DragDropEffects.Move)) { var sourceList = dragInfo.SourceCollection.TryGetList(); var items = dragInfo.SourceItems.OfType <object>().ToList(); if (sourceList != null) { foreach (var o in items) { sourceList.Remove(o); } } alreadyDropped = true; } } }
public void StartDrag(IDragInfo dragInfo) { _projectBrowseControl._controller.AvailableItems_StartDrag(dragInfo.SourceItems, out var data, out var canCopy, out var canMove); dragInfo.Effects = GuiHelper.ConvertCopyMoveToDragDropEffect(canCopy, canMove); dragInfo.Data = data; }
/// <summary> /// Drag Tags (to autocomplete or hrlist) /// Data is tags without empty Last tag. /// </summary> /// <param name="dragInfo"></param> public void StartDrag(IDragInfo dragInfo) { var tags = dragInfo.SourceItems.Cast<TagViewModel>().Where(t => !(t.State == State.Init && t.IsLast)); master.CompleteTypings(); dragInfo.StartDragWith(tags); }
public bool CanStartDrag(IDragInfo dragInfo) { if (dragInfo.SourceItem.GetType() == typeof(FileNameItem)) { return(true); } return(false); }
public void StartDrag(IDragInfo dragInfo) { dragInfo.Effects = DragDropEffects.Copy; Klocek klocek = (Klocek)((Klocek)dragInfo.SourceItem).Clone(); klocek.ZPrzybornika = true; dragInfo.Data = klocek; }
public bool CanStartDrag(IDragInfo dragInfo) { if (dragInfo.SourceItem is IdeBaseItem item && item.CanDragDrop) { return(DragDrop.DefaultDragHandler.CanStartDrag(dragInfo)); } return(false); }
public override void StartDrag(IDragInfo dragInfo) { dragInfo.Effects = DragDropEffects.Move; dragInfo.Data = PrzenoszonyObiekt = dragInfo.SourceItem; KolekcjaŹródłowa = (IList)dragInfo.SourceCollection; IndeksŹródłowy = dragInfo.SourceIndex; KolekcjaŹródłowa[0] = null; }
void IDragSource.DragDropOperationFinished(DragDropEffects operationResult, IDragInfo dragInfo) { //if (operationResult != DragDropEffects.None) //{ // ReloadGroups(); //Model.IsUnsaved = true; // Is this needed? //} }
bool IDragSource.CanStartDrag(IDragInfo dragInfo) { if (dragInfo.SourceIndex > 4) { return(true); } return(false); }
public DropInfo(object sender, DragEventArgs e, IDragInfo dragInfo, string dataFormat) { Data = e.Data.GetDataPresent(dataFormat) ? e.Data.GetData(dataFormat) : e.Data; DragInfo = dragInfo; VisualTarget = sender as UIElement; InitializeFromSender(sender, e); }
void IDragSource.StartDrag(IDragInfo dragInfo) { Log.Info("StartDrag"); _mementoService.BeginBatch("Drag & Drop"); dragInfo.Effects = DragDropEffects.Move | DragDropEffects.Copy; dragInfo.Data = dragInfo.SourceItems; }
public void StartDrag(IDragInfo dragInfo) { if (item.SupportsDragDrop) { dragInfo.Data = new DragData(item); dragInfo.Effects = DragDropEffects.Move; } }
public void StartDrag(IDragInfo dragInfo) { DragDrop.DefaultDragHandler.StartDrag(dragInfo); var dragDropInfo = _itemsProvider.PrepareDropInfo(dragInfo.SourceItems); _itemsProvider.PrepareDragLayout(dragDropInfo.DraggingItems); dragInfo.Data = dragDropInfo.DraggingItems.SelectMany(it => it).ToList(); _droppingItems = dragDropInfo.DroppingItems; }
/// <summary> /// Queries whether a drag can be started /// </summary> /// <param name="dragInfo"> /// Information about the drag. /// </param> /// <remarks> /// To allow a drag to be started, the <see cref="IDragInfo.Effects"/> property on <paramref name="dragInfo"/> /// should be set to a value other than <see cref="DragDropEffects.None"/>. /// </remarks> public override void StartDrag(IDragInfo dragInfo) { var scale = this.Thing is QuantityKind quantityKind ? quantityKind.DefaultScale : null; var payload = new Tuple <ParameterType, MeasurementScale>(this.Thing, scale); dragInfo.Payload = payload; dragInfo.Effects = DragDropEffects.Copy; }
public Type GetHintAdorner(IDragInfo dragInfo) { if (!CanHandleData(dragInfo.Data)) { return(null); } return(typeof(DropTargetInactiveHintAdorner)); }
/// <summary> /// Event handler for the <see cref="PreviewMouseLeftButtonUp"/> event /// </summary> /// <remarks> /// Occurs when the left mouse button is released while the mouse pointer is over this element. /// </remarks> /// <param name="sender">the sender of the event</param> /// <param name="e">the <see cref="MouseButtonEventArgs"/> associated to the event</param> private void PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (!(e.Source is Thing)) { return; } this.dragInfo = null; }
/// <summary> /// Queries whether a drag can be started /// </summary> /// <param name="dragInfo"> /// Information about the drag. /// </param> /// <remarks> /// To allow a drag to be started, the <see cref="IDragInfo.Effects"/> property on <paramref name="dragInfo"/> /// should be set to a value other than <see cref="DragDropEffects.None"/>. /// </remarks> public virtual void StartDrag(IDragInfo dragInfo) { var dragSource = dragInfo.Payload as IDragSource; if (dragSource != null) { dragSource.StartDrag(dragInfo); } }
public void StartDrag(IDragInfo dragInfo) { var game = _game; if (game == null) { return; } game.StartDrag(new HandleableDragInfo(dragInfo)); }
public bool CanStartDrag(IDragInfo dragInfo) { // so here is the magic if (dragInfo != null) { if ((dragInfo.SourceIndex % 2) == 0) { return false; } } return true; }
public void StartDrag(IDragInfo dragInfo) { var result = _parentControl.AvailableItems_StartDrag?.Invoke(dragInfo.SourceItems); if (null != result) { dragInfo.Effects = GuiHelper.ConvertCopyMoveToDragDropEffect(result.Value.CanCopy, result.Value.CanMove); dragInfo.Data = result.Value.Data; } }
/// <summary> /// Event handler for the <see cref="PreviewMouseLeftButtonDown"/> event /// </summary> /// <remarks> /// Occurs when the left mouse button is pressed while the mouse pointer is over this element. /// </remarks> /// <param name="sender">the sender of the event</param> /// <param name="e">the <see cref="MouseButtonEventArgs"/> associated to the event</param> private void PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (e.ClickCount != 1 || VisualTreeExtensions.HitTestScrollBar(sender, e) || VisualTreeExtensions.HitTestGridColumnHeader(sender, e)) { this.dragInfo = null; return; } this.dragInfo = new DragInfo(sender, e); }
public void OnDrop(GameObject go) { if (DropEvent != null) { DropEvent(go); } mDraggedItem = null; isDragging = false; UpdateCursor(); }
public void StartDrag(IDragInfo dragInfo) { var item = dragInfo.VisualSource as WrapPanel; if (item != null) { dragInfo.Effects = DragDropEffects.Copy; var hitItem = VisualTreeHelper.HitTest(item, dragInfo.PositionInDraggedItem); dragInfo.Data = hitItem.VisualHit as Image; } }
public void StartDrag(IDragInfo dragInfo) { Altaxo.Serialization.Clipboard.IDataObject dao; bool canCopy, canMove; _projectBrowseControl._controller.FolderTree_StartDrag(out dao, out canCopy, out canMove); dragInfo.Effects = GuiHelper.ConvertCopyMoveToDragDropEffect(canCopy, canMove); if (null != dao) dragInfo.DataObject = GuiHelper.ToWpf(dao); }
public virtual void StartDrag(IDragInfo dragInfo) { int itemCount = dragInfo.SourceItems.Cast<object>().Count(); if (itemCount == 1) dragInfo.Data = dragInfo.SourceItems.Cast<object>().First(); else if (itemCount > 1) dragInfo.Data = TypeUtilities.CreateDynamicallyTypedList(dragInfo.SourceItems); dragInfo.Effects = (dragInfo.Data != null) ? DragDropEffects.Copy | DragDropEffects.Move : DragDropEffects.None; }
public override void StartDrag(IDragInfo dragInfo) { if (dragInfo.SourceItem != null) { if (dragInfo.SourceItem.GetType() == typeof (CategoryNode)) { dragInfo.Effects = DragDropEffects.None; } else { base.StartDrag(dragInfo); dragInfo.Data = Activator.CreateInstance(dragInfo.SourceItem as Type); } } }
public override void StartDrag(IDragInfo dragInfo) { var itemCount = dragInfo.SourceItems.Cast<object>().Count(); if (itemCount == 1) { IOperationViewModel operationViewModel = dragInfo.SourceItems.Cast<IOperationViewModel>().First(); ITestItemViewModel testItemViewModel = testItemViewModelFactory.Create(operationViewModel.GetNewTestItem()); dragInfo.Data = testItemViewModel; } dragInfo.Effects = (dragInfo.Data != null) ? DragDropEffects.Copy | DragDropEffects.Move : DragDropEffects.None; }
public virtual void StartDrag(IDragInfo dragInfo) { var itemCount = dragInfo.SourceItems.Cast<object>().Count(); if (itemCount == 1) { dragInfo.Data = dragInfo.SourceItems.Cast<object>().First(); } else if (itemCount > 1) { dragInfo.Data = dragInfo.SourceItems; } if (dragInfo.Data == null) dragInfo.AllowedEffects = DragDropEffects.None; else dragInfo.AllowedEffects = DragDropEffects.Copy | DragDropEffects.Move; }
public override void StartDrag(IDragInfo dragInfo) { if (dragInfo.SourceItem != null) { if (dragInfo.SourceItem.GetType() == typeof (WebTestScenario)) { dragInfo.Effects = DragDropEffects.None; } else { _testCase = dragInfo.SourceItem as TestCase; if (_testCase != null) { TestScenario scenario = _testCase.Scenario; scenario.Manager.BeginChangeSetBatch("Drag and Drop"); } base.StartDrag(dragInfo); } } }
public void StartDrag(IDragInfo dragInfo) { if (dragInfo.SourceItem as IADOTabularObject != null) { dragInfo.Data = ((IADOTabularObject)dragInfo.SourceItem).DaxName; dragInfo.DataObject = new DataObject(typeof(string), ((IADOTabularObject)dragInfo.SourceItem).DaxName); dragInfo.Effects = DragDropEffects.Move; } else { dragInfo.Effects = DragDropEffects.None; } }
public bool CanStartDrag(IDragInfo dragInfo) { return true; // throw new System.NotImplementedException(); }
public void StartDrag(IDragInfo dragInfo) { if(dragInfo.SourceItem is PersonViewModel) { dragInfo.Data = new DragDropContainer(dragInfo.SourceItem); dragInfo.Effects = System.Windows.DragDropEffects.Copy | System.Windows.DragDropEffects.Move; } }
public bool CanStartDrag(IDragInfo dragInfo) { return DragDrop.DefaultDragHandler.CanStartDrag(dragInfo); }
public bool CanStartDrag(IDragInfo dragInfo) { return _projectBrowseControl._controller.AvailableItems_CanStartDrag(dragInfo.SourceItems); }
public void StartDrag(IDragInfo dragInfo) { DragDrop.DefaultDragHandler.StartDrag(dragInfo); }
bool IDragSource.CanStartDrag(IDragInfo dragInfo) { if (dragInfo.SourceItem is PredicateNode) return true; return false; }
public bool CanStartDrag(IDragInfo dragInfo) { return _projectBrowseControl._controller.ItemList_CanStartDrag(); }
public bool CanStartDrag(IDragInfo dragInfo) { return _projectBrowseControl._controller.FolderTree_CanStartDrag(); }
void IDragSource.StartDrag(IDragInfo dragInfo) { dragInfo.AllowedEffects = DragDropEffects.Move; dragInfo.Data = dragInfo.SourceItem; }
public virtual void StartDrag(IDragInfo dragInfo) { // nothing special here, use the default way DragDrop.DefaultDragHandler.StartDrag(dragInfo); }
//ドラッグ開始 void IDragSource.StartDrag(IDragInfo dragInfo) { dragInfo.Data = SelectedItem; dragInfo.Effects = System.Windows.DragDropEffects.All; }
bool IDragSource.CanStartDrag(IDragInfo dragInfo) { return true; }
public void StartDrag(IDragInfo dragInfo) { object data; bool canCopy, canMove; _projectBrowseControl._controller.AvailableItems_StartDrag(dragInfo.SourceItems, out data, out canCopy, out canMove); dragInfo.Effects = GuiHelper.ConvertCopyMoveToDragDropEffect(canCopy, canMove); dragInfo.Data = data; }
public void StartDrag(IDragInfo dragInfo) { try { var selectedVideo = (JdownloaderVideo)dragInfo.SourceItem; dragInfo.Effects = DragDropEffects.Copy | DragDropEffects.Move; dragInfo.Data = selectedVideo; } catch (Exception error) { MessageBox.Show(error.ToString()); } }
public void StartDrag(IDragInfo dragInfo) { //Console.WriteLine("Starting Drag"); dragInfo.Data = this; dragInfo.Effects = System.Windows.DragDropEffects.Move; }
/// <summary> /// Determines whether this instance [can start drag] the specified drag information. /// </summary> /// <param name="dragInfo">The drag information.</param> /// <returns></returns> public virtual bool CanStartDrag(IDragInfo dragInfo) { return true; }
public void StartDrag(IDragInfo dragInfo) { if (dragInfo.SourceItem is ItemViewModel) { dragInfo.Data = dragInfo.SourceItem; dragInfo.Effects = System.Windows.DragDropEffects.Copy | System.Windows.DragDropEffects.Move; } }
public void StartDrag(IDragInfo dragInfo) { if (isLocked) return; dragInfo.Data = mixViewModel.SelectedItems; dragInfo.Effects = DragDropEffects.Move | DragDropEffects.Copy; }
public bool CanStartDrag(IDragInfo dragInfo) { return true; }
/// <summary> /// Initializes a new instance of the DropInfo class. /// </summary> /// /// <param name="sender"> /// The sender of the drag event. /// </param> /// /// <param name="e"> /// The drag event. /// </param> /// /// <param name="dragInfo"> /// Information about the source of the drag, if the drag came from within the framework. /// </param> public DropInfo(object sender, DragEventArgs e, IDragInfo dragInfo) { var dataFormat = SquaredInfinity.Foundation.Presentation.Behaviors.DragDrop.DataFormat.Name; Data = (e.Data.GetDataPresent(dataFormat)) ? e.Data.GetData(dataFormat) : e.Data; DragInfo = dragInfo; KeyStates = e.KeyStates; AllowedEffects = e.Effects; if (AllowedEffects.HasFlag(DragDropEffects.Copy) && Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) ActualDropEffect = DragDropEffects.Copy; else ActualDropEffect = DragDropEffects.Move; VisualTarget = sender as UIElement; // if drop target isn't a ItemsControl if (!(VisualTarget is ItemsControl)) { // try to find next ItemsControl var itemsControl = VisualTarget.FindVisualParent<ItemsControl>(); if (itemsControl != null) { // now check if this ItemsControl is a drop target if (SquaredInfinity.Foundation.Presentation.Behaviors.DragDrop.GetIsDropTarget(itemsControl)) { VisualTarget = itemsControl; } } } // visual target can be null, so give us a point... this.DropPosition = this.VisualTarget != null ? e.GetPosition(this.VisualTarget) : new Point(); if (this.VisualTarget is ItemsControl) { var itemsControl = (ItemsControl)this.VisualTarget; var itemContainer = itemsControl.GetItemContainerAt(this.DropPosition); var directlyOverItem = itemContainer != null; this.TargetGroup = this.FindGroup(itemsControl, this.DropPosition); this.VisualTargetOrientation = itemsControl.GetItemsPanelOrientation(); this.VisualTargetFlowDirection = itemsControl.GetItemsPanelFlowDirection(); if (itemContainer == null) { itemContainer = itemsControl.GetItemContainerAt(this.DropPosition, this.VisualTargetOrientation); directlyOverItem = false; } if (itemContainer != null) { var itemParent = ItemsControl.ItemsControlFromItemContainer(itemContainer); InsertIndex = itemParent.ItemContainerGenerator.IndexFromContainer(itemContainer); TargetCollection = itemParent.ItemsSource ?? itemParent.Items.SourceCollection; var rawItem = itemParent.ItemContainerGenerator.ItemFromContainer(itemContainer); RawTargetCollection = itemParent.GetRawUnderlyingCollection(); var targetList = RawTargetCollection as IList; if(targetList != null) RawInsertIndex = targetList.IndexOf(rawItem); if (directlyOverItem || typeof(TreeViewItem).IsAssignableFrom(itemContainer.GetType())) { TargetItem = itemParent.ItemContainerGenerator.ItemFromContainer(itemContainer); VisualTargetItem = itemContainer; } var itemRenderSize = itemContainer.RenderSize; if (VisualTargetOrientation == Orientation.Vertical) { var currentYPos = e.GetPosition(itemContainer).Y; var targetHeight = itemRenderSize.Height; if (currentYPos > targetHeight / 2) { InsertIndex++; RawInsertIndex++; InsertPosition = RelativeInsertPosition.AfterTargetItem; } else { InsertPosition = RelativeInsertPosition.BeforeTargetItem; } if (currentYPos > targetHeight * 0.25 && currentYPos < targetHeight * 0.75) { InsertPosition |= RelativeInsertPosition.TargetItemCenter; } } else { var currentXPos = e.GetPosition(itemContainer).X; var targetWidth = itemRenderSize.Width; if ((VisualTargetFlowDirection == FlowDirection.RightToLeft && currentXPos < targetWidth / 2) || (VisualTargetFlowDirection == FlowDirection.LeftToRight && currentXPos > targetWidth / 2)) { InsertIndex++; RawInsertIndex++; InsertPosition = RelativeInsertPosition.AfterTargetItem; } else { InsertPosition = RelativeInsertPosition.BeforeTargetItem; } if (currentXPos > targetWidth * 0.25 && currentXPos < targetWidth * 0.75) { InsertPosition |= RelativeInsertPosition.TargetItemCenter; } } } else { TargetCollection = itemsControl.ItemsSource ?? itemsControl.Items.SourceCollection; RawTargetCollection = TargetCollection; bool insert_at_the_end = false; // no item under mouse, // test if we are at the begining or end of target item control // and based on that position make insertion either as a first or last item if (VisualTargetOrientation == Orientation.Vertical) { if (DropPosition.Y > 5) insert_at_the_end = true; } else { if (DropPosition.X > 5) insert_at_the_end = true; } if(insert_at_the_end) { InsertIndex = itemsControl.Items.Count; RawInsertIndex = itemsControl.Items.Count; } else { InsertIndex = 0; RawInsertIndex = 0; } } } }
public void StartDrag(IDragInfo dragInfo) { }
public void StartDrag(IDragInfo dragInfo) { dragInfo.Data = SelectedItems; dragInfo.Effects = DragDropEffects.Move | DragDropEffects.Copy; }