Наследование: RoutedEventArgs, IDragEventArgs
Пример #1
0
        /// <summary>
        /// Entering the Target, we'll change its background and optionally change the DragUI as well
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TargetTextBox_DragEnter(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            /// Change the background of the target
            VisualStateManager.GoToState(this, "Inside", true);
            bool hasText = e.DataView.Contains(StandardDataFormats.Text);

            e.AcceptedOperation = hasText ? DataPackageOperation.Copy : DataPackageOperation.None;
            if (hasText)
            {
                e.DragUIOverride.Caption = "Drop here to insert text";
                // Now customize the content
                if ((bool)HideRB.IsChecked)
                {
                    e.DragUIOverride.IsGlyphVisible   = false;
                    e.DragUIOverride.IsContentVisible = false;
                }
                else if ((bool)CustomRB.IsChecked)
                {
                    var bitmap = new BitmapImage(new Uri("ms-appx:///Assets/dropcursor.png", UriKind.RelativeOrAbsolute));
                    // Anchor will define how to position the image relative to the pointer
                    Windows.Foundation.Point anchor = new Windows.Foundation.Point(0, 52); // lower left corner of the image
                    e.DragUIOverride.SetContentFromBitmapImage(bitmap, anchor);
                    e.DragUIOverride.IsGlyphVisible   = false;
                    e.DragUIOverride.IsCaptionVisible = false;
                }
                // else keep the DragUI Content set by the source
            }
        }
Пример #2
0
        void HandleDrop(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            var           datapackage = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage;
            VisualElement element     = null;

            if (sender is IVisualElementRenderer renderer)
            {
                element = renderer.Element;
            }

            var args = new DropEventArgs(datapackage?.View);

            SendEventArgs <DropGestureRecognizer>(async rec =>
            {
                if (!rec.AllowDrop)
                {
                    return;
                }

                try
                {
                    await rec.SendDrop(args);
                }
                catch (Exception dropExc)
                {
                    Internals.Log.Warning(nameof(DropGestureRecognizer), $"{dropExc}");
                }
            });
        }
Пример #3
0
		private void ListView_DragOver(object sender, DragEventArgs e)
		{
			if (e.DataView.Contains(StandardDataFormats.Text))
			{
				e.AcceptedOperation = DataPackageOperation.Move;
			}
		}
Пример #4
0
        private void gview_Drop(object sender, DragEventArgs e)
        {
            viewmodel.BooksScroll = ScrollMode.Enabled;

            object gridSource;
            e.Data.Properties.TryGetValue("gridSource", out gridSource);

            if (gridSource == sender)
                return;

            object sourceItem;
            e.Data.Properties.TryGetValue("item", out sourceItem);
            if (sourceItem == null)
                return;

               // viewmodel.ShelfBrush = _shelfBrushColor;
               // viewmodel.GridBrush = _gridBrushColor;

            //Remove it from shelf
            var book = (Book)sourceItem;
            viewmodel.ShelfBooks.Remove(book);
            book.Shelf = false;

            var a = new BookEventArgs();
            a.Book = book;
            a.State = BookEventArgs.BookState.Updated;
            viewmodel.BookChanged(this, a);
            viewmodel.UpdateBook(book);
        }
Пример #5
0
 private async void OnDropped(object sender, DragEventArgs e)
 {
     var file = (StorageFile)(await e.DataView.GetStorageItemsAsync())[0];
     var imageSource = new BitmapImage();
     imageSource.SetSource(await file.OpenReadAsync());
     myImg.Source = imageSource;
 }
        /// <summary>
        /// Entering a target: check if this will result in a win
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DropBorder_DragEnter(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            bool win = (_dragOperation != null) && e.DataView.Contains(StandardDataFormats.Text) && IsSymbolTargetBorder(sender);

            e.AcceptedOperation = win ? DataPackageOperation.Copy : DataPackageOperation.None;
            e.DragUIOverride.IsCaptionVisible = false;
        }
Пример #7
0
 private void txtTextToSay_DragOver(object sender, Windows.UI.Xaml.DragEventArgs e)
 {
     if (e.DataView.Contains(StandardDataFormats.Text))
     {
         e.AcceptedOperation = DataPackageOperation.Copy;
     }
 }
