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;
        }
Ejemplo n.º 2
0
    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 OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var draggedItem = (sender as ListBox).SelectedItem as MyObject;

            e.AllowedEffects = DragDropEffects.All;
            var    data = DragDropPayloadManager.GeneratePayload(null);
            string text = typeof(MyObject).ToString();

            if (draggedItem != null)
            {
                text = draggedItem.Name;
            }

            data.SetData("Text", text);
            data.SetData("DraggedData", draggedItem);

            e.DragVisual = new DragVisual()
            {
                Content = text,
            };

            e.DragVisualOffset = e.RelativeStartPoint;
            e.Data             = data;
            shouldCancelDrop   = false;
        }
Ejemplo n.º 4
0
        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 OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            details = new DropIndicationDetails();
            var listBox = e.OriginalSource as System.Windows.Controls.ListBox ?? (e.OriginalSource as FrameworkElement).ParentOfType <System.Windows.Controls.ListBox>();

            if (listBox == null || listBox.SelectedItems.Count == 0)
            {
                return;
            }
            var item = listBox.SelectedItems;

            details.CurrentDraggedItem = item;

            IDragPayload dragPayload = DragDropPayloadManager.GeneratePayload(null);

            dragPayload.SetData("DraggedData", item);
            dragPayload.SetData("DropDetails", details);

            e.Data = dragPayload;

            e.DragVisual = new DragVisual()
            {
                Content         = details,
                Background      = new SolidColorBrush(Colors.Transparent),
                BorderThickness = new Thickness(0),
                ContentTemplate = Application.Current.FindResource("SecureItemsDragTemplate") as DataTemplate
            };
            e.DragVisualOffset = e.RelativeStartPoint;
            e.AllowedEffects   = DragDropEffects.All;
        }
Ejemplo n.º 6
0
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var sourceRow = e.OriginalSource as GridViewRow ?? (e.OriginalSource as FrameworkElement).ParentOfType <GridViewRow>();

            if (sourceRow != null && sourceRow.Name != "PART_RowResizer")
            {
                DropIndicationDetails details = new DropIndicationDetails();
                var item = sourceRow.Item;
                details.CurrentDraggedItem = item;

                IDragPayload dragPayload = DragDropPayloadManager.GeneratePayload(null);

                dragPayload.SetData("DraggedItem", item);
                dragPayload.SetData("DropDetails", details);

                e.Data = dragPayload;

                e.DragVisual = new DragVisual()
                {
                    Content         = details,
                    ContentTemplate = this.AssociatedObject.Resources["DraggedItemTemplate"] as DataTemplate
                };
                e.DragVisualOffset = e.RelativeStartPoint;
                e.AllowedEffects   = DragDropEffects.All;
            }
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        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;
        }
Ejemplo n.º 9
0
        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;
        }
Ejemplo n.º 10
0
        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;
        }
Ejemplo n.º 11
0
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            DropIndicationDetails details = new DropIndicationDetails();
            //DragDropPayloadManager.GetDataFromObject(e.Data, )
            //ListBoxItem itemA = (ListBoxItem)VisualTreeHelper.GetParent(e.OriginalSource as UIElement);
            var listBoxItem = e.OriginalSource as System.Windows.Controls.ListBoxItem ?? (e.OriginalSource as FrameworkElement).ParentOfType <System.Windows.Controls.ListBoxItem>();
            // var item = listBoxItem != null ? listBoxItem.DataContext : (sender as System.Windows.Controls.ListBox).ItemsSource;

            List <ProductViewModel> item = new List <ProductViewModel>();

            item = (sender as System.Windows.Controls.ListBox).SelectedItems.Cast <ProductViewModel>().ToList <ProductViewModel>();
            if (listBoxItem != null)
            {
                item.Add(listBoxItem.DataContext as ProductViewModel);
            }

            details.CurrentDraggedItem = item;
            //copyProgress.Maximum = item.Count;

            IDragPayload dragPayload = DragDropPayloadManager.GeneratePayload(null);

            dragPayload.SetData("DraggedData", item);
            dragPayload.SetData("DropDetails", details);

            e.Data = dragPayload;

            e.DragVisual = new DragVisual()
            {
                Content         = details,
                ContentTemplate = this.AssociatedObject.Resources["DraggedItemTemplate"] as DataTemplate
            };
            e.DragVisualOffset = e.RelativeStartPoint;
            e.AllowedEffects   = DragDropEffects.All;
        }
