Beispiel #1
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;
        }
		private static void OnDragInitialize(object sender, DragInitializeEventArgs args)
		{
			var container = args.OriginalSource as RadListBoxItem;

			if (container != null)
			{
				var toolboxItem = container.Content as IToolboxItem;
				if (toolboxItem != null)
				{
					var shape = toolboxItem.CreateShape();
					if (shape != null)
					{
						var element = container.Content as FrameworkElement;
						if (element != null)
						{
							var shapeSize = new Size(element.ActualWidth, element.ActualHeight);
							var dragDropInfo = new DiagramDropInfo(shapeSize, SerializationService.Default.SerializeItems(new[] { shape }));
							args.Data = dragDropInfo;
							args.DragVisualOffset = new Point(args.RelativeStartPoint.X - (shapeSize.Width / 2), args.RelativeStartPoint.Y - (shapeSize.Height / 2));
							args.DragVisual = new Image { Source = new RadBitmap(element).Bitmap, Width = shapeSize.Width, Height = shapeSize.Height };
						}
					}
					args.AllowedEffects = DragDropEffects.All;
					args.Handled = true;
				}
			}
			else
			{
				args.Cancel = true;
			}
		}
Beispiel #3
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 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;
        }
		private void OnDragInitialize(object sender, DragInitializeEventArgs args)
		{
			args.AllowedEffects = DragDropEffects.All;
			if (args.OriginalSource.GetType() == typeof(Telerik.Windows.Controls.RadListBoxItem))
			{
				var draggedShape = (args.OriginalSource as Telerik.Windows.Controls.RadListBoxItem).ChildrenOfType<RadDiagramShapeBase>().FirstOrDefault();
				if (draggedShape != null)
				{
					var shapeSize = new Size(draggedShape.ActualWidth, draggedShape.ActualHeight);
					if (shapeSize.Width > 0 && shapeSize.Height > 0)
					{
						var dropInfo = new DiagramDropInfo(shapeSize, SerializationService.Default.SerializeItems(new List<IDiagramItem> {draggedShape}));
						args.Data = dropInfo;
						args.DragVisualOffset = new Point(args.RelativeStartPoint.X - (shapeSize.Width / 2), args.RelativeStartPoint.Y - (shapeSize.Height / 2));

						var draggingImage = new System.Windows.Controls.Image
						{
							Source = new Telerik.Windows.Media.Imaging.RadBitmap(draggedShape).Bitmap,
							Width = shapeSize.Width,
							Height = shapeSize.Height
						};
						args.DragVisual = draggingImage;
					}
				}
			}
		}
Beispiel #6
0
 private void OnBorderDrop(object sender, DragInitializeEventArgs e)
 {
     e.AllowedEffects = DragDropEffects.All;
     e.DragVisual     = new TextBlock()
     {
         Text = "Dragging.."
     };
 }
Beispiel #7
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;
 }
Beispiel #8
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;
        }
Beispiel #9
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;
 }
Beispiel #10
0
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            e.AllowedEffects = DragDropEffects.All;
            string text = (e.OriginalSource as RadTreeViewItem).DataContext.ToString();

            e.DragVisual = new ContentControl {
                Content = text
            };
            e.Data = text;
        }
Beispiel #11
0
 private static void OnGridViewRowDragInitialize(object sender, DragInitializeEventArgs args)
 {
     args.AllowedEffects = DragDropEffects.All;
     args.DragVisualOffset = new Point(args.RelativeStartPoint.X, args.RelativeStartPoint.Y);
     args.DragVisual = new RadDiagramShape
     {
         Content = ((FrameworkElement)args.OriginalSource).DataContext,
         ContentTemplate = Application.Current.Resources["DragTemplate"] as DataTemplate
     };
 }
Beispiel #12
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;
        }
Beispiel #13
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;
        }
Beispiel #14
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;
            }
        }
Beispiel #15
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;
        }
Beispiel #16
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;
        }
Beispiel #17
0
        private static void OnElementDragInitialize(object sender, DragInitializeEventArgs e)
        {
            arrowContainer.Width  = rootVisual.ActualWidth;
            arrowContainer.Height = rootVisual.ActualHeight;
            var position = Mouse.GetPosition(rootVisual);

            arrowVisual.X1 = arrowVisual.X2 = position.X;
            arrowVisual.Y1 = arrowVisual.Y2 = position.Y;

            allowDropCache       = rootVisual.AllowDrop;
            rootVisual.AllowDrop = true;
        }