Пример #8
0
 private void OnTabStripDragOver(object sender, Windows.UI.Xaml.DragEventArgs e)
 {
     if (e.DataView.Properties.ContainsKey(DataIdentifier))
     {
         e.AcceptedOperation = DataPackageOperation.Move;
     }
 }
        private async void TargetListView_Drop(object sender, DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.Text))
            {
                var def = e.GetDeferral();
                var s = await e.DataView.GetTextAsync();
                string[] items = s.Split('\n');
                View.MonsterSoloView msv = new MonsterSoloView();
                msv.DataContext = monsterList.GetMonsterByID(Convert.ToInt32(items[0]));
                SelectedMonsterList.Add(monsterList.GetMonsterByID(Convert.ToInt32(items[0])));

                msv.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Center);
                msv.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Center);
                Grid grid = sender as Grid;
                foreach (var element in grid.Children)
                {
                    View.MonsterSoloView msvelement = element as View.MonsterSoloView;
                    SelectedMonsterList.monsterList.Remove(msvelement.DataContext as Monster);
                    grid.Children.Remove(element);
                    
                }
                grid.Children.Add(msv);

           
                e.AcceptedOperation = DataPackageOperation.Copy;
                def.Complete();
                selectedMonsterGridView.DataContext = new ObservableCollection<Monster>(SelectedMonsterList.monsterList);
            }
        }
Пример #10
0
 private void ListView_DragOver(object sender, Windows.UI.Xaml.DragEventArgs e)
 {
     //(sender as UserControl).Background = new SolidColorBrush(Color.FromArgb(255, 48, 179, 221));
     e.AcceptedOperation = DataPackageOperation.Link;
     e.DragUIOverride.IsCaptionVisible = true;
     e.DragUIOverride.IsContentVisible = true;
 }
        private void Control_Drop(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            DataPackageView dpView = e.Data.GetView();
            var             item   = dpView.Properties[DragItemKey];

            var sourceItems = dpView.Properties[SourceItemsKey] as IList;

            var destinationItems = Element.ItemsSource as IList;

            var originalSrc = e.OriginalSource as FrameworkElement;

            var dataContext = originalSrc.DataContext;


            if (dataContext is ViewCell)
            {
                var x = destinationItems.IndexOf((dataContext as ViewCell).BindingContext);

                destinationItems.Insert(x, item);
            }
            else if (dataContext is CellItem)
            {
                var x = destinationItems.IndexOf((dataContext as CellItem));

                destinationItems.Insert(x, item);
            }
            else
            {
                destinationItems.Add(item);
            }

            sourceItems.Remove(item);
        }
Пример #12
0
        void HandleDragLeave(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            var package       = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage;
            var dragEventArgs = new DragEventArgs(package);

            dragEventArgs.AcceptedOperation = (DataPackageOperation)((int)dragEventArgs.AcceptedOperation);
            SendEventArgs <DropGestureRecognizer>(rec =>
            {
                if (!rec.AllowDrop)
                {
                    return;
                }

                var operationPriorToSend = dragEventArgs.AcceptedOperation;
                rec.SendDragLeave(dragEventArgs);

                // If you set the AcceptedOperation to a value it was already set to
                // it causes the related animation to remain visible when the dragging component leaves
                // for example
                // e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
                // Even if AcceptedOperation is already set to Copy it will cause the copy animation
                // to remain even after the the dragged element has left
                if (operationPriorToSend != dragEventArgs.AcceptedOperation)
                {
                    var result          = (int)dragEventArgs.AcceptedOperation;
                    e.AcceptedOperation = (Windows.ApplicationModel.DataTransfer.DataPackageOperation)result;
                }
            });
        }
 private void Image_DragOver(object sender, DragEventArgs e)
 {
     if (DataContext is ViewModels.TodoItemViewModel)
     {
         e.AcceptedOperation = DataPackageOperation.Copy;
     }
 }
Пример #14
0
 private void Item_DragEnter(object sender, Windows.UI.Xaml.DragEventArgs e)
 {
     e.DragUIOverride.Caption          = "test caption";
     e.DragUIOverride.IsCaptionVisible = true;
     e.DragUIOverride.IsGlyphVisible   = false;
     e.DragUIOverride.IsContentVisible = false;
     e.Handled = true;
 }
Пример #15
0
 private void DragOverForApiTest(object sender, Windows.UI.Xaml.DragEventArgs args)
 {
     args.AcceptedOperation = DataPackageOperation.Copy;
     if (!Results.Text.Contains("DragOver"))
     {
         Results.Text += "->DragOver";
     }
 }
Пример #16
0
 private void ExtendedPostingView_OnDragOver(object sender, DragEventArgs e) {
     e.AcceptedOperation = DataPackageOperation.Copy;
     if (e.DragUIOverride == null)
         return;
     e.DragUIOverride.IsCaptionVisible = true;
     e.DragUIOverride.IsContentVisible = true;
     e.DragUIOverride.IsGlyphVisible = true;
 }
