private void AssociatedObject_Drop(object sender, DropEventArgs e) { System.Diagnostics.Debug.WriteLine("Drop"); DragSource dragSource = sender as DragSource; FrameworkElement fe = dragSource.AssociatedObject as FrameworkElement; Record record = fe.DataContext as Record; // XamDataGrid の取得 XamDataGrid presenter = record.DataPresenter as XamDataGrid; // ドラッグレコードの取得 ContentPresenter source = e.DragSource as ContentPresenter; DataRecord sourceRecord = source.DataContext as DataRecord; int sourceIndex = sourceRecord.Index; // ドロップレコードの取得 ContentPresenter target = e.DropTarget as ContentPresenter; DataRecord targetRecord = target.DataContext as DataRecord; int targetIndex = targetRecord.Index; var dc = presenter.DataContext; var vm = dc as MainWindowViewModel; // ドラッグレコードの位置変更 //vm.Tasks.Move(sourceIndex, targetIndex); }
void StreamListView_Drop(object sender, DropEventArgs e) { ClientStats.LogEvent("Drop label in stream"); var message = (Message)StreamListView.ItemContainerGenerator.ItemFromContainer(e.Target); if (e.Data as LabelsContainer != null) { var newLabel = (LabelsContainer)e.Data; message.AddLabel(new Label(newLabel.Labelname)); } // For fixed labels if (e.Source as RadioButton != null) { var control = (RadioButton)e.Source; var view = FoldersControl.GetActivityView(control); switch (view) { case ActivityView.Todo: message.AddLabel(new Label(LabelType.Todo)); break; case ActivityView.WaitingFor: message.AddLabel(new Label(LabelType.WaitingFor)); break; case ActivityView.Someday: message.AddLabel(new Label(LabelType.Someday)); break; } } }
private void OnDrop(object sender, DropEventArgs e) { if (!e.Data.Properties.ContainsKey("Source")) { return; } var sl = (sender as Element).Parent as StackLayout; if (e.Data.Properties["Source"] == sl) { return; } var color = e.Data.Properties["Color"] as SolidColorBrush; if (AllColors.Contains(color)) { AllColors.Remove(color); RainbowColors.Add(color); } else { RainbowColors.Remove(color); AllColors.Add(color); } SLAllColors.Background = SolidColorBrush.White; SLRainbow.Background = SolidColorBrush.White; }
private void DropGestureRecognizer_Drop(object sender, DropEventArgs e) { var box_view = e.Data.Properties["Demo"] as BoxView; var frame = (sender as Element)?.Parent as Frame; frame.Content = box_view; }
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}"); } }); }
void OnDrop(object sender, DropEventArgs e) { DependencyService.Get <TinyMessengerHub>() .Publish(new AddToCartMessage() { Gatos = DraggingGatos }); }
private void DropGestureRecognizer_Drop(object sender, DropEventArgs e) { double precoItem = (double)e.Data.Properties["Preco"]; Preco += precoItem; QuantidadeItens += 1; Carrinho.Text = $"Carrinho: {QuantidadeItens} item - {Preco.ToString("C")}"; }
public virtual bool CheckDrop(DropEventArgs drop) { if (!IsActive) { return(false); } //check if they clicked in the layout return(Layout.CheckDrop(drop) || Modal); }
private void DropGestureRecognizer_Drop(object sender, DropEventArgs e) { var data = e.Data.Properties["Text"].ToString(); //e.Data.GetTextAsync(); var frame = (sender as Element)?.Parent as Frame; frame.Content = new Label { Text = data }; }
private void OnRecordDragDrop(object sender, DropEventArgs dragInfo) { var result = VisualTreeHelper.HitTest(dragInfo.DropTarget, dragInfo.GetPosition(dragInfo.DropTarget)); var targetElement = Utilities.GetAncestorFromType(result.VisualHit, typeof(DataRecordPresenter), true) as DataRecordPresenter; if (targetElement != null) { DataRecord targetRecord = targetElement.DataRecord; IList targetList = GetSourceList(targetRecord); object targetItem = targetRecord.DataItem; Type targetType = targetItem.GetType(); DraggingData draggedData = dragInfo.Data as DraggingData; if (draggedData != null) { IList itemsList = draggedData.Items; object firstItem = itemsList[0]; IList <IList> listsList = draggedData.Lists; if (!targetType.IsInstanceOfType(firstItem)) { // the target type doesn't match the items we are dropping, get the child list from the parent if we have a property. if (draggedData.SourceProperty != null) { PropertyInfo listProperty = targetType.GetProperty(draggedData.SourceProperty); targetList = listProperty.GetValue(targetItem, null) as IList; if (targetList != null) { for (int i = itemsList.Count - 1; i >= 0; i--) { object currentItem = itemsList[i]; int targetIndex = targetList.IndexOf(targetItem); listsList[i].Remove(currentItem); targetList.Add(currentItem); } } } else { MessageBox.Show("Can't drop here"); } } else { for (int i = itemsList.Count - 1; i >= 0; i--) { object currentItem = itemsList[i]; int targetIndex = targetList.IndexOf(targetItem); listsList[i].Remove(currentItem); targetList.Insert(targetIndex, currentItem); } } } } }
private void DropGestureRecognizer_Drop(object sender, DropEventArgs e) { var data = e.Data.Properties["Demo"].ToString(); var stack = (sender as Element)?.Parent as StackLayout; stack.Children.Add(new Label { Text = data, TextColor = Color.Yellow, FontSize = 36, HorizontalTextAlignment = TextAlignment.Center }); label.Text = ""; }
async void OnDrop(object sender, DropEventArgs e) { Square square = (Square)e.Data.Properties["Square"]; if (square.Area.Equals(area)) { await DisplayAlert("Correct", "Congratulations!", "OK"); } else { await DisplayAlert("Incorrect", "Try again.", "OK"); } }
async void OnDrop(object sender, DropEventArgs e) { string text = await e.Data.GetTextAsync(); if (text.Equals("Cat")) { await DisplayAlert("Correct", "Congratulations!", "OK"); } else if (text.Equals("Monkey")) { await DisplayAlert("Incorrect", "Try again.", "OK"); } }
public void OnDropEmitter(object sender, DropEventArgs e) { foreach (Cell cell in e._cells) { if (cell._isEmpty && cell._adjacentCells[2] == null) { GenerateTile(cell); } if (cell._adjacentCells[2]._isEmpty && cell._adjacentCells != null) { StartCoroutine(Switching(cell, cell._adjacentCells[2], _dropDuration, true)); } } }
private void DropGestureRecognizer_Drop(object sender, DropEventArgs e) { var image = e.Data.Properties["Demo"] as Image; var frame = (sender as Element)?.Parent as Frame; frame.Content = image; Task.Run(async() => { await image.RotateTo(360, 1000); }); Task.Run(async() => { await image.ScaleTo(1.4, 400); await image.FadeTo(1, 600); }); }
private void DropTarget_DragSourceDropped(object sender, DropEventArgs args) { FrameworkElement senderElement = sender as FrameworkElement; if (senderElement != null) { ScheduledSessionViewModel source = ForView.Unwrap <ScheduledSessionViewModel>(args.DragSource.DataContext); ScheduleCellViewModel target = ForView.Unwrap <ScheduleCellViewModel>(senderElement.DataContext); if (source != null && target != null) { source.MoveTo(target.Place); Debug.WriteLine(String.Format("{0} dropped on {1}.", source, target)); } } }
public bool Drop(object sender, GamePiece sprite, Action <Sprite> onHandled, DragEventArgs e) { var eventArgs = new DropEventArgs() { Sprite = sprite, OnHandled = onHandled, DragCurrent = e.DragCurrent, DragStart = e.DragStart, DragStop = e.DragStop, Button = e.Button }; Dropped?.Invoke(sender, eventArgs); return(eventArgs.Handled); }
public override bool CheckDrop(DropEventArgs drop) { //check if we are currently dragging if (CurrentlyDragging) { //don't respond to anymore drop events CurrentlyDragging = false; return(true); } else { //drop.Drop = drop.Drop; return(base.CheckDrop(drop)); } }
public virtual bool CheckDrop(DropEventArgs drop) { if (Rect.Contains(drop.Drop)) { for (int i = Items.Count - 1; i >= 0; i--) { var droppable = Items[i] as IDroppable; if ((droppable != null) && droppable.CheckDrop(drop)) { return(true); } } } //None of the items in this container were clicked return(false); }
public async Task TextPackageCorrectlySetsOnCompatibleTarget(Type fieldType, string result) { var dropRec = new DropGestureRecognizer() { AllowDrop = true }; var element = (View)Activator.CreateInstance(fieldType); element.GestureRecognizers.Add(dropRec); var args = new DropEventArgs(new DataPackageView(new DataPackage() { Text = result })); await dropRec.SendDrop(args); Assert.AreEqual(element.GetStringValue(), result); }
private void onDropNode(object sender, DropEventArgs e) { if (e.DestNode == null) { Debug.Log("拖拽操作需要指定一个父节点!"); e.Cancel = true; return; } if (e.DestNode != null && (!(e.DestNode.DataKey as UIElement).VisbleGolbal || e.DestNode.ToggleList["锁定"])) { Debug.Log("不能移动到处于隐藏、锁定状态的节点下!"); e.Cancel = true; return; } m_layout_mng.CurEditLayout.SetDirty(); CmdManager.Instance.AddCmd(new UITreeNodeDragCmd(e.Node, e.DestNode, uiTree)); }
public async Task HandledTest() { string testString = "test String"; var dropTec = new DropGestureRecognizer() { AllowDrop = true }; var element = new Label(); element.Text = "Text Shouldn't change"; var args = new DropEventArgs(new DataPackageView(new DataPackage() { Text = testString })); args.Handled = true; await dropTec.SendDrop(args); Assert.AreNotEqual(element.Text, testString); }
void HandleDrop(View element, DataPackage datapackage) { var args = new DropEventArgs(datapackage?.View); SendEventArgs <DropGestureRecognizer>(async rec => { if (!rec.AllowDrop) { return; } try { await rec.SendDrop(args); } catch (Exception dropExc) { Application.Current?.FindMauiContext()?.CreateLogger <DropGestureRecognizer>()?.LogWarning(dropExc, "Error sending drop event"); } }, (View)element); }
void HandleDrop(View element, DataPackage datapackage) { var args = new DropEventArgs(datapackage?.View); SendEventArgs <DropGestureRecognizer>(async rec => { if (!rec.AllowDrop) { return; } try { await rec.SendDrop(args); } catch (Exception e) { Forms.MauiContext?.CreateLogger <DropGestureRecognizer>()?.LogWarning(e, null); } }, (View)element); }
private void TabDrop(DropEventArgs e) { foreach (var item in tabs) { ListBoxItem myListBoxItem = (ListBoxItem)(TabsList.ItemContainerGenerator.ContainerFromItem(item)); ContentPresenter myContentPresenter = VisualHelper.FindVisualChild <ContentPresenter>(myListBoxItem); if (myContentPresenter.IsMouseOver) { var tabPosition = myContentPresenter.TransformToAncestor(FindMyWindow()) .Transform(new Point(0, 0)); var position = new Point(e.RelativeMousePosition.X - tabPosition.X, e.RelativeMousePosition.Y - tabPosition.Y); TabDropOnElement(item, position, e.Data as Model.UI.TabItem); return; } } TabDropOnEmptyArea(e.Data as Model.UI.TabItem); }
void HandleDrop(View element, DataPackage datapackage) { var args = new DropEventArgs(datapackage?.View); SendEventArgs <DropGestureRecognizer>(async rec => { if (!rec.AllowDrop) { return; } try { await rec.SendDrop(args); } catch (Exception e) { Internals.Log.Warning(nameof(DropGestureRecognizer), $"{e}"); } }, (View)element); }
private void DropGestureRecognizer_Drop(Object sender, DropEventArgs e) { var label = (Label)((Element)sender).Parent; var dropLabel = (Label)e.Data.Properties["Label"]; if (label == dropLabel) { return; } Debug.WriteLine($"DropGestureRecognizer_Drop [{dropLabel.Text}] => [{label.Text}]"); var sourceContainer = (Grid)dropLabel.Parent; var targetContainer = (Grid)label.Parent; sourceContainer.Children.Remove(dropLabel); targetContainer.Children.Remove(label); sourceContainer.Children.Add(label); targetContainer.Children.Add(dropLabel); e.Handled = true; }
public bool CheckDrop(DropEventArgs drop) { //check if we are currently dragging if (CurrentlyDragging) { //don't respond to anymore drop events CurrentlyDragging = false; //Move the button to the drop position Position = drop.Drop.ToPoint(); //fire off the event for any listeners if (OnDrop != null) { OnDrop(this, drop); } return(true); } return(false); }
void HandleDrop(object sender, Microsoft.UI.Xaml.DragEventArgs e) { var datapackage = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage; var args = new DropEventArgs(datapackage?.View); SendEventArgs <DropGestureRecognizer>(async rec => { if (!rec.AllowDrop) { return; } try { await rec.SendDrop(args); } catch (Exception dropExc) { Application.Current?.FindMauiContext()?.CreateLogger <DropGestureRecognizer>()?.LogWarning(dropExc, "Error sending drop event"); } }); }
void HandleDrop(object sender, Microsoft.UI.Xaml.DragEventArgs e) { var datapackage = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage; 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}"); } }); }