Beispiel #18
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;
        }
Beispiel #19
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;
                }
            }
        }
        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;
        }
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var sourceElement = e.OriginalSource as FrameworkElement;
            if (sourceElement == null)
            {
                e.Cancel = true;
                return;
            }
            var navItem = sourceElement.DataContext as NavItemViewModel;
            if (navItem != null)
            {
                if (string.IsNullOrWhiteSpace(navItem.Model.AssemblyName))
                {
                    return;
                }

                navItem.WindowManager.IsMenuShown = false;

                var dragCue = new ContentControl
                {
                    Content = new GadgetView
                    {
                        DataContext = new GadgetDragCueViewModel
                        {
                            Width = 150,
                            Height = 150,
                            Name = navItem.Name
                        }
                    }
                };
                e.DragVisual = dragCue;

                var payload = DragDropPayloadManager.GeneratePayload(null);

                payload.SetData("DragData", new DragDropParameter
                {
                    Location = e.RelativeStartPoint,
                    DraggedItem = navItem.Model
                });

                e.Data = payload;

                e.Cancel = false;
                e.AllowedEffects = DragDropEffects.All;
                e.Handled = true;
            }
        }
Beispiel #22
0
        private void AssociatedObject_OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            e.Effects = DragDropEffects.All;
            IList selectedItems = GetSelectedItemsAsList(AssociatedObject);

            if (selectedItems.Count > 0)
            {
                if (GetItemContainerFromPoint(AssociatedObject, e.DragStartPosition) is FrameworkElement item)
                {
                    Point mousePos = e.GetPosition(AssociatedObject);
                    Point itemPos  = item.TranslatePoint(new Point(), AssociatedObject);
                    Point offset   = new Point(mousePos.X - itemPos.X, mousePos.Y - itemPos.Y);
                    e.DragVisualSize   = new Size(item.ActualWidth, item.ActualHeight);
                    e.DragVisualOffset = offset;
                    e.Data             = DragDataManager.GenerateDataObject(selectedItems);
                }
                else
                {
                    AssociatedObject.SelectedItems.Clear();
                }
            }
        }
        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;
            }
        }
Beispiel #24
0
        private void OnPlanDatailDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var details = new DropIndicationDetails();
            GridViewRow row = e.OriginalSource as GridViewRow ??
                              (e.OriginalSource as FrameworkElement).ParentOfType<GridViewRow>();

            var gridView = sender as RadGridView;
            if (gridView == null) return;

            object item = row != null ? row.Item : gridView.SelectedItem;
            details.CurrentDraggedItem = item;

            IDragPayload dragPayload = DragDropPayloadManager.GeneratePayload(null);

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

            e.Data = dragPayload;

            //判断是否能拖拽
            var planDetail = item as PlanHistoryDTO;
            if (planDetail != null && ViewModel.SelRequest != null &&
                ViewModel.SelRequest.Status < (int) RequestStatus.已审核 &&
                (planDetail.CanRequest == (int) CanRequest.可申请 || planDetail.CanRequest == (int) CanRequest.可再次申请))
            {
                e.AllowedEffects = DragDropEffects.All;
            }
            else
            {
                e.AllowedEffects = DragDropEffects.None;
            }
            e.DragVisual = new DragVisual
            {
                Content = item,
                ContentTemplate = gridView.Resources["PlanDraggedItemTemplate"] as DataTemplate
            };
            e.DragVisualOffset = e.RelativeStartPoint;
        }
        private static void TrayDragInitialized(object sender, DragInitializeEventArgs e)
        {
            RadToolBarTray tray    = sender as RadToolBarTray;
            RadToolBar     toolBar = e.Source as RadToolBar;

            if (tray == null || toolBar == null)
            {
                return;
            }

            DragDropInfo info = new DragDropInfo(toolBar, tray);

            lastInitializedInfo = info;
            if (trayToHostDict.ContainsKey(tray) || !tray.IsMouseOver)
            {
                MoveToolBarToDragVisual(info, tray);
            }
            else
            {
                SetHitTesting(info.Tray.Items);
            }

            SetActiveToolBarStyle(info.ToolBar);
            if (trayToHostDict.ContainsKey(info.Tray))
            {
                trayToHostDict[info.Tray].Opacity = 0;
            }

            DragDropManager.AddDragDropCompletedHandler(info.ToolBar, ToolBarDragDropCompleted);
            DragDropManager.AddGiveFeedbackHandler(info.ToolBar, ToolBarGiveFeedback);

            e.Data             = info;
            e.DragVisual       = info.DragVisual;
            e.DragVisualOffset = e.RelativeStartPoint;
            e.AllowedEffects   = DragDropEffects.All;
            e.Handled          = true;
        }