Пример #17
0
 /// <summary>
 /// Handle DragOver event, which fires when a user has dragged an item over the app, but not yet dropped it. 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Grid_DragOver(object sender, DragEventArgs e)
 {
     e.AcceptedOperation = DataPackageOperation.Copy;
     //Customize the UI
     e.DragUIOverride.Caption = "Copy picture here"; // Sets custom UI text
     e.DragUIOverride.IsCaptionVisible = true; // Sets if the caption is visible
     e.DragUIOverride.IsContentVisible = true; // Sets if the dragged content is visible     
 }
Пример #18
0
        private void OnTabStripDrop(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            // This event is called when we're dragging between different TabViews
            // It is responsible for handling the drop of the item into the second TabView

            object obj;
            object objOriginTabView;

            if (e.DataView.Properties.TryGetValue(DataIdentifier, out obj) && e.DataView.Properties.TryGetValue(DataTabView, out objOriginTabView))
            {
                // TODO - BUG: obj should never be null, but occassionally is. Why?
                if (obj == null || objOriginTabView == null)
                {
                    return;
                }

                var originTabView      = objOriginTabView as TabView;
                var destinationTabView = sender as TabView;
                var destinationItems   = destinationTabView.TabItems;
                var tabViewItem        = obj as TabViewItem;

                if (destinationItems != null)
                {
                    // First we need to get the position in the List to drop to
                    var index = -1;

                    // Determine which items in the list our pointer is inbetween.
                    for (int i = 0; i < destinationTabView.TabItems.Count; i++)
                    {
                        var item = destinationTabView.ContainerFromIndex(i) as TabViewItem;

                        if (e.GetPosition(item).X - item.ActualWidth < 0)
                        {
                            index = i;
                            break;
                        }
                    }

                    // Remove item from the old TabView
                    originTabView.TabItems.Remove(tabViewItem);

                    if (index < 0)
                    {
                        // We didn't find a transition point, so we're at the end of the list
                        destinationItems.Add(tabViewItem);
                    }
                    else if (index < destinationTabView.TabItems.Count)
                    {
                        // Otherwise, insert at the provided index.
                        destinationItems.Insert(index, tabViewItem);
                    }

                    // Select the newly dragged tab
                    destinationTabView.SelectedItem = tabViewItem;
                }
            }
        }
Пример #19
0
        private async void Files_Drop(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.StorageItems))
            {
                var items = await e.DataView.GetStorageItemsAsync();

                ViewModel.ProcessDroppedFiles(items);
            }
        }
Пример #20
0
 private void Files_DragOver(object sender, Windows.UI.Xaml.DragEventArgs e)
 {
     if (e.DataView.Contains(StandardDataFormats.StorageItems))
     {
         e.AcceptedOperation = DataPackageOperation.Copy;
         e.DragUIOverride.IsCaptionVisible = true;
         e.DragUIOverride.Caption          = "Add files";
     }
 }
Пример #21
0
        protected override void OnDrop(Windows.UI.Xaml.DragEventArgs args)
        {
            if (!args.Handled && args.AcceptedOperation == DataPackageOperation.Move)
            {
                TreeViewItem droppedOnItem = this;
                var          treeView      = AncestorTreeView;
                if (treeView != null)
                {
                    var treeViewList = treeView.ListControl;
                    var droppedNode  = treeViewList.DraggedTreeViewNode;
                    if (droppedNode != null)
                    {
                        if (treeViewList.IsMutiSelectWithSelectedItems)
                        {
                            var droppedOnNode = treeView.NodeFromContainer(droppedOnItem);
                            var selectedRoots = treeViewList.GetRootsOfSelectedSubtrees();
                            foreach (var node in selectedRoots)
                            {
                                var nodeIndex = treeViewList.FlatIndex(node);
                                if (treeViewList.IsFlatIndexValid(nodeIndex))
                                {
                                    treeViewList.RemoveNodeFromParent(node);
                                    ((TreeViewNodeVector)droppedOnNode.Children).Append(node);
                                }
                            }

                            args.Handled = true;
                            treeView.MutableListControl.OnDropInternal(args);
                        }
                        else
                        {
                            var droppedOnNode = treeView.NodeFromContainer(droppedOnItem);

                            // Remove the item that was dragged
                            int removeIndex = droppedNode.Parent.Children.IndexOf(droppedNode);

                            if (droppedNode != droppedOnNode)
                            {
                                ((TreeViewNodeVector)droppedOnNode.Parent.Children).RemoveAt(removeIndex);

                                // Append the dragged dropped item as a child of the node it was dropped onto
                                ((TreeViewNodeVector)droppedOnNode.Children).Append(droppedNode);

                                // If not set to true then the Reorder code of listview will override what is being done here.
                                args.Handled = true;
                                treeView.MutableListControl.OnDropInternal(args);
                            }
                            else
                            {
                                args.AcceptedOperation = DataPackageOperation.None;
                            }
                        }
                    }
                }
            }
            base.OnDrop(args);
        }
