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;
        }
Exemplo n.º 2
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;
            }
        }
        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);
            }
        }
        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;
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
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;
        }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
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;
            }
        }
Exemplo n.º 10
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;
        }
Exemplo n.º 11
0
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var draggedColumn = ((e.OriginalSource as RadListBoxItem) ?? (e.OriginalSource as FrameworkElement).ParentOfType <RadListBoxItem>()).DataContext as GridViewColumn;

            var dragVisual = new DragVisual()
            {
                Content = draggedColumn.Header
            };
            var payload = DragDropPayloadManager.GeneratePayload(null);

            payload.SetData("DraggedColumn", draggedColumn);

            e.DragVisual     = dragVisual;
            e.Data           = payload;
            e.AllowedEffects = DragDropEffects.All;
        }
Exemplo n.º 12
0
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            // only on preview tab and edit mode drag and drop is allowed
            // for all items within the area and group in all Sales Estimating revisions
            // should be in one place while moving to avoid confusion
            if ((App.Current as App).SelectedTabIndexEstimateDetails == 3 &&
                ((App.Current as App).CurrentAction == "EDIT") &&
                (((App.Current as App).SelectedEstimateRevisionTypeID == 4) ||  // SE - Sales Estimating
                 ((App.Current as App).SelectedEstimateRevisionTypeID == 15) || // PVAR-SE
                 ((App.Current as App).SelectedEstimateRevisionTypeID == 19) || // BVAR-SE
                 ((App.Current as App).SelectedEstimateRevisionTypeID == 25)))  // PSTM-SE
            {
                DropIndicationDetails details = new DropIndicationDetails();
                var row = e.OriginalSource as GridViewRow ?? (e.OriginalSource as FrameworkElement).ParentOfType <GridViewRow>();

                var item = row != null ? row.Item : (sender as RadGridView).SelectedItem;
                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,
                    ContentTemplate = this.AssociatedObject.Resources["DraggedItemTemplate"] as DataTemplate
                };
                e.DragVisualOffset = e.RelativeStartPoint;
                e.AllowedEffects   = DragDropEffects.All;
            }
            else
            {
                e.Cancel = true;
            }
        }
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            DropIndicationDetails details = new DropIndicationDetails();
            var gridView = sender as RadGridView;

            details.DragSource = gridView.ItemsSource;

            var items = gridView.SelectedItems;

            details.CurrentDraggedItems = items;

            IDragPayload dragPayload = DragDropPayloadManager.GeneratePayload(null);

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

            e.Data = dragPayload;

            e.DragVisual = new DragVisual {
                Content = details, ContentTemplate = AssociatedControl.Resources["DraggedItemTemplate"] as DataTemplate
            };
            e.DragVisualOffset = new Point(e.RelativeStartPoint.X + 10, e.RelativeStartPoint.Y);
            e.AllowedEffects   = DragDropEffects.All;
        }
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            DropIndicationDetails details = new DropIndicationDetails();
            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).SelectedItem;

            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,
                ContentTemplate = this.AssociatedObject.Resources["DraggedItemTemplate"] as DataTemplate
            };
            e.DragVisualOffset = e.RelativeStartPoint;
            e.AllowedEffects   = DragDropEffects.All;
        }
        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;
                }
                ;
            }
        }