Ejemplo n.º 1
0
        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;
            }
        }
        /// <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;
            }            
        }
 public void PropertiesTest()
 {
     var classUnderTest = new DropIndicationDetails();
     TestsHelper.TestPublicPropertiesGetSet(classUnderTest);
 }