Пример #22
0
        protected override void OnDragEnter(Windows.UI.Xaml.DragEventArgs args)
        {
            TreeViewItem draggedOverItem = this;

            args.AcceptedOperation             = DataPackageOperation.None;
            args.DragUIOverride.IsGlyphVisible = true;

            var treeView = AncestorTreeView;

            if (treeView != null && treeView.CanReorderItems && !args.Handled)
            {
                var          treeViewList = treeView.ListControl;
                TreeViewNode draggedNode  = treeViewList.DraggedTreeViewNode;
                if (draggedNode != null)
                {
                    TreeViewNode draggedOverNode = treeView.NodeFromContainer(draggedOverItem);
                    TreeViewNode walkNode        = draggedOverNode.Parent;

                    while (walkNode != null && walkNode != draggedNode)
                    {
                        walkNode = walkNode.Parent;
                    }

                    if (walkNode != draggedNode && draggedNode != draggedOverNode)
                    {
                        args.AcceptedOperation = DataPackageOperation.Move;
                    }

                    TreeViewNode droppedOnNode = TreeNode;
                    if (droppedOnNode != draggedNode)                     // Don't expand if drag hovering on itself.
                    {
                        // Set up timer.
                        if (!draggedOverNode.IsExpanded && draggedOverNode.HasChildren)
                        {
                            if (m_expandContentTimer != null)
                            {
                                var expandContentTimer = m_expandContentTimer;
                                expandContentTimer.Stop();
                                expandContentTimer.Start();
                            }
                            else
                            {
                                // Initialize timer.
                                TimeSpan interval           = new TimeSpan(c_dragOverInterval);
                                var      expandContentTimer = new DispatcherTimer();
                                m_expandContentTimer        = expandContentTimer;
                                expandContentTimer.Interval = interval;
                                expandContentTimer.Tick    += OnExpandContentTimerTick;
                                expandContentTimer.Start();
                            }
                        }
                    }
                }
            }

            base.OnDragEnter(args);
        }
Пример #23
0
        private async void ExtendedPostingView_OnDrop(object sender, DragEventArgs e) {
            if (!e.DataView.Contains(StandardDataFormats.StorageItems))
                return;

            var items = await e.DataView.GetStorageItemsAsync();
            foreach (IStorageFile file in items.OfType<IStorageFile>()) {
                await ViewModel.Attach(file);

            }
        }
Пример #24
0
 private void Output_DragOver(object sender, Windows.UI.Xaml.DragEventArgs e)
 {
     if (e.DataView.Contains(StandardDataFormats.StorageItems)
         )//&& !e.DataView.AvailableFormats.Contains("FileOpFlags")) // Removes special environment folders that don't "drop"
     {
         e.AcceptedOperation = DataPackageOperation.Copy;
         e.DragUIOverride.IsCaptionVisible = true;
         e.DragUIOverride.Caption          = "Set output folder";
     }
 }
Пример #25
0
 private void Grid_DragOver(object sender, DragEventArgs e)
 {
         e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
         e.AcceptedOperation = DataPackageOperation.Copy;
         e.DragUIOverride.Caption = "Copy"; 
    
         e.DragUIOverride.IsCaptionVisible = true; 
         e.DragUIOverride.IsContentVisible = true; 
         e.DragUIOverride.IsGlyphVisible = true; 
 }
Пример #26
0
        private async void CurrentCardsListView_Drop(object sender, DragEventArgs e)
        {
            if (!e.Data.GetView().AvailableFormats.Contains("text"))
                return;

            string cardNames = (string)await e.Data.GetView().GetTextAsync("text");
            Dominion.Card[] cards = cardNames.Split(',').Select(cardName => DominionCard.Create(cardName).dominionCard).ToArray();
            Dominion.Strategy.Description.StrategyDescription strategy = this.StrategyDescription.ConvertToDominionStrategy();
            strategy = strategy.AddCardsToPurchaseOrder(cards);
            this.StrategyDescription.PopulateFrom(strategy);
        }
Пример #27
0
        private async void Output_Drop(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.StorageItems))
            {
                var items = await e.DataView.GetStorageItemsAsync();

                if (items.OfType <StorageFolder>().FirstOrDefault() is StorageFolder folder)
                {
                    ViewModel.ProcessExportFolder(folder);
                }
            }
        }
        private void OnFileDragOver(object sender, DragEventArgs e)
        {
            e.AcceptedOperation = DataPackageOperation.Copy;

            if (e.DragUIOverride != null)
            {
                e.DragUIOverride.Caption = "Add file";
                e.DragUIOverride.IsContentVisible = true;
            }

            this.AddFilePanel.Visibility = Visibility.Visible;
        }
 private async void ImageGrid_Drop(object sender, DragEventArgs e)
 {
     if (e.DataView.Contains(StandardDataFormats.StorageItems))
     {
         var items = await e.DataView.GetStorageItemsAsync();
         if (items.Count > 0)
         {
             var storageFile = items[0] as StorageFile;
             _oriFile = storageFile;
             await ShowImage();
         }
     }
 }
