Exemplo n.º 1
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;
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
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;
            }
        }
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var sourceRow = (e.OriginalSource as TreeListViewRow) ?? (e.OriginalSource as FrameworkElement).ParentOfType <TreeListViewRow>();

            if (sourceRow != null)
            {
                var dataObject = DragDropPayloadManager.GeneratePayload(null);

                var draggedItem = sourceRow.Item;

                DragDropPayloadManager.SetData(dataObject, "DragData", new Collection <object>()
                {
                    draggedItem
                });
                e.Data = dataObject;

                // TODO: Cleanup. The "if" statement is to patch a problem with the ObjectAssociation collection. Quick and Dirty
                if ((sender as RadTreeListView).Name != "ObjectAssociationTreeListView")
                {
                    var screenshotVisualProvider = new ScreenshotDragVisualProvider();
                    e.DragVisual = screenshotVisualProvider.CreateDragVisual(new DragVisualProviderState(e.RelativeStartPoint, new List <object>()
                    {
                        draggedItem
                    }, new List <DependencyObject>()
                    {
                        sourceRow
                    }, sender as FrameworkElement));
                    e.DragVisualOffset    = new Point(0, 0);
                    this.originalSource   = sourceRow.Item;
                    this.sourceCollection = sourceRow.ParentRow != null ? (IList)sourceRow.ParentRow.Items.SourceCollection : (IList)sourceRow.GridViewDataControl.ItemsSource;
                }
                // In case the item is dragged to a different tree, populate the DraggedModel object with the dragged data
                // so it can be picked up by the destination tree
                if (Globals.DraggedItem == null)
                {
                    Globals.DraggedItem = new DragModel();
                }
                switch ((sender as RadTreeListView).Name)
                {
                case "ObjectTreeListView":
                    Globals.DraggedItem.Type = "Object";
                    Globals.DraggedItem.ObjectModelSource = draggedItem as ObjectModel;
                    break;

                case "TemplateTreeListView":
                    Globals.DraggedItem.Type = "Template";
                    Globals.DraggedItem.TemplateModelSource = draggedItem as TemplateModel;
                    break;

                case "PropertyTreeListView":
                    Globals.DraggedItem.Type = "Property";
                    Globals.DraggedItem.PropertyModelSource = draggedItem as PropertyModel;
                    break;

                case "RequirementTreeListView":
                    Globals.DraggedItem.Type = "Requirement";
                    Globals.DraggedItem.RequirementModelSource = draggedItem as RequirementModel;
                    break;

                case "ObjectAssociationTreeListView":
                    Globals.DraggedItem.Type = "ObjectAssociation";
                    Globals.DraggedItem.ObjectAssociationModelSource = draggedItem as ObjectAssociationModel;
                    break;

                case "ObjectRequirementTreeListView":
                    Globals.DraggedItem.Type = "ObjectRequirement";
                    Globals.DraggedItem.ObjectRequirementModelSource = draggedItem as ObjectRequirementModel;
                    break;

                case "AspectListView":
                    Globals.DraggedItem.Type = "Aspect";
                    Globals.DraggedItem.AspectModelSource = draggedItem as AspectModel;
                    break;

                case "AttributeListView":
                    Globals.DraggedItem.Type = "Attribute";
                    Globals.DraggedItem.AttributeModelSource = draggedItem as AttributeModel;
                    break;

                default:
                    break;
                }
                ;
            }
        }