private void DragGestureRecognizer_DragStarting(object sender, DragStartingEventArgs e) { Image image = (sender as Element)?.Parent as Image; image.Opacity = 0.4; e.Data.Properties.Add("Demo", image); }
/// <summary> /// Event invoked when the user drags an Asset from the rightmost sidebar. /// Adds the Asset's data to argument data. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void TabControlAssetsButton_DragStarting(UIElement sender, DragStartingEventArgs args) { args.Data.Properties.Add(Group, sender); args.Data.Properties.Add("action", DragStartingId); args.Data.Properties.Add("xClicked", (int)(lastPositionClicked.X)); args.Data.Properties.Add("yClicked", (int)(lastPositionClicked.Y)); }
private void OnDragStarting(UIElement sender, DragStartingEventArgs args) { IEnumerable <DbMediaFile> files = null; var _vm = DataContext as CommonViewItemModel; switch (_vm.Type) { case CommonItemType.Album: files = _vm.InternalDbEntityId.GetAlbumById() .MediaFiles .OrderBy(c => c.DiscNumber) .ThenBy(c => c.TrackNumber); break; case CommonItemType.Artist: files = _vm.InternalDbEntityId.GetArtistById() .MediaFiles .OrderBy(c => c.Album) .ThenBy(c => c.DiscNumber) .ThenBy(c => c.TrackNumber); break; } if (files != null) { args.DragUI.SetContentFromDataPackage(); args.Data.RequestedOperation = DataPackageOperation.Copy; args.Data.SetText(DragHelper.Add(files)); } }
private void SectionOnDragStarting(UIElement sender, DragStartingEventArgs args) { lock (_sectionLock) { _sourceSection = sender as HubSection; } }
private void dragGrid3_DragStarting(UIElement sender, DragStartingEventArgs args) { args.Data.SetText(sourceTextBlock3.Text); // drag 过程中的 ui 为指定的 BitmapImage args.DragUI.SetContentFromBitmapImage(new BitmapImage(new Uri("ms-appx:///Assets/hololens.jpg", UriKind.Absolute))); }
private void dragStart(UIElement sender, DragStartingEventArgs args) { TextBlock block = sender as TextBlock; args.Data.SetText(block.Text); args.Data.RequestedOperation = DataPackageOperation.Copy; }
private void dragGrid2_DragStarting(UIElement sender, DragStartingEventArgs args) { args.Data.SetText(sourceTextBlock2.Text); // 由系统根据 DataPackage 中保存的数据的类型来决定 drag 过程中的 ui args.DragUI.SetContentFromDataPackage(); }
internal DragItemsStartingEventArgs(DragStartingEventArgs inner, IList <object> items) { _inner = inner; Data = _inner.Data; Items = items; }
protected async void Item_DragStarting(object sender, DragStartingEventArgs e) { List <IStorageItem> selectedStorageItems = new List <IStorageItem>(); foreach (ListedItem item in App.CurrentInstance.ContentPage.SelectedItems) { if (item.PrimaryItemAttribute == StorageItemTypes.File) { selectedStorageItems.Add(await StorageFile.GetFileFromPathAsync(item.ItemPath)); } else if (item.PrimaryItemAttribute == StorageItemTypes.Folder) { selectedStorageItems.Add(await StorageFolder.GetFolderFromPathAsync(item.ItemPath)); } } if (selectedStorageItems.Count == 0) { e.Cancel = true; return; } e.Data.SetStorageItems(selectedStorageItems); e.DragUI.SetContentFromDataPackage(); }
private void Task_DragStarting(UIElement sender, DragStartingEventArgs args) { if (sender is UserControl s) { _draggingElementVm = s.DataContext; } }
protected async void Item_DragStarting(object sender, DragStartingEventArgs e) { List <IStorageItem> selectedStorageItems = new List <IStorageItem>(); foreach (ListedItem item in ParentShellPageInstance.ContentPage.SelectedItems) { if (item is ShortcutItem) { // Can't drag shortcut items continue; } else if (item.PrimaryItemAttribute == StorageItemTypes.File) { selectedStorageItems.Add(await ParentShellPageInstance.FilesystemViewModel.GetFileFromPathAsync(item.ItemPath)); } else if (item.PrimaryItemAttribute == StorageItemTypes.Folder) { selectedStorageItems.Add(await ParentShellPageInstance.FilesystemViewModel.GetFolderFromPathAsync(item.ItemPath)); } } if (selectedStorageItems.Count == 0) { e.Cancel = true; return; } e.Data.SetStorageItems(selectedStorageItems, false); e.DragUI.SetContentFromDataPackage(); }
private void OnDragStarting(object sender, DragStartingEventArgs e) { DragGestureRecognizer card = (sender as DragGestureRecognizer); INoteModel DaNote = (card.BindingContext as HLinkNoteModel).DeRef; e.Data.Text = DaNote.GetDefaultText; }
private void Grid_DragStarting2(UIElement sender, DragStartingEventArgs args) { //if((sender as Grid)?.DataContext is Epage item) //{ // args.AllowedOperations = DataPackageOperation.Link; // args.Data.SetData(EPAGE, item); //} }
private void AccountControl_DragStarting(UIElement sender, DragStartingEventArgs args) { if ((sender as AccountControl)?.DataContext is Account account) { args.AllowedOperations = DataPackageOperation.Link; args.Data.SetData(accountId, account.Id); } }
private void TimelineItem_DragStarting(UIElement sender, DragStartingEventArgs args) { var p1 = args.GetPosition(this); var p2 = args.GetPosition(sender); var p3 = p1.X - p2.X / logicDpiScale; args.Data.Properties.Add("test", p3); }
private void OnDragStarting(UIElement sender, DragStartingEventArgs args) { var playlist = (sender as FrameworkElement).DataContext as Playlist; args.DragUI.SetContentFromDataPackage(); args.Data.RequestedOperation = DataPackageOperation.Copy; args.Data.SetText(DragHelper.Add(playlist)); }
private void DragGestureRecognizer_DragStarting(object sender, DragStartingEventArgs e) { var label = (Label)((Element)sender).Parent; Debug.WriteLine($"DragGestureRecognizer_DragStarting [{label.Text}]"); e.Data.Properties["Label"] = label; }
private void Container_DragStarting(UIElement sender, DragStartingEventArgs args) { var deferral = args.GetDeferral(); var container = (ListViewItem)sender; args.Data.SetData("number", container.Content); deferral.Complete(); }
/// <summary> /// Saves the position where the user started dragging an Asset menu item. /// Called when a drag operation starts on an Asset object. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void UserControl_DragStarting(UIElement sender, DragStartingEventArgs args) { var asset = sender as Marbles.Asset; args.Data.Properties.Add("assetDragged", asset); args.Data.Properties.Add("xClicked", (int)(lastPositionClicked.X)); args.Data.Properties.Add("yClicked", (int)(lastPositionClicked.Y)); }
private void StackPanel_DragStarting(UIElement sender, DragStartingEventArgs args) { Grid send = (Grid)sender; var songid = send.Tag.ToString(); args.Data.SetText(songid); args.Data.RequestedOperation = DataPackageOperation.Copy; }
private void TextBlock_DragStarting(UIElement sender, DragStartingEventArgs args) { if ((sender as StackPanel)?.DataContext is TaskDto task) { args.AllowedOperations = DataPackageOperation.Move; args.Data.SetData("ID", task.Id); } }
// dragGrid1 开始 drag 时触发的事件 private void dragGrid1_DragStarting(UIElement sender, DragStartingEventArgs args) { lblMsg.Text += "dragGrid1_DragStarting"; lblMsg.Text += Environment.NewLine; // 通过 DataPackage 保存文本数据(关于 DataPackage 的详细说明请参见“分享”部分) // 一个 DataPackage 对象可以包含多种类型的数据:ApplicationLink, WebLink, Bitmap, Html, Rtf, StorageItems, Text args.Data.SetText(sourceTextBlock.Text); }
private async void OnImageDragStarting(UIElement sender, DragStartingEventArgs args) { var response = (ImageResponse)((Image)sender).DataContext; var content = await response.GetResponseContentAsync(); var file = await DataTransferHelper.CreateTemporaryFileAsync(content.stream, content.contentType); args.Data.SetStorageItems(new[] { file }); }
// dragGrid2 开始 drag 时触发的事件 private void dragGrid2_DragStarting(UIElement sender, DragStartingEventArgs args) { lblMsg.Text += "dragGrid2_DragStarting"; lblMsg.Text += Environment.NewLine; RandomAccessStreamReference imageStreamRef = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/hololens.jpg", UriKind.Absolute)); // 通过 DataPackage 保存图片数据 args.Data.SetBitmap(imageStreamRef); }
private void Grid_DragStarting(UIElement sender, DragStartingEventArgs args) { args.AllowedOperations = DataPackageOperation.Copy; var song = (sender as Grid).DataContext as Song; this.draggedSong = song; DateTime today = DateTime.Today; draggedSong.addedAt = today.ToString("dd/MM/yyyy"); }
private async void myImage_DragStarting(UIElement sender, DragStartingEventArgs args) { var folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("img"); var file = await folder.GetFileAsync("DMX_TechSummit.jpg"); var files = new List<StorageFile>(); files.Add(file); args.Data.SetStorageItems(files); }
/// <summary> /// Adds the center coord /// </summary> /// <param name="sender"></param> /// <param name="args"></param> private void PartDragStarting(UIElement sender, DragStartingEventArgs args) { //// Get the position of the click relative to the dragged control //var startPosition = args.GetPosition(sender); //// Try to cast the sender's DataContext to BasePart //var castedSender = (sender as UserControl).DataContext as BasePart; //// If we couldn't, cancel the drag event //if (castedSender == null) //{ // args.Cancel = true; //} //Position pos = new Position(); //// Get the center coord of the dragged part //pos.Absolute = castedSender.CenterCoord; //// Calculate the shift applied during drop (because parts can be dragged not only be center but on the whole area) //// It's half of dimensions minus relative click position //pos.Shift.X = castedSender.Width / 2 - startPosition.X; //pos.Shift.Y = castedSender.Height / 2 - startPosition.Y; //// Store these 2 values in the IoC //try //{ // // RESERVE_IOC PositionBeforeDrag // IoC.Add(pos, "PositionBeforeDrag"); //} //catch (Exception) //{ // // If it wasn't possible // if (IoC.Remove("PositionBeforeDrag")) // { // // And it was due to the fact that IoC already had entries under these names (which are now removed) // try // { // // Try to add them once more // IoC.Add(pos, "PositionBeforeDrag"); // } // catch (Exception) // { // // If the operation failed again, cancel the drag event // args.Cancel = true; // } // } //} //args.DragUI.SetContentFromBitmapImage(new BitmapImage(new Uri("ms-appx:///Assets/Pictures/MoveObjectPicture.png")) //{ // DecodePixelHeight = 28, // DecodePixelWidth = 28, //}); }
private async void myImage_DragStarting(UIElement sender, DragStartingEventArgs args) { var folder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("img"); var file = await folder.GetFileAsync("DMX_TechSummit.jpg"); var files = new List <StorageFile>(); files.Add(file); args.Data.SetStorageItems(files); }
private void Actor_DragStarting(UIElement sender, DragStartingEventArgs args) { draggingActor = new TextBlock(); draggingActor.Text = ((TextBlock)sender).Text; draggingActor.FontSize = CurrentPen.Size * 4; draggingActor.IsColorFontEnabled = true; draggingActor.FontWeight = FontWeights.Bold; draggingActor.Foreground = new SolidColorBrush(CurrentPen.Color); draggingActor.CanDrag = true; draggingActor.DragStarting += ExistingActor_DragStarting; }
private void UserControl_DragStarting(UIElement sender, DragStartingEventArgs args) { try { args.Data.Properties.Add("ViewItem", DataContext); } catch (Exception ex) { TelemetryExtension.Current?.TrackException(ex); } }
private async void image1_DragStarting(UIElement sender, DragStartingEventArgs args) { args.Data.RequestedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy; var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"Assets\Alcatraz.JPG"); //To get a folder from the Assets folder... //var localizationDirectory = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync(@"Assets\Localization"); args.Data.SetStorageItems(new List<IStorageItem> { file }); }
private void NavigationViewItem_DragStarting(UIElement sender, DragStartingEventArgs args) { if (!((sender as Microsoft.UI.Xaml.Controls.NavigationViewItem).DataContext is LocationItem locationItem)) { return; } // Adding the original Location item dragged to the DragEvents data view var navItem = (sender as Microsoft.UI.Xaml.Controls.NavigationViewItem); args.Data.Properties.Add("sourceLocationItem", navItem); }
private void DragText_DragStarting(UIElement sender, DragStartingEventArgs args) { args.Data.SetText(DragText.Text); args.Data.SetRtf(DragText.Text); args.Data.RequestedOperation = SetRequestedOperation(); }
private void YesCalendarFlipView_DragStarting(UIElement sender, DragStartingEventArgs args) { Debug.WriteLine("Drag Starting"); }
async private void DragImage_DragStarting(UIElement sender, DragStartingEventArgs args) { // get the file StorageFolder installFolder = Windows.ApplicationModel.Package.Current.InstalledLocation; StorageFolder subFolder = await installFolder.GetFolderAsync("Assets"); var file = await subFolder.GetFileAsync("MSLogoImage.png"); // turn it into a stream and set it as a bitmap in the datapackage var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); args.Data.SetBitmap(RandomAccessStreamReference.CreateFromStream(stream)); // also set it as a file in the datapackage var files = new List<StorageFile>(); files.Add(file); args.Data.SetStorageItems(files); args.Data.RequestedOperation = SetRequestedOperation(); }
private static void Ctl_DragStarting(UIElement sender, DragStartingEventArgs args) { var element = sender as UIElement; var command = GetDragCommand(element); var parameter = GetDragCommandParameter(element); if (command != null) { if (command.CanExecute(parameter)) { command.Execute(parameter); } } }