Пример #30
0
        private async void DropTarget_Drop(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            try
            {
                var text = await e.DataView.GetTextAsync();

                DropTargetTextBlock.Text = text;
            }
            catch (Exception ex)
            {
                ExceptionMessage.Text = ex.ToString();
            }
        }
Пример #31
0
        private async void TreeView_Drop(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            try
            {
                var text = await e.DataView.GetTextAsync();

                Results.Text = "Dropped: " + text;
            }
            catch (Exception ex)
            {
                ExceptionMessage.Text = ex.ToString();
            }
        }
		private async void Canvas_Drop(object sender, DragEventArgs e)
		{
			DataTemplate dataTemplate = this.Resources["PlayerElementTemplate"] as DataTemplate;
			var elem = dataTemplate.LoadContent() as FrameworkElement;

			var pname = await e.DataView.GetTextAsync();
			elem.DataContext = App.MainViewModel.SelectedTeam.Players.First((pl) => pl.Name == pname);

			var p = e.GetPosition(Canvas);
			Canvas.SetLeft(elem, p.X);
			Canvas.SetTop(elem, p.Y);
			Canvas.Children.Add(elem);
		}
        private async void Grid_OnDrop(object sender, DragEventArgs e)
        {
            Locator.ViewModels.NewThreadVm.IsLoading = true;
            var d = e.GetDeferral();

            var files = await e.DataView.GetStorageItemsAsync();
            foreach (var file in files)
            {
                await Locator.ViewModels.NewThreadVm.ImgurAddImageCommand.AddImgurImage(file as StorageFile, ReplyText);
            }
            d.Complete();
            Locator.ViewModels.NewThreadVm.IsLoading = false;
        }
Пример #34
0
 private async void Grid_Drop(object sender, DragEventArgs e)
 {
     if (e.DataView.Contains(StandardDataFormats.StorageItems))
     {
         var items = await e.DataView.GetStorageItemsAsync();
         if (items.Count > 0)
         {
             var storageFile = items[0] as StorageFile;
             var bitmapImage = new BitmapImage();
             bitmapImage.SetSource(await storageFile.OpenAsync(FileAccessMode.Read));
             Collage.Source = bitmapImage;
         }
     }
 }
Пример #35
0
        private void GridViewDrop(object sender, DragEventArgs e)
        {
            object gridSource;
            e.Data.Properties.TryGetValue("gridSource", out gridSource);

            if (gridSource == sender)
                return;

            object sourceItem;
            e.Data.Properties.TryGetValue("item", out sourceItem);
            if (sourceItem == null)
                return;

            _mainViewModel.SwitchItem((DemoItem)sourceItem);
        }
        private void StackPanel_DragOver(object sender, DragEventArgs e)
        {
            // using Windows.ApplicationModel.DataTransfer;
            e.AcceptedOperation = DataPackageOperation.Copy;

            // Drag adorner ... change what mouse / icon looks like
            // as you're dragging the file into the app:
            // http://igrali.com/2015/05/15/drag-and-drop-photos-into-windows-10-universal-apps/
            e.DragUIOverride.Caption = "drop to create a custom sound and tile";
            e.DragUIOverride.IsCaptionVisible = true;
            e.DragUIOverride.IsContentVisible = true;
            e.DragUIOverride.IsGlyphVisible = true;
            //e.DragUIOverride.SetContentFromBitmapImage(new BitmapImage(new Uri("ms-appx:///Assets/clippy.jpg")));

        }
Пример #37
0
        /// <summary>
        /// Drop: restore the background and append the dragged text
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void TargetTextBox_Drop(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            VisualStateManager.GoToState(this, "Outside", true);
            bool hasText = e.DataView.Contains(StandardDataFormats.Text);

            // if the result of the drop is not too important (and a text copy should have no impact on source)
            // we don't need to take the deferral and this will complete the operation faster
            e.AcceptedOperation = hasText ? DataPackageOperation.Copy : DataPackageOperation.None;
            if (hasText)
            {
                var text = await e.DataView.GetTextAsync();

                TargetTextBox.Text += text;
            }
        }