Ejemplo n.º 12
0
        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;
        }
Ejemplo n.º 13
0
        private void OnTimelineDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var itemControl = e.OriginalSource as TimelineItemControlBase;

            if (itemControl != null)
            {
                var data     = (TimelineDataItem)itemControl.DataContext;
                var dataItem = (ITimelineItem)data.DataItem;
                var payload  = DragDropPayloadManager.GeneratePayload(null);
                payload.SetData("DraggedItem", dataItem);

                e.AllowedEffects = DragDropEffects.Move;
                e.Data           = payload;

                this.dragVisual.Content = new TimelineItemDragVisualInfo()
                {
                    ItemImageSource = new RadBitmap(itemControl).Bitmap,
                    ItemImageWidth  = itemControl.ActualWidth,
                    ItemImageHeight = itemControl.ActualHeight,
                };
                e.DragVisual = this.dragVisual;

                this.groupControlInfos = GetGroupInfos(timeline);
            }
        }
Ejemplo n.º 14
0
        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;
        }
Ejemplo n.º 16
0
        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;
            }
        }
Ejemplo n.º 17
0
        private void OnDragInitialize(object sender, DragInitializeEventArgs args)
        {
            args.AllowedEffects = DragDropEffects.All;
            var    payload = DragDropPayloadManager.GeneratePayload(null);
            string data    = this.pdfViewer.GetSelectedText();

            payload.SetData("DragData", data);
            args.Data = payload;
        }
Ejemplo n.º 18
0
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            e.AllowedEffects = DragDropEffects.All;
            var payload = DragDropPayloadManager.GeneratePayload(new CustomerToStringConverter());
            var data    = ((FrameworkElement)e.OriginalSource).DataContext;

            payload.SetData("DragData", data);
            e.Data    = payload;
            e.Handled = true;
        }
        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);
            }
        }
Ejemplo n.º 20
0
        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();
            }
        }
Ejemplo n.º 21
0
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            TreeListViewRow sourceRow = (e.OriginalSource as TreeListViewRow) ?? (e.OriginalSource as FrameworkElement).ParentOfType <TreeListViewRow>();

            if (sourceRow != null)
            {
                IDragPayload dataObject = DragDropPayloadManager.GeneratePayload(null);
                DragDropPayloadManager.SetData(dataObject, __dragSource, sourceRow.Item);
                e.Data = dataObject;
            }
        }
Ejemplo n.º 22
0
        private void OnDragInitialize(object sender, DragInitializeEventArgs args)
        {
            args.AllowedEffects = DragDropEffects.All;

            RadTreeView radTreeView = sender as RadTreeView;

            var payload = DragDropPayloadManager.GeneratePayload(null);

            payload.SetData("DragData", radTreeView.SelectedItem.ToString());
            args.Data = payload;
        }
Ejemplo n.º 23
0
        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;
        }
Ejemplo n.º 24
0
    // 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;
        }
    }
Ejemplo n.º 25
0
        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
                });
            }
        }
Ejemplo n.º 26
0
        private void OnDragInitialize(object sender, DragInitializeEventArgs args)
        {
            args.AllowedEffects = DragDropEffects.All;
            var payload = DragDropPayloadManager.GeneratePayload(null);
            var data    = ((FrameworkElement)args.OriginalSource).DataContext;

            payload.SetData("DragData", data);
            args.Data       = payload;
            args.DragVisual = new ContentControl {
                Content = data, ContentTemplate = this.DragVisualTemplate
            };
            args.DragVisualOffset = args.RelativeStartPoint;
        }
Ejemplo n.º 27
0
        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;
                }
            }
        }
Ejemplo n.º 28
0
        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 ";
                }
            }
        }
Ejemplo n.º 29
0
        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);
            }
        }
Ejemplo n.º 30
0
        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();
            }
        }