Beispiel #26
0
        private void OnDragInitialized(object sender, DragInitializeEventArgs args)
        {
            if (this.DraggingCandidate != null && this.IsItemDraggingEnabled && this.MaximizedItem != null)
            {
                Rect bounds            = VisualTreeHelper.GetDescendantBounds(this.DraggingCandidate);
                RenderTargetBitmap rtb = new RenderTargetBitmap((int)bounds.Width, (int)bounds.Height, 96, 96, PixelFormats.Pbgra32);
                DrawingVisual      dv  = new DrawingVisual();
                using (DrawingContext dc = dv.RenderOpen())
                {
                    VisualBrush vb = new VisualBrush(this.DraggingCandidate);
                    dc.DrawRectangle(vb, null, new Rect(new Point(), bounds.Size));
                }
                rtb.Render(dv);
                PngBitmapEncoder png = new PngBitmapEncoder();
                png.Frames.Add(BitmapFrame.Create(rtb));
                MemoryStream stream = new MemoryStream();
                using (stream)
                {
                    png.Save(stream);
                    BitmapImage bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.StreamSource = stream;
                    bitmap.CacheOption  = BitmapCacheOption.OnLoad;
                    bitmap.EndInit();
                    Border tmpBorder = new Border();
                    tmpBorder.Padding = new Thickness(Math.Max(0, (this.DraggingCandidate.ActualWidth - bounds.Width) / 2));
                    Image image = new Image()
                    {
                        Source = bitmap, Width = bounds.Width, Height = bounds.Height
                    };
                    tmpBorder.Child = image;
                    args.DragVisual = tmpBorder;
                }

                args.Handled = true;
            }
        }
        private static void TrayDragInitialized(object sender, DragInitializeEventArgs e)
        {
            RadToolBarTray tray    = sender as RadToolBarTray;
            RadToolBar     toolBar = e.Source as RadToolBar;

            if (tray == null || toolBar == null)
            {
                return;
            }

            DragDropInfo info = new DragDropInfo(toolBar, tray);

            lastInitializedInfo = info;

            SetActiveToolBarStyle(info.ToolBar);

            DragDropManager.AddDragDropCompletedHandler(info.ToolBar, ToolBarDragDropCompleted);

            e.DragVisual       = CreateDragImageFromToolBar(info.ToolBar);
            e.Data             = info;
            e.DragVisualOffset = e.RelativeStartPoint;
            e.AllowedEffects   = DragDropEffects.All;
            e.Handled          = true;
        }
        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)
        {
            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)
        {
            DragDropIndicationDetail details = new DragDropIndicationDetail();
            var items = (sender as RadListBox).SelectedItems;
            details.CurrentDraggedItem = items;

            IDragPayload dragPayload = DragDropPayloadManager.GeneratePayload(null);

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

            e.Data = dragPayload;

            //Si les infos du drag&drop ne doivent pas être cachées
            if (GetInfosHidden(sender as DependencyObject).Equals(false))
            {
                e.DragVisual = new DragVisual()
                {
                    Content = details,
                    ContentTemplate = this.AssociatedObject.Resources["DraggedItemTemplate"] as DataTemplate
                };
            }
            else
            {
                e.DragVisual = new DragVisual();
            }

            e.DragVisualOffset = new Point(e.RelativeStartPoint.X + 20, e.RelativeStartPoint.Y + 20);
            e.AllowedEffects = DragDropEffects.All;
        }
		private void OnDragInitialized(object sender, DragInitializeEventArgs args)
		{
			if (this.DraggingCandidate != null)
			{
				this.DraggingCandidate.IsMouseOverShape = false;

				args.DragVisual = new Rectangle
				{
					Width = 70,
					Height = 32,
					RadiusY = 2,
					RadiusX = 2,
					StrokeThickness = 2,
					Fill = new SolidColorBrush(Color.FromArgb(0x19, 0x33, 0x33, 0x33)),
					Stroke = new SolidColorBrush(Color.FromArgb(0x7F, 0x33, 0x33, 0x33))
				};
				args.DragVisualOffset = args.RelativeStartPoint;

				args.AllowedEffects = DragDropEffects.All;
				args.Handled = true;
			}
			else
			{
				args.Cancel = true;
			}
		}
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            this.draggedImage = e.OriginalSource as Image ?? (e.OriginalSource as FrameworkElement).ParentOfType<Image>();

            if (this.draggedImage == null)
            {
                e.Cancel = true;
            }

            this.relativeStartPoint = e.RelativeStartPoint;
        }
 private void OnDragInitialized(object sender, DragInitializeEventArgs e)
 {
     e.DragVisual = new OrgChartDragView() { DataContext = this.DataContext };
     e.DragVisualOffset = new Point(e.RelativeStartPoint.X * (1 - this.ScaleLevel), e.RelativeStartPoint.Y * (1 - this.ScaleLevel));
 }
        /// <summary>
        /// Handles the <see cref="E:DragInitialize" /> event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="DragInitializeEventArgs"/> instance containing the event data.</param>
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            using (var details = new DropIndicationDetails())
            {
                var spreadsheetView = sender as SpreadsheetView;
                if (spreadsheetView != null)
                {
                    var item = spreadsheetView.SelectedItem;
                    details.CurrentDraggedItem = item;

                    var dragPayload = DragDropPayloadManager.GeneratePayload(null);

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

                    e.Data = dragPayload;
                }

                e.DragVisual = new DragVisual
                                   {
                                       Content = details,
                                       ContentTemplate = AssociatedObject.Resources["DraggedItemTemplate"] as DataTemplate
                                   };
                e.DragVisualOffset = e.RelativeStartPoint;
                e.AllowedEffects = DragDropEffects.All;
            }            
        }
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var source = e.OriginalSource as FrameworkElement;
            if (source != null && source.Name != "PART_RowResizer")
            {
                GridRowIndicationDetail details = new GridRowIndicationDetail();
                var item = (sender as RadGridView).SelectedItem;
                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 OnDragInitialize(object sender, DragInitializeEventArgs e)
		{
			var treeViewItem = e.OriginalSource as RadTreeViewItem ?? (e.OriginalSource as FrameworkElement).ParentOfType<RadTreeViewItem>();
			var data = treeViewItem != null? treeViewItem.Item : (sender as RadTreeView).SelectedItem;

			var payload = DragDropPayloadManager.GeneratePayload(null);

			var dropDetails = new DropIndicationDetails();
			dropDetails.CurrentDraggedItem = data;

			DragVisual visual = new DragVisual()
			{
				Content = dropDetails,
				ContentTemplate = data is CategoryViewModel ? this.AssociatedObject.Resources["CategoryDragTemplate"] as DataTemplate : this.AssociatedObject.Resources["ProductDragTemplate"] as DataTemplate
			};

			payload.SetData("DraggedData", data);
			payload.SetData("DropDetails", dropDetails);

			e.DragVisual = visual;
			e.DragVisualOffset = e.RelativeStartPoint;
			e.Data = payload;
			e.AllowedEffects = DragDropEffects.All;

			FrameworkElement sourceItem = e.OriginalSource as RadTreeViewItem ?? (e.OriginalSource as FrameworkElement).ParentOfType<RadTreeViewItem>();
			if (sourceItem == null)
			{
				this.sourceItems = (IList)this.AssociatedObject.ItemsSource;
			}
			else
			{
				this.sourceItems = (sourceItem as RadTreeViewItem).ParentItem != null ? (IList)(sourceItem as RadTreeViewItem).ParentItem.ItemsSource : (IList)this.AssociatedObject.ItemsSource;
			}

			this.sourceItem = sourceItem.DataContext;
			this.destinationItems = this.AssociatedObject.ItemsSource as IList;
			this.isTreeSource = true;
		}
		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;

				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;
			}
		}
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var details = new DropIndicationDetails();
            var row = e.OriginalSource as GridViewRow ??
                              (e.OriginalSource as FrameworkElement).ParentOfType<GridViewRow>();

            if (sender != null)
            {
                object 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.DragVisualOffset = e.RelativeStartPoint;
            e.AllowedEffects = DragDropEffects.All;
        }
        private void OnDragInitialized(object sender, DragInitializeEventArgs args)
        {
            var toolBoxItem = args.OriginalSource as ToolboxItem;
            if (toolBoxItem != null)
            {
                var serializer = new SerializationService(null);
                var shape = toolBoxItem.Shape;
                if (shape != null)
                {
                    args.Data = serializer.SerializeItems(new List<IDiagramItem> { shape as IDiagramItem });

                    args.DragVisualOffset = new Point(args.RelativeStartPoint.X - (shape.ActualWidth / 2), args.RelativeStartPoint.Y - (shape.ActualHeight / 2));

                    var draggingImage = new Image
                        {
                            Source = new Telerik.Windows.Media.Imaging.RadBitmap(shape).Bitmap,
                            Width = shape.ActualWidth,
                            Height = shape.ActualHeight
                        };
                    args.DragVisual = draggingImage;
                }
            }
            args.AllowedEffects = DragDropEffects.All;
            args.Handled = true;
        }
		private void OnDragInitialized(object sender, DragInitializeEventArgs args)
		{
			var toolBoxItem = args.OriginalSource as ToolboxItem;
			if (toolBoxItem != null)
			{
				var shape = toolBoxItem.Shape;
				if (shape != null && shape.ActualWidth > 0 && shape.ActualHeight > 0 && this.serializator != null)
				{
					////args.Data = this.shapeToDataMap[toolBoxItem];
					shape.ClearValue(BackgroundProperty);
					args.Data = this.serializator.SerializeItems(new List<IDiagramItem> { shape });

					args.DragVisualOffset = new Point(args.RelativeStartPoint.X - (shape.ActualWidth / 2), args.RelativeStartPoint.Y - (shape.ActualHeight / 2));

					var draggingImage = new System.Windows.Controls.Image
					{
						Source = new Telerik.Windows.Media.Imaging.RadBitmap(shape).Bitmap,
						Width = shape.ActualWidth,
						Height = shape.ActualHeight
					};
					args.DragVisual = draggingImage;
				}
				else
				{
					args.Data = toolBoxItem.Content;
				}

				toolBoxItem.IsMouseOverItem = false;
			}
			args.AllowedEffects = DragDropEffects.All;
			args.Handled = true;
		}
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var listBox = sender as ListBox;
            if (listBox != null)
            {
                var draggedItem = listBox.SelectedItems;
                string dataVisual = string.Empty;
                e.AllowedEffects = DragDropEffects.All;
                var data = DragDropPayloadManager.GeneratePayload(null);
                _CollectorForAdd.Clear();
                if (draggedItem != null)
                {
                    foreach(var item in draggedItem)
                    {
                        _CollectorForAdd.Add((Collectors)item);
                        dataVisual += ((Collectors)item).UserName + "; ";
                    }
                }
                dataVisual = dataVisual.Remove(dataVisual.Length - 2, 2);
                data.SetData("DraggedData", draggedItem);

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

                e.DragVisualOffset = e.RelativeStartPoint;
                e.Data = data;
            }
        }
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            GridRowIndicationDetail details = new GridRowIndicationDetail();
            var items = (sender as RadListBox).SelectedItems;
            details.CurrentDraggedItem = items;

            IDragPayload dragPayload = DragDropPayloadManager.GeneratePayload(null);

            dragPayload.SetData("DraggedData", items);
            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 static void TrayDragInitialized(object sender, DragInitializeEventArgs e)
        {
            RadToolBarTray tray = sender as RadToolBarTray;
            RadToolBar toolBar = e.Source as RadToolBar;
            if (tray == null || toolBar == null)
            {
                return;
            }

            DragDropInfo info = new DragDropInfo(toolBar, tray);
            lastInitializedInfo = info;

            SetActiveToolBarStyle(info.ToolBar);

            DragDropManager.AddDragDropCompletedHandler(info.ToolBar, ToolBarDragDropCompleted);
           
            e.DragVisual = CreateDragImageFromToolBar(info.ToolBar);
            e.Data = info;
            e.DragVisualOffset = e.RelativeStartPoint;
            e.AllowedEffects = DragDropEffects.All;
            e.Handled = true;
        }
        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;
                }
                ;
            }
        }
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            var item = e.Source as ListBoxItem;
            var box = ItemsControl.ItemsControlFromItemContainer(item) as ListBox;

            if (box != null)
            {
                e.AllowedEffects = DragDropEffects.All;
                e.Data = box.SelectedItem;
                e.DragVisual = new ContentControl { Content = e.Data, ContentTemplate = box.ItemTemplate };
                e.DragVisualOffset = new Point(e.RelativeStartPoint.X + 16, e.RelativeStartPoint.Y);
                e.Handled = true;
            }
        }
        private void OnDragInitialize(object sender, DragInitializeEventArgs args)
        {
            Console.Out.WriteLine("OnDragInitialize started");

            var listbox = sender as RadListBox;

            if (listbox == null)
            {
                return;
            }

            var selectedItem = listbox.SelectedItem as ApplicationInfo;

            if (selectedItem == null)
            {
                return;
            }

            args.AllowedEffects = DragDropEffects.Move;
            var payload = DragDropPayloadManager.GeneratePayload(null);
            payload.SetData("DragData", selectedItem);

            args.Data = payload;
            args.DragVisual = new ContentControl
                {
                    Content = DragDropPayloadManager.GetDataFromObject(args.Data, "DragData") as ApplicationInfo,
                    ContentTemplate = LayoutRoot.Resources["ApplicationTemplateDragged"] as DataTemplate
                };

            Console.Out.WriteLine("OnDragInitialize ended");
        }
        private void OnDragInitialize(object sender, DragInitializeEventArgs e)
        {
            using (var details = new DropIndicationDetails())
            {
                var row = e.OriginalSource as GridViewRow ?? (e.OriginalSource as FrameworkElement).ParentOfType<GridViewRow>();

                var gridView = (sender as RadGridView);

                var item = row != null ? row.Item : gridView.SelectedItem;
                
                var multiItemsModule = gridView.ParentOfType<Controls.FieldEditors.FieldMultiCrossRefView>()
                    .DataContext as IMultiItemsModule;
                if (
                    multiItemsModule != null)
                {
                    var dragoptions =
                        multiItemsModule.DragAndDropOptions;
                    if (dragoptions != null && dragoptions.Any())
                    {
                        details.DragFields = new Collection<string>();
                        foreach (var option in dragoptions)
                        {
                            details.DragFields.Add(option.DragField);
                        }
                    }
                }
                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 static void TrayDragInitialized(object sender, DragInitializeEventArgs e)
        {
            RadToolBarTray tray = sender as RadToolBarTray;
            RadToolBar toolBar = e.Source as RadToolBar;
            if (tray == null || toolBar == null)
            {
                return;
            }

            DragDropInfo info = new DragDropInfo(toolBar, tray);
            lastInitializedInfo = info;
            if (trayToHostDict.ContainsKey(tray) || !tray.IsMouseOver)
            {
                MoveToolBarToDragVisual(info, tray);
            }
            else
            {
                SetHitTesting(info.Tray.Items);
            }

            SetActiveToolBarStyle(info.ToolBar);
            if (trayToHostDict.ContainsKey(info.Tray))
            {
                trayToHostDict[info.Tray].Opacity = 0;
            }

            DragDropManager.AddDragDropCompletedHandler(info.ToolBar, ToolBarDragDropCompleted);
            DragDropManager.AddGiveFeedbackHandler(info.ToolBar, ToolBarGiveFeedback);

            e.Data = info;
            e.DragVisual = info.DragVisual;
            e.DragVisualOffset = e.RelativeStartPoint;
            e.AllowedEffects = DragDropEffects.All;
            e.Handled = true;
        }
        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;
        }
        private void OnDragInit(object sender, DragInitializeEventArgs e)
        {
            if (this.canDrag)
            {
#if SILVERLIGHT
                e.Data = this;
#else
                e.Data = new DataObject(typeof(SwimlaneShapeBase), this);
#endif
                this.Diagram.ServiceLocator.GetService<IToolService>().IsMouseDown = false;
                this.DragStartOffset = e.RelativeStartPoint;

                var newBounds = new Rect(this.Position, new Size(this.Bounds.Width, this.Height + 1));
                var bm = this.swimlaneDiagram.CreateImage(newBounds);

                var draggingImage = new System.Windows.Controls.Image
                {
                    Source = bm,
                    Width = newBounds.Width,
                    Height = newBounds.Height,
                };

                e.DragVisual = new Border() { Child = draggingImage, Opacity = 0.5 };

                e.AllowedEffects = DragDropEffects.All;
                e.Handled = true;
            }
            else
            {
#if SIVERLIGHT
                this.IsMouseOver = true;
#endif
                e.Cancel = true;
            }
        }