Пример #38
0
        protected override void OnDragOver(Windows.UI.Xaml.DragEventArgs args)
        {
            var treeView = AncestorTreeView;

            if (treeView != null && !args.Handled)
            {
                var          treeViewList    = treeView.ListControl;
                TreeViewItem draggedOverItem = this;
                TreeViewNode draggedOverNode = treeView.NodeFromContainer(draggedOverItem);
                TreeViewNode draggedNode     = treeViewList.DraggedTreeViewNode;

                if (draggedNode != null && treeView.CanReorderItems)
                {
                    if (treeViewList.IsMutiSelectWithSelectedItems)
                    {
                        if (treeViewList.IsSelected(draggedOverNode))
                        {
                            args.AcceptedOperation = DataPackageOperation.None;
                            treeView.MutableListControl.SetDraggedOverItem(null);
                        }
                        else
                        {
                            args.AcceptedOperation = DataPackageOperation.Move;
                            treeView.MutableListControl.SetDraggedOverItem(draggedOverItem);
                        }
                    }
                    else
                    {
                        TreeViewNode walkNode = draggedOverNode.Parent;
                        while (walkNode != null && walkNode != draggedNode)
                        {
                            walkNode = walkNode.Parent;
                        }

                        var mutableTreeViewList = treeView.MutableListControl;
                        if (walkNode != draggedNode && draggedNode != draggedOverNode)
                        {
                            args.AcceptedOperation = DataPackageOperation.Move;
                            mutableTreeViewList.SetDraggedOverItem(draggedOverItem);
                        }

                        treeViewList.UpdateDropTargetDropEffect(false, false, null);
                    }
                }
            }

            base.OnDragOver(args);
        }
Пример #39
0
 private void DropGrid_DragOver(object sender, DragEventArgs e)
 {
     e.AcceptedOperation = DataPackageOperation.Copy;
     if (e.DataView.Contains(StandardDataFormats.StorageItems))
     {
         //var items = await e.DataView.GetStorageItemsAsync();
         //if (items.Any() && (items[0].Name.ToLowerInvariant().Contains(".jpg")))
         //    {
         //        e.DragUIOverride.Caption = "Dragging JPEG file";
         //        e.DragUIOverride.IsCaptionVisible = true;
         //        e.DragUIOverride.IsContentVisible = true;
         //        e.DragUIOverride.IsGlyphVisible = true;
         //    }
     }
     //e.DragUIOverride.SetContentFromBitmapImage(new BitmapImage(new Uri("ms-appx:///Assets/clippy.jpg")));
 }
Пример #40
0
 private async void OnFileDrop(object sender, DragEventArgs e)
 {
     if (e.DataView.Contains(StandardDataFormats.StorageItems))
     {
         var items = await e.DataView.GetStorageItemsAsync();
         if (items.Count > 0)
         {
             List<StorageFile> files = new List<StorageFile>();
             foreach (var item in items.OfType<StorageFile>().Select(storageFile => new AppFile { Name = storageFile.Name, File = storageFile }))
             {
                 files.Add(item.File);
             }
             Messenger.Default.Send<NotificationMessage<IReadOnlyList<StorageFile>>>(new NotificationMessage<IReadOnlyList<StorageFile>>(files, "fromDragDrop"));
         }
     }
 }
Пример #41
0
        private async void txtTextToSay_Drop(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.Text))
            {
                try
                {
                    string copiedData = await e.DataView.GetTextAsync();

                    ViewModel.Text += copiedData;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }
        }
        private async void Grid_Drop(object sender, DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.StorageItems))
            {
                var storageItem = await e.DataView.GetStorageItemsAsync();
                if (storageItem != null)
                {
                    var bmImage = new BitmapImage();
                    bmImage.SetSource(await (storageItem.First() as StorageFile).OpenReadAsync());

                    Image img = new Image();
                    img.Source = bmImage;
                    ListViewForItems.Items.Add(img);
                }               
            }
        }
Пример #43
0
        void HandleDragLeave(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            var package       = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage;
            var dragEventArgs = new DragEventArgs(package);

            SendEventArgs <DropGestureRecognizer>(rec =>
            {
                if (!rec.AllowDrop)
                {
                    return;
                }

                e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
                rec.SendDragLeave(dragEventArgs);
            });
        }
        private async void OnFileDrop(object sender, DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.StorageItems))
            {
                var items = await e.DataView.GetStorageItemsAsync();
                if (items.Count > 0)
                {
                    foreach (var appFile in items.OfType<StorageFile>().Select(storageFile => new AppFile { Name = storageFile.Name, File = storageFile }))
                    {
                        this.Files.Add(appFile);
                    }
                }
            }

            this.AddFilePanel.Visibility = Visibility.Collapsed;
        }
