/// <summary> /// Called when an items has been dropped on the surface. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="Telerik.Windows.DragDrop.DragEventArgs"/> instance containing the event data.</param> private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { diagram.SelectedIndex = -1; // this offset is necessary when multiple items are dropped at one; it keeps them separate though the same drop point is given var offset = 0; #if WPF if (e.Data == null || !(e.Data is DataObject)) return; var droppedClassViewModels = (e.Data as DataObject).GetData(treeView.SelectedItems.GetType()) as IEnumerable; #else if (e.Data == null || !(e.Data is IEnumerable)) return; var droppedClassViewModels = e.Data as IEnumerable; #endif if (droppedClassViewModels == null) return; foreach (var viewModel in droppedClassViewModels) { var classViewModel = viewModel as ClassViewModel; var currentPosition = diagram.GetTransformedPoint(e.GetPosition(diagram)); if (classViewModel != null) { this.AddNewItemToDiagram(classViewModel, currentPosition, ref offset); } else { var namespaceViewModel = viewModel as NamespaceViewModel; foreach (var type in namespaceViewModel.Types) this.AddNewItemToDiagram(type, currentPosition, ref offset); } } e.Handled = true; }
private void OnItemDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var item = (e.OriginalSource as FrameworkElement).ParentOfType<RadTreeViewItem>(); if (item == null) { e.Effects = DragDropEffects.None; e.Handled = true; return; } var position = GetPosition(item, e.GetPosition(item)); if (item.Level == 0 && position != DropPosition.Inside) { e.Effects = DragDropEffects.None; e.Handled = true; return; } RadTreeView tree = sender as RadTreeView; var draggedData = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData"); var dropDetails = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails; if ((draggedData == null && dropDetails == null)) { return; } if (position != DropPosition.Inside) { e.Effects = DragDropEffects.All; destinationItems = item.Level > 0 ? (IList)item.ParentItem.ItemsSource : (IList)tree.ItemsSource; int index = destinationItems.IndexOf(item.Item); dropDetails.DropIndex = position == DropPosition.Before ? index : index + 1; } else { destinationItems = (IList)item.ItemsSource; int index = 0; if (destinationItems == null) { e.Effects = DragDropEffects.None; } else { e.Effects = DragDropEffects.All; dropDetails.DropIndex = index; } } dropDetails.CurrentDraggedOverItem = item.Item; dropDetails.CurrentDropPosition = position; e.Handled = true; }
private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs args) { dropPosition.Visibility = Visibility.Collapsed; string payloadData = DragDropPayloadManager.GetDataFromObject(args.Data, "DragData") as string; if (string.IsNullOrEmpty(payloadData)) { return; } RadRichTextBox mainEditor = sender as RadRichTextBox; RadRichTextBox richTextBox = mainEditor.ActiveDocumentEditor as RadRichTextBox; Point point = args.GetPosition(richTextBox); DocumentPosition pos = richTextBox.ActiveEditorPresenter.GetDocumentPositionFromViewPoint(point); richTextBox.Document.CaretPosition.MoveToPosition(pos); }
private void OnElementDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { this.currentDragPosition = e.GetPosition(this.itemsHost); }
private void OnRowDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var row = sender as GridViewRow; var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as GridRowIndicationDetail; if (details == null || row == null) { return; } details.CurrentDraggedOverItem = row.DataContext; if (details.CurrentDraggedItem == details.CurrentDraggedOverItem) { e.Effects = DragDropEffects.None; e.Handled = true; return; } details.CurrentDropPosition = GetDropPositionFromPoint(e.GetPosition(row), row); int dropIndex = (this.AssociatedObject.Items as IList).IndexOf(row.DataContext); int draggedItemIdex = (this.AssociatedObject.Items as IList).IndexOf(DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedItem")); if (dropIndex >= row.GridViewDataControl.Items.Count - 1 && details.CurrentDropPosition == DropPosition.After) { details.DropIndex = dropIndex; return; } dropIndex = draggedItemIdex > dropIndex ? dropIndex : dropIndex - 1; details.DropIndex = details.CurrentDropPosition == DropPosition.Before ? dropIndex : dropIndex + 1; }
private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var position = e.GetPosition(sender as Canvas); Canvas.SetTop(this.draggedImage, position.Y - this.relativeStartPoint.Y); Canvas.SetLeft(this.draggedImage, position.X - this.relativeStartPoint.X); }
private void OnItemDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var draggedData = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData"); var dropDetails = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails; var item = (e.OriginalSource as FrameworkElement).ParentOfType<RadTreeViewItem>(); var position = GetPosition(item, e.GetPosition(item)); if (position != DropPosition.Inside) { e.Effects = DragDropEffects.All; this.destinationItems = item.Level > 0 ? (IList)item.ParentItem.ItemsSource : (IList)this.AssociatedObject.ItemsSource; //(IList)item.ParentItem.ItemsSource != null ? (IList)item.ParentItem.ItemsSource : (IList)this.AssociatedObject.ItemsSource; int index = this.destinationItems.IndexOf(item.Item); dropDetails.DropIndex = position == DropPosition.Before ? index : index + 1; } else { this.destinationItems = (IList)item.ItemsSource; int index = 0; if (this.destinationItems == null) { e.Effects = DragDropEffects.None; } else { e.Effects = DragDropEffects.All; dropDetails.DropIndex = index; } } dropDetails.CurrentDraggedOverItem = item.Item; dropDetails.CurrentDropPosition = position; if (this.isTreeSource && this.IsChildOfSource(item)) { e.Effects = DragDropEffects.None; } e.Handled = true; }
private static void TrayDropped(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { RadToolBarTray destinationTray = sender as RadToolBarTray; DragDropInfo info = GetDragDropInfo(e.Data); if (destinationTray == null || info == null) { return; } var positionInfo = BandsUtilities.CalculateToolBarPositionInfo(info.ToolBar, destinationTray, e.GetPosition(destinationTray)); if (!destinationTray.Items.Contains(info.ToolBar)) { MoveToolBarToTray(info, destinationTray); } bool allowNewBandCreation = GetNewBandMode(destinationTray) != NewBandMode.None; BandsUtilities.UpdateToolBarPosition(destinationTray, info.ToolBar, positionInfo, allowNewBandCreation); ClearHitTesting(destinationTray.Items); HideNewBandIndicator(destinationTray); e.Handled = true; }
private static void TrayDraggedOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { RadToolBarTray tray = sender as RadToolBarTray; DragDropInfo info = GetDragDropInfo(e.Data); if (tray == null || info == null) { return; } var positionInfo = BandsUtilities.CalculateToolBarPositionInfo(info.ToolBar, tray, e.GetPosition(tray)); bool allowNewBandCreation = GetNewBandMode(tray) == NewBandMode.Live; BandsUtilities.UpdateToolBarPosition(tray, info.ToolBar, positionInfo, allowNewBandCreation); UpdateNewBandIndicator(info, positionInfo, tray); }
private static void TrayDragEntered(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { RadToolBarTray tray = sender as RadToolBarTray; DragDropInfo info = GetDragDropInfo(e.Data); if (tray == null || info == null) { return; } lastInitializedInfo = null; if (!tray.Items.Contains(info.ToolBar)) { var positionInfo = BandsUtilities.CalculateToolBarPositionInfo(info.ToolBar, tray, e.GetPosition(tray)); MoveToolBarToTray(info, tray); bool allowNewBandCreation = GetNewBandMode(tray) == NewBandMode.Live; BandsUtilities.UpdateToolBarPosition(tray, info.ToolBar, positionInfo, allowNewBandCreation); UpdateNewBandIndicator(info, positionInfo, tray); SetHitTesting(tray.Items); } e.Handled = true; }