private void OnDropInfo(object sender, DragDropEventArgs e) { if (!(e.Options.Source is GridViewRow)) { return; } var gridView = e.Options.Destination as RadGridView; IEnumerable <object> draggedItems = e.Options.Payload as IEnumerable <object>; TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue; this.HideDropPositionFeedbackPresenter(); if (e.Options.Status == DragStatus.DropPossible) { this.UpdateDragCueContent(cue, gridView.Items[gridView.Items.Count - 1], "Move after: "); cue.IsDropPossible = true; } else if (e.Options.Status == DragStatus.DropImpossible) { cue.DragActionContent = null; cue.IsDropPossible = false; } else if (e.Options.Status == DragStatus.DropComplete) { ReorderingEventArgs reorderingArgs = new ReorderingEventArgs(gridView, draggedItems, gridView.Items.Count); this.OnReordering(reorderingArgs); this.TryReorderRows(reorderingArgs); this.OnReordered(new ReorderedEventArgs(gridView, draggedItems)); } e.Handled = true; }
private void ClearDragCueContent(TreeViewDragCue cue) { cue.DragTooltipContentTemplate = null; cue.DragActionContentTemplate = null; cue.DragTooltipContent = null; cue.DragActionContent = null; }
private void OnDragInfo(object sender, DragDropEventArgs e) { if (!(e.Options.Source is GridViewRow)) { return; } var gridView = sender as RadGridView; var draggedItems = e.Options.Payload as IEnumerable <object>; this.AssociatedObject.ReleaseMouseCapture(); if (e.Options.Status == DragStatus.DragInProgress) { this.dragCue = this.CreateDragCue(); this.dragCue.ItemsSource = draggedItems; e.Options.DragCue = this.dragCue; } else if (e.Options.Status == DragStatus.DragCancel) { //treeView.CancelDrag(); } else if (e.Options.Status == DragStatus.DragComplete) { } else if (e.Options.Status == DragStatus.DropImpossible) { // HIDE DROP INDICATOR } e.Handled = true; }
private void UpdateDragCueContent(TreeViewDragCue cue, object tooltipContent, object actionContent) { cue.Style = this.DragCueStyle; cue.DragTooltipContentTemplate = this.DragCueTooltipContentTemplate; cue.DragActionContentTemplate = this.DragCueActionContentTemplate; cue.ItemTemplate = this.DragCueItemTemplate; cue.DragTooltipContent = tooltipContent; cue.DragActionContent = actionContent; }
private TreeViewDragCue CreateDragCue() { var cue = new TreeViewDragCue(); cue.Style = this.DragCueStyle; cue.DragTooltipContentTemplate = this.DragCueTooltipContentTemplate; cue.DragActionContentTemplate = this.DragCueActionContentTemplate; cue.ItemTemplate = this.DragCueItemTemplate; return(cue); }
private void OnDragInfo(object sender, DragDropEventArgs e) { if (e.Options.Status == DragStatus.DragInProgress) { var draggedItem = e.Options.Payload as IDraggable; var cue = new TreeViewDragCue(); cue.ItemTemplate = ItemTemplate; var itemsSource = new List <IDraggable>(); itemsSource.Add(draggedItem); cue.ItemsSource = itemsSource; e.Options.DragCue = cue; } }
/// <summary> /// Create the Drag Cue for the Drag operation received as dependency property /// </summary> /// <returns>TreeViewDragCue object</returns> private TreeViewDragCue CreateDragCue() { var cue = new TreeViewDragCue(); cue.Style = this.DragCueStyle; cue.FontFamily = new FontFamily("Arial"); cue.Foreground = new SolidColorBrush(Colors.White); cue.Background = new SolidColorBrush(Color.FromArgb(255, 159, 29, 33)); cue.FontSize = 7; cue.DragTooltipContentTemplate = this.DragCueTooltipContentTemplate; cue.DragActionContentTemplate = this.DragCueActionContentTemplate; cue.ItemTemplate = this.DragCueItemTemplate; return(cue); }
/// <summary> /// On DropInfo /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnDropInfo(object sender, DragDropEventArgs e) { //Limit Drop Behavior to GridViewRow if (!(e.Options.Source is GridViewRow)) { return; } var gridView = e.Options.Destination as RadGridView; IEnumerable <object> draggedItems = e.Options.Payload as IEnumerable <object>; TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue; this.HideDropPositionFeedbackPresenter(); if (e.Options.Status == DragStatus.DropPossible) { if (gridView != null) { //if ((gridView.Items[gridView.Items.Count - 1] as MarketSnapshotPerformanceData).MarketSnapshotPreferenceInfo.EntityName == null) //{ // ContentControl destinationCue = new ContentControl(); // destinationCue.Content = "No Content in Group"; // e.Options.DestinationCue = destinationCue; //} this.UpdateDragCueContent(cue, gridView.Items[gridView.Items.Count - 1], "Move after: "); cue.IsDropPossible = true; } else { cue.IsDropPossible = false; } } else if (e.Options.Status == DragStatus.DropImpossible) { cue.DragActionContent = null; cue.IsDropPossible = false; } else if (e.Options.Status == DragStatus.DropComplete) { ReorderingEventArgs reorderingArgs = new ReorderingEventArgs(gridView, draggedItems, gridView.Items.Count); this.OnReordering(reorderingArgs); this.TryReorderRows(reorderingArgs); this.OnReordered(new ReorderedEventArgs(gridView, draggedItems)); } e.Handled = true; }
private void OnGridViewRowDropQuery(object sender, DragDropQueryEventArgs e) { this.AssociatedObject.ReleaseMouseCapture(); var row = sender as GridViewRow; var draggedItems = e.Options.Payload as IEnumerable <object>; TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue; if (e.Options.Status == DragStatus.DropDestinationQuery) { this.currentDropItem = row.Item; this.currentDropPosition = this.GetDropPositionFromPoint(e.Options.CurrentDragPoint, row); e.QueryResult = !draggedItems.Contains(this.currentDropItem); if (!e.QueryResult.Value) { this.ClearDragCueContent(cue); } } e.Handled = true; }
private void OnGridViewRowDropInfo(object sender, DragDropEventArgs e) { this.AssociatedObject.ReleaseMouseCapture(); var senderRow = (GridViewRow)sender; var gridView = senderRow.GridViewDataControl; IEnumerable <object> draggedItems = e.Options.Payload as IEnumerable <object>; TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue; if (e.Options.Status == DragStatus.DropPossible) { var currentRow = this.AssociatedObject.GetContainerFromDataItem((this.currentDropItem)) as GridViewRow; //if(currentRow == null) // cancel drag this.UpdateDragCueContent(cue, currentDropItem, String.Format("Move {0}: ", Enum.GetName(typeof(DropPosition), this.currentDropPosition)).ToLower(CultureInfo.InvariantCulture)); this.ShowDropPositionFeedbackPresenter(gridView, currentRow, this.currentDropPosition); cue.IsDropPossible = true; } else if (e.Options.Status == DragStatus.DropImpossible) { this.HideDropPositionFeedbackPresenter(); this.ClearDragCueContent(cue); cue.IsDropPossible = false; } else if (e.Options.Status == DragStatus.DropComplete) { this.HideDropPositionFeedbackPresenter(); var dropIndex = gridView.Items.IndexOf(this.currentDropItem); if (currentDropPosition == DropPosition.After) { dropIndex++; } ReorderingEventArgs reorderingArgs = new ReorderingEventArgs(gridView, draggedItems, dropIndex); this.OnReordering(reorderingArgs); this.TryReorderRows(reorderingArgs); this.OnReordered(new ReorderedEventArgs(gridView, draggedItems)); } e.Handled = true; }
/// <summary> /// 处理拖拽的拖动操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UserInRoles_OnDragInfo(object sender, DragDropEventArgs e) { RadGridView gridView = sender as RadGridView; IEnumerable draggedItems = e.Options.Payload as IEnumerable; if (e.Options.Status == DragStatus.DragInProgress) { TreeViewDragCue cue = new TreeViewDragCue(); // 设置拖放窗口显示内容的模板。 cue.ItemTemplate = ServiceLocator.Current.GetInstance<UniCloud.UniAuth.Views.UserRoleAllotView>().Resources["UserInRolesTemplate"] as DataTemplate; cue.Background = new SolidColorBrush(Colors.Transparent); cue.ItemsSource = draggedItems; e.Options.DragCue = cue; } }
/// <summary> /// Sets the preview and tool tip visability as well as whether a drop is actually possible based on error codes. /// </summary> /// <param name="cue">The cue.</param> /// <param name="previewVisibility">The preview visibility.</param> /// <param name="toolTipVisibility">The tool tip visibility.</param> /// <param name="dropPossible">Bool value that tells us if the drop is possible </param> /// <returns></returns> public static TreeViewDragCue SetPreviewAndToolTipVisabilityAndDropPossible(TreeViewDragCue cue, Visibility previewVisibility, Visibility toolTipVisibility, bool dropPossible) { cue.DragPreviewVisibility = previewVisibility; cue.DragTooltipVisibility = toolTipVisibility; cue.IsDropPossible = dropPossible; return cue; }
/// <summary> /// Creates the drag cue when an error message needs to be displayed. /// </summary> /// <param name="cue">The cue.</param> /// <param name="errorString">The error string.</param> /// <param name="dataTemplate">The data template.</param> /// <returns></returns> public static TreeViewDragCue CreateErrorDragCue(TreeViewDragCue cue, string errorString, DataTemplate dataTemplate) { cue = SetPreviewAndToolTipVisabilityAndDropPossible(cue, Visibility.Collapsed, Visibility.Visible, false); cue.DragTooltipContentTemplate = dataTemplate; cue.DragActionContent = String.Format(errorString); return cue; }