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);
            }
        }
        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;
        }
示例#3
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();
        }
示例#4
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();
            }
        }
示例#5
0
 public async void dropimg(object sender, DragEventArgs e)
 {
     DragOperationDeferral defer = e.GetDeferral();
     try
     {
         DataPackageView data_view = e.DataView;
         string str = await clipboard(data_view);
         clipboard_substitution(str);
     }
     finally
     {
         defer.Complete();
     }
 }
示例#6
0
 public async void Dropimg(object sender, DragEventArgs e)
 {
     if (Writetext)
     {
         return;
     }
     DragOperationDeferral defer = e.GetDeferral();
     try
     {
         DataPackageView dataView = e.DataView;
         string str = await _m.clipboard(dataView);
         Tianjia(str);
     }
     finally
     {
         defer.Complete();
     }
 }
 /// <summary>
 /// Drop on the Trash
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private async void TargetTextBlock_Drop(object sender, DragEventArgs e)
 {
     if (e.DataView.Contains(StandardDataFormats.Text))
     {
         // We need to take the deferral as the source will read _deletedItem which
         // we cannot set synchronously
         var def = e.GetDeferral();
         _deletedItem = await e.DataView.GetTextAsync();
         e.AcceptedOperation = DataPackageOperation.Move;
         def.Complete();
     }
 }
 /// <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)
 {
     // This test is in theory not needed as we returned DataPackageOperation.None if
     // the DataPackage did not contained text. However, it is always better if each
     // method is robust by itself
     if (e.DataView.Contains(StandardDataFormats.Text))
     {
         // We need to take a Deferral as we won't be able to confirm the end
         // of the operation synchronously
         var def = e.GetDeferral();
         var s = await e.DataView.GetTextAsync();
         var items = s.Split('\n');
         foreach (var item in items)
         {
             _selection.Add(item);
         }
         e.AcceptedOperation = DataPackageOperation.Copy;
         def.Complete();
     }
 }
示例#9
0
        static async void HandleDrop(DragEventArgs e, Action<StorageFile> handleDroppedFile)
        {
            if (!e.DataView.Contains(StandardDataFormats.StorageItems))
                return;

            var deferral = e.GetDeferral();

            try
            {
                var storageItems = await e.DataView.GetStorageItemsAsync();

                var file = GetSingleImageFile(storageItems);

                if (file != null)
                {
                    handleDroppedFile(file);

                    e.Handled = true;
                }
            }
            finally
            {
                deferral.Complete();
            }
        }
 private async void Image_Drop(object sender, DragEventArgs e)
 {
     var def = e.GetDeferral();
     var data = await e.DataView.GetTextAsync();
 }