private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { TreeViewDragDropOptions options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions; if (options == null) { return; } var draggedItem = options.DraggedItems.Cast <ProductViewModel>().ToList(); if (draggedItem == null) { return; } if (e.Effects != DragDropEffects.None) { var collection = (sender as System.Windows.Controls.ListBox).ItemsSource as IList; foreach (var s in draggedItem) { collection.Add(s); } } e.Handled = true; }
private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { EstimateDetails draggedItem = (EstimateDetails)DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData"); var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails; var currentRow = e.OriginalSource as GridViewRow ?? (e.OriginalSource as FrameworkElement).ParentOfType <GridViewRow>(); EstimateDetails targetItem = currentRow != null ? (EstimateDetails)currentRow.Item : null; if (details == null || draggedItem == null || currentRow == null || targetItem == null) { return; } var draggedItemAreaId = draggedItem.NonstandardCategoryID > 0 ? draggedItem.NonstandardCategoryID : draggedItem.AreaId; var targetItemAreaId = targetItem.NonstandardCategoryID > 0 ? targetItem.NonstandardCategoryID : targetItem.AreaId; if ((draggedItemAreaId == targetItemAreaId) && (draggedItem.EstimateRevisionDetailsId != targetItem.EstimateRevisionDetailsId)) { var collection = (sender as RadGridView).ItemsSource as IList; collection.Remove(draggedItem); collection.Insert((sender as RadGridView).Items.IndexOf(currentRow.Item), draggedItem); RetailSystemClient mrsClient = new RetailSystemClient(); mrsClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(Internal.Utilities.GetMetriconRetailSystemWcfClientEndpointUrl()); mrsClient.MoveEstimateDetailItemCompleted += new EventHandler <MoveEstimateDetailItemCompletedEventArgs>(mrsClient_MoveEstimateDetailItemCompleted); mrsClient.MoveEstimateDetailItemAsync(draggedItem.EstimateRevisionDetailsId, targetItem.EstimateRevisionDetailsId, (App.Current as App).CurrentUserId); } else { } e.Handled = true; }
private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { object sourceItem = DragDropPayloadManager.GetDataFromObject(e.Data, __dragSource); TreeListViewRow destinationRow = (e.OriginalSource as TreeListViewRow) ?? (e.OriginalSource as FrameworkElement).ParentOfType <TreeListViewRow>(); GridViewScrollViewer destinationTree = (e.OriginalSource as GridViewScrollViewer) ?? (e.OriginalSource as FrameworkElement).ParentOfType <GridViewScrollViewer>(); if (destinationRow != null && destinationRow.Item != sourceItem) { e.Effects = !IsChildOf(destinationRow, sourceItem) ? DragDropEffects.Move : DragDropEffects.None; if (e.Effects == DragDropEffects.Move) { DragDropPayloadManager.SetData(e.Data, __dragTarget, destinationRow.Item); } } else if (destinationTree != null) { DragDropPayloadManager.SetData(e.Data, __dragTarget, string.Empty); } else { e.Effects = DragDropEffects.None; } e.Handled = true; }
private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var data = (IList)DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData"); if (data == null) { return; } if (e.Effects != DragDropEffects.None) { var destinationItem = (e.OriginalSource as FrameworkElement).ParentOfType <RadTreeViewItem>(); var dropDetails = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails; if (destinationItems != null) { var backup = new Backup(); for (int i = 0; i < dropDetails.CurrentDraggedItem.Count; i++) { var source = (dropDetails.CurrentDraggedItem[i] as ProductViewModel); var dest = (dropDetails.CurrentDraggedOverItem as ProductViewModel); string sourcePath = System.IO.Path.GetDirectoryName(source.FullPath); if (destinationItems.Count == 0) { RadTreeView_LoadOnDemand(null, e); } backup.CopyFile(sourcePath, dest.FullPath, source.Name); int dropIndex = dropDetails.DropIndex >= destinationItems.Count ? destinationItems.Count : dropDetails.DropIndex < 0 ? 0 : dropDetails.DropIndex; this.destinationItems.Insert(dropIndex, data[i]); } } } }
private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { TreeViewDragDropOptions options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions; if (options == null) { e.Effects = DragDropEffects.None; e.Handled = true; return; } var draggedItem = options.DraggedItems.FirstOrDefault(); var itemsType = (this.AssociatedObject.ItemsSource as IList).AsQueryable().ElementType; if (draggedItem.GetType() != itemsType) { e.Effects = DragDropEffects.None; } else { (options.DragVisual as TreeViewDragVisual).IsDropPossible = true; options.DropAction = DropAction.Move; options.UpdateDragVisual(); } e.Handled = true; }
private void OnApplicationTreeDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions; if (options == null) { return; } // The condition after the first OR operator is needed to deny the drop of items in Application File. (sub-items) RadTreeViewItem dropTargetItem = options.DropTargetItem; var draggedItem = options.DraggedItems.First(); if (dropTargetItem == null || (dropTargetItem != null && options.DropTargetItem.DataContext is Resource && options.DropPosition == DropPosition.Inside) || draggedItem is PartitionViewModel) { options.DropAction = DropAction.None; } options.UpdateDragVisual(); }
private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedItem"); var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails; if (details == null || draggedItem == null) { return; } if (e.Effects == DragDropEffects.Move || e.Effects == DragDropEffects.All) { ((sender as RadGridView).ItemsSource as IList).Remove(draggedItem); } if (e.Effects != DragDropEffects.None) { var collection = (sender as RadGridView).ItemsSource as IList; int index = details.DropIndex < 0 ? 0 : details.DropIndex; index = details.DropIndex > collection.Count - 1 ? collection.Count : index; collection.Insert(index, draggedItem); } HideDropPositionFeedbackPresenter(); }
private void OnRowDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var row = sender as GridViewRow; var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails; 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 OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var data = DragDropPayloadManager.GetDataFromObject(e.Data, typeof(string).FullName); ((IList)(sender as RadListBox).ItemsSource).Add(data); DragDropPayloadManager.SetData(e.Data, "IsDropSuccessful", true); 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; dropDetails.IsValidDrop = true; 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; dropDetails.IsValidDrop = false; } else { e.Effects = DragDropEffects.All; dropDetails.DropIndex = index; dropDetails.IsValidDrop = true; } } dropDetails.CurrentDraggedOverItem = item.Item; dropDetails.CurrentDropPosition = position; e.Handled = true; }
private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var text = DragDropPayloadManager.GetDataFromObject(e.Data, "Text") as string; if (text != null) { (sender as TextBox).Text += text; } }
private void OnDragDropCompleted(object sender, DragDropCompletedEventArgs e) { var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData"); if (e.Effects != DragDropEffects.None) { var collection = (sender as RadGridView).ItemsSource as IList; collection.Remove(draggedItem); } }
private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions; if (options.DropPosition != Telerik.Windows.Controls.DropPosition.Inside) { options.DropPosition = Telerik.Windows.Controls.DropPosition.Inside; options.UpdateDragVisual(); } }
// Forbids the local machine tree view to drop anything private void OnLocalMachineTreeDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions; if (options != null) { options.DropAction = DropAction.None; options.UpdateDragVisual(); e.Handled = true; } }
private void OnDragDropCompleted(object sender, DragDropCompletedEventArgs e) { var isDropSuccessful = DragDropPayloadManager.GetDataFromObject(e.Data, "IsDropSuccessful"); if (isDropSuccessful != null && (bool)isDropSuccessful) { var data = DragDropPayloadManager.GetDataFromObject(e.Data, "DragData"); ((IList)(sender as RadListBox).ItemsSource).Remove(data); } e.Handled = true; }
private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var text = DragDropPayloadManager.GetDataFromObject(e.Data, "Text") as string; var listBox = sender as ListBox; if (text != null && listBox != null) { (listBox.ItemsSource as IList).Add(new MyObject() { ID = ListBoxDragDropBehavior.lastAdded++, Name = text }); } }
private void OnTreeViewDragInitialize(object sender, DragInitializeEventArgs e) { var options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions; if (options != null) { bool canDrag = options.DraggedItems.OfType <DataItem>().Any(x => x.CanDrag); if (!canDrag) { e.Data = null; e.DragVisual = null; } } }
private void OnDragDropCompleted(object sender, DragDropCompletedEventArgs args) { var data = DragDropPayloadManager.GetDataFromObject(args.Data, "DragData"); var param = new DragDropParameter { DraggedItem = data, ItemsSource = this.AssociatedObject.ItemsSource }; if (this.DragCommand != null && this.DragCommand.CanExecute(param)) { this.DragCommand.Execute(param); } }
private void OnDragOverTree(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions; if (options != null && options.DropPosition == Telerik.Windows.Controls.DropPosition.Inside && options.DropTargetItem != null && options.DropTargetItem.Item is Division) { options.DropAction = DropAction.None; var dragVisual = options.DragVisual as TreeViewDragVisual; if (dragVisual != null) { dragVisual.IsDropPossible = false; dragVisual.DropActionText = "Cannot drop into "; } } }
private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var item = e.OriginalSource as RadListBoxItem ?? (e.OriginalSource as FrameworkElement).ParentOfType <RadListBoxItem>(); var listBox = sender as RadListBox; if (item != null && listBox != null) { var targetColumn = item.DataContext as GridViewColumn; var draggedColumn = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedColumn") as GridViewDataColumn; draggedColumn.DisplayIndex = targetColumn.DisplayIndex; RebindListBox(); } }
private void OnDragOver(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData"); var itemsType = (this.AssociatedObject.ItemsSource as IList).AsQueryable().ElementType; if (draggedItem.GetType() != itemsType) { e.Effects = DragDropEffects.None; } //var dropDetails = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails; //dropDetails.CurrentDraggedOverItem = this.AssociatedObject; //dropDetails.CurrentDropPosition = Controls.DropPosition.Inside; e.Handled = true; }
private void OnTimelineDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var position = e.GetPosition(this.timeline); var dataItem = (ITimelineItem)DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedItem"); var source = (IList)this.timeline.ItemsSource; var itemIndex = source.IndexOf(dataItem); var groupUnderMouse = GetGroupUnderMouse(position); var rowIndex = GetRowUnderMouse(position, groupUnderMouse); source.Remove(dataItem); dataItem.GroupKey = groupUnderMouse.Key; dataItem.RowIndex = rowIndex; dataItem.StartDate = this.timeline.ConvertPointToDateTime(position); source.Insert(itemIndex, dataItem); }
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 OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { if (e.Data != null && e.AllowedEffects != DragDropEffects.None) { SecureObject sourceItem = DragDropPayloadManager.GetDataFromObject(e.Data, __dragSource) as SecureObject; SecureObject targetItem = DragDropPayloadManager.GetDataFromObject(e.Data, __dragTarget) as SecureObject; IList <SecureObject> storeList = AssociatedTreeListView.DataContext as IList <SecureObject>; if (sourceItem != null && storeList != null) { sourceItem.ChangeParent(targetItem, storeList); } if (targetItem == null) { AssociatedTreeListView.Rebind(); } } }
private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs args) { 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; richTextBox.CurrentEditingStyle.SpanProperties.ForeColor = Colors.Red; Dispatcher.BeginInvoke(new Action(delegate() { mainEditor.Focus(); richTextBox.Insert(payloadData); })); }
private void OnDragDropCompleted(object sender, DragDropCompletedEventArgs e) { Debug.WriteLine("GridViewDragDropBehavior.OnDragDropCompleted: {0}", e.Effects); var data = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData") as IList; var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails"); Debug.WriteLine(e.Effects); // Remove Element from source list if drag drop effect is move /*if (e.Effects == DragDropEffects.Move) * { * var collection = (details as DropIndicationDetails).DragSource as IList; * foreach(var element in data) * { * collection.Remove(element); * } * }*/ }
/// <summary> /// Initialize directory dragging /// </summary> /// <param name="sener"></param> /// <param name="e"></param> private static void OnDraginitialize(object sener, Telerik.Windows.DragDrop.DragInitializeEventArgs e) { var options = DragDropPayloadManager.GetDataFromObject(e.Data, TreeViewDragDropOptions.Key) as TreeViewDragDropOptions; bool isProtected = false; //Check if there is any child of the item protected var draggedDirectory = options.DraggedItems.OfType <DirectoryViewModel>().FirstOrDefault(); var guids = new List <Guid>(); var directoriesToCheck = new List <DirectoryViewModel>(); directoriesToCheck.Add(draggedDirectory); while (directoriesToCheck.Any()) { var innerDirectories = new List <DirectoryViewModel>(); foreach (var subDirectory in directoriesToCheck) { guids.Add(subDirectory.Model.Id); innerDirectories.AddRange(subDirectory.Directories); } directoriesToCheck.Clear(); directoriesToCheck.AddRange(innerDirectories); } if (fileStructureDocumentPathService.IsProtected(guids)) { MessageBox.Show(localizationService.Translate("filestructure_drag_protected"), localizationService.Translate("filestructure_delete_notallowed_title"), MessageBoxButton.OK, MessageBoxImage.Information); e.Data = null; e.DragVisual = null; e.Handled = true; } //Checks if the folder is assigned to a workflow if (draggedDirectory.Model.WorkflowId.HasValue) { MessageBox.Show(localizationService.Translate("filestructure_drag_protected_workflow"), localizationService.Translate("filestructure_delete_notallowed_title"), MessageBoxButton.OK, MessageBoxImage.Information); e.Data = null; e.DragVisual = null; e.Handled = true; } }
private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var draggedItem = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData"); var itemsType = (this.AssociatedObject.ItemsSource as IList).AsQueryable().ElementType; //var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails; //if (details == null || draggedItem == null || draggedItem.GetType() != itemsType) { // return; } if (e.Effects != DragDropEffects.None) { var collection = (sender as RadGridView).ItemsSource as IList; collection.Add(draggedItem); } e.Handled = true; }
private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { var data = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData"); if (data == null) { return; } if (e.Effects != DragDropEffects.None) { var destinationItem = (e.OriginalSource as FrameworkElement).ParentOfType <RadTreeViewItem>(); var dropDetails = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails; if (destinationItems != null) { int dropIndex = dropDetails.DropIndex >= destinationItems.Count ? destinationItems.Count : dropDetails.DropIndex < 0 ? 0 : dropDetails.DropIndex; this.destinationItems.Insert(dropIndex, data); } } }
private void OnDrop(object sender, Telerik.Windows.DragDrop.DragEventArgs e) { Debug.WriteLine("TreeItemDropBehavior.OnDrop: {0}", e.Effects); if (e.Effects != DragDropEffects.None) { var destinationItem = (e.OriginalSource as FrameworkElement).ParentOfType <RadTreeViewItem>(); var data = DragDropPayloadManager.GetDataFromObject(e.Data, "DraggedData") as IList; var details = DragDropPayloadManager.GetDataFromObject(e.Data, "DropDetails") as DropIndicationDetails; if (destinationItem != null) { foreach (var element in data) { (destinationItem.DataContext as Folder).Elements.Add(element as Element); } e.Handled = true; } } }