Пример #45
0
        private async void Grid_Drop(object sender, DragEventArgs e)
        {


            var files = await e.DataView.GetStorageItemsAsync();

            foreach (StorageFile file in files)
            {
                try
                {
                    BitmapImage bi = new BitmapImage();
                    bi.SetSource(await file.OpenAsync(FileAccessMode.Read));
                    items.Add(new BitmapItem() { Source = bi });
                }
                catch { }
            }
            listView.ItemsSource = items;
        }
Пример #46
0
        void HandleDragOver(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            var package       = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage;
            var dragEventArgs = new DragEventArgs(package);

            SendEventArgs <DropGestureRecognizer>(rec =>
            {
                if (!rec.AllowDrop)
                {
                    e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.None;
                    return;
                }

                rec.SendDragOver(dragEventArgs);
                var result          = (int)dragEventArgs.AcceptedOperation;
                e.AcceptedOperation = (Windows.ApplicationModel.DataTransfer.DataPackageOperation)result;
            });
        }
Пример #47
0
 private async void DropGrid_Drop(object sender, DragEventArgs e)
 {
     if (e.DataView.Contains(StandardDataFormats.StorageItems))
     {
         var items = await e.DataView.GetStorageItemsAsync();
         if (items.Any())
         {
             DroppedBlock.Text = items[0].Name;
             if (items[0].Name.ToLowerInvariant().Contains(".jpg"))
             {
                 var file = items[0] as StorageFile;
                 var bitmap = new BitmapImage();
                 bitmap.SetSource(await file.OpenAsync(FileAccessMode.Read));
                 DroppedImage.Source = bitmap;
             }
         }
     }
 }
        private async void Image_Drop(object sender, DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.StorageItems))
            {
                var items = await e.DataView.GetStorageItemsAsync();

                if (items.Any())
                {
                    var storageFile = items[0] as StorageFile;

                    if (storageFile.ContentType.Contains("image"))
                    {
                        var viewModel = DataContext as ViewModels.TodoItemViewModel;
                        viewModel.SavePictureCommand.Execute(storageFile);
                    }
                }
            }
        }
Пример #49
0
        protected override void OnDragLeave(Windows.UI.Xaml.DragEventArgs args)
        {
            if (!args.Handled)
            {
                var treeView = AncestorTreeView;
                if (treeView != null)
                {
                    var treeViewList = treeView.ListControl;
                    treeViewList.SetDraggedOverItem(null);
                }

                if (m_expandContentTimer != null)
                {
                    m_expandContentTimer.Stop();
                }
            }

            base.OnDragLeave(args);
        }
Пример #50
0
		private async void UnorganizedListView_OnDrop(object sender, DragEventArgs e)
		{
			if (e.DataView.Contains(StandardDataFormats.StorageItems))
			{
				var storageItems = await e.DataView.GetStorageItemsAsync();

				foreach (StorageFile storageItem in storageItems)
				{
					var bitmapImage = new BitmapImage();
					await bitmapImage.SetSourceAsync(await storageItem.OpenReadAsync());

					var myItem = new MyItem
					{
						Id = Guid.NewGuid(),
						Image = bitmapImage
					};

					this.MyItems.Add(myItem);
				}
			}
		}
        private async void StackPanel_Drop(object sender, DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.StorageItems))
            {
                var items = await e.DataView.GetStorageItemsAsync();

                if (items.Any())
                {
                    var storageFile = items[0] as StorageFile;
                    var contentType = storageFile.ContentType;

                    StorageFolder folder = ApplicationData.Current.LocalFolder;

                    PathTextBox.Text = folder.Path;

                    if (contentType == "image/png" || contentType == "image/jpeg")
                    {
                        StorageFile newFile = await storageFile.CopyAsync(folder, storageFile.Name, NameCollisionOption.GenerateUniqueName);
                        var bitmapImage = new BitmapImage();
                        bitmapImage.SetSource(await storageFile.OpenAsync(FileAccessMode.Read));
                        ImageViewer.Source = bitmapImage;
                    }
                    else if (contentType == "audio/wav" || contentType == "audio/mpeg")
                    {
                        StorageFile newFile = await storageFile.CopyAsync(folder, storageFile.Name, NameCollisionOption.GenerateUniqueName);
                        /* Creating a marker ... could come in handy.
                        MediaPlayer.Markers.Clear();
                        MediaPlayer.MarkerReached += MediaPlayer_MarkerReached;
                        var marker = new TimelineMarker();
                        marker.Time = new TimeSpan(0, 0, 3);
                        MediaPlayer.Markers.Add(marker);
                        */
                        MediaPlayer.SetSource(await storageFile.OpenAsync(FileAccessMode.Read), contentType);
                        MediaPlayerStoryboard.Begin();
                        //MediaPlayer.Source = new Uri(somesuch, UriKind.Absolute);
                    }
                }
            }
        }
Пример #52
0
		private async void ListView_Drop(object sender, DragEventArgs e)
		{
			if (e.DataView.Contains(StandardDataFormats.Text))
			{
				var id = await e.DataView.GetTextAsync();
				var itemIdsToMove = id.Split(',');

				var destinationListView = sender as ListView;
				var listViewItemsSource = destinationListView?.ItemsSource as ObservableCollection<MyItem>;

				if (listViewItemsSource != null)
				{
					foreach (var itemId in itemIdsToMove)
					{
						var itemToMove = this.MyItems.First(i => i.Id.ToString() == itemId);

						listViewItemsSource.Add(itemToMove);
						this.MyItems.Remove(itemToMove);
					}
				}
			}
		}
Пример #53
0
        private void Control_Drop(object sender, Windows.UI.Xaml.DragEventArgs e)
        {
            var item = (e.Data.Properties[DragItemKey] as ViewCell).BindingContext;
            var cc   = e.GetDeferral();

            e.AcceptedOperation = DataPackageOperation.Move;

            var sourceItems      = e.Data.Properties[SourceItemsKey] as IList;
            var destinationItems = Element.ItemsSource as IList;

            var originalSrc = e.OriginalSource as FrameworkElement;

            var dataContext = originalSrc.DataContext;

            var currentItem = (dataContext as CollectionViewSource).View.CurrentItem;

            if (dataContext is CollectionViewSource)
            {
                destinationItems.Add(item);
            }
            else if (dataContext is ViewCell)
            {
                var x = destinationItems.IndexOf((dataContext as ViewCell).BindingContext);

                destinationItems.Insert(x, item);
            }
            else if (dataContext is CellItem)
            {
                var x = destinationItems.IndexOf((dataContext as CellItem));

                destinationItems.Insert(x, item);
            }

            sourceItems.Remove(item);

            cc.Complete();
        }
Пример #54
0
        /// <summary>
        /// We need to return the effective operation from Drop
        /// This is not important for our source ListView, but it might be if the user
        /// drags text from another source
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void TargetListView_Drop(object sender, DragEventArgs e)
        {
            if (e.DataView.Contains(StandardDataFormats.Text))
            {
                var def = e.GetDeferral();
                var id = await e.DataView.GetTextAsync();
                var itemIdsToMove = id.Split(',');

                var destinationListView = sender as ListView;
                var listViewItemsSource = destinationListView?.ItemsSource as ObservableCollection<Palestrante>;

                if (listViewItemsSource != null)
                {
                    foreach (var itemId in itemIdsToMove)
                    {
                        var itemToMove = ListSource.First(i => i.nome.ToString() == itemId);
                        listViewItemsSource.Add(itemToMove);
                        //ListSource.Remove(itemToMove);
                    }
                }
                e.AcceptedOperation = DataPackageOperation.Copy;
                def.Complete();
            }
        }
Пример #55
0
        private void gview_DragEnter(object sender, DragEventArgs e)
        {
            viewmodel.BooksScroll = ScrollMode.Disabled;

            //Drag from shelf back to main
            object sourceItem;
            object s;
            e.DragUIOverride.IsGlyphVisible = false;
            e.DragUIOverride.IsCaptionVisible = false;

            e.Data.Properties.TryGetValue("gridSource", out s);
            // If it is being dragged back onto the shelf, do nothing an return
            if (sender == s)
            {
               //viewmodel.ShelfBrush = _shelfBrushColor;
              //  viewmodel.GridBrush = _gridBrushColor;
                e.Handled = true;
                return;
            }

            e.Data.Properties.TryGetValue("item", out sourceItem);
            e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Move;
            viewmodel.GridBrush = new SolidColorBrush(Colors.DarkOliveGreen);
        }
Пример #56
0
 /// <summary>
 /// DragLeave: Restore previous background
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TargetTextBox_DragLeave(object sender, Windows.UI.Xaml.DragEventArgs e)
 {
     VisualStateManager.GoToState(this, "Outside", true);
 }
Пример #57
0
 private void Page_DragOver(object sender, Windows.UI.Xaml.DragEventArgs e)
 {
     DragIcon.Visibility = Visibility.Visible;
 }
Пример #58
0
 private void StackPanel_Drop(object sender, DragEventArgs e)
 {
 }
Пример #59
0
 private void Page_DragLeave(object sender, Windows.UI.Xaml.DragEventArgs e)
 {
     DragIcon.Visibility = Visibility.Collapsed;
 }
Пример #60
0
 private void dragEnter_GameArea(object sender, Windows.UI.Xaml.DragEventArgs e)
 {
     //TODO
 }