public void OnDropTargetEvent(DragDrop dragDrop, DropTargetEventType type) { if (dragDrop.Target != this) return; Package package = null; if (dragDrop.Payload is Package) package = (Package)dragDrop.Payload; else if (dragDrop.Payload is Int64) package = PackagesPanel.Current.Tree.FindPackageById((Int64)dragDrop.Payload); if (package == null) return; //Point mousePoint = dragDrop.GetPosition(dragDrop.Target); if (type == DropTargetEventType.Enter) dragDrop.DefaultEnterEventHandler(dragDrop.Target); else if (type == DropTargetEventType.Over) dragDrop.DefaultOverEventHandler(dragDrop.Target); else if (type == DropTargetEventType.Leave) dragDrop.DefaultLeaveEventHandler(dragDrop.Target); else if (type == DropTargetEventType.Drop) PackagesPanel.Current.CreatePackageDialog(package.Id, true/*bForUseInDocument*/); }
public override void DragAndDrop_StartDragging(DragDrop.Package package, int x, int y) { base.DragAndDrop_StartDragging(package, x, y); IsHidden = true; // This hiding our parent thing is kind of lousy. Parent.IsHidden = true; }
public override bool DragAndDrop_CanAcceptPackage(DragDrop.Package p) { if (!m_AllowReorder) return false; if (p.Name == "TabButtonMove") return true; return false; }
/// <summary> /// Populate the Drag 'n' Drop data structures when a drag is actually started. /// </summary> private void DragRectOnMouseMove(object sender, MouseEventArgs mouseEventArgs) { if (mouseEventArgs.LeftButton == MouseButtonState.Pressed) { if (Item.Tag is IStripe) { //If the dummy node has a stripe as its tag, we use the stripe directly //This allows StripeDropInputMode to take over var dao = new DataObject(); dao.SetData(typeof(IStripe), Item.Tag); DragDrop.DoDragDrop(this, dao, DragDropEffects.Link | DragDropEffects.Copy | DragDropEffects.Move); } else { //Otherwise, we just use the node itself and let (hopefully) NodeDropInputMode take over var dao = new DataObject(); dao.SetData(typeof(INode), new SimpleNode { Layout = Item.Layout, Style = (INodeStyle)Item.Style.Clone(), Tag = Item.Tag }); DragDrop.DoDragDrop(this, dao, DragDropEffects.Link | DragDropEffects.Copy | DragDropEffects.Move); } } }
private void PickUpCard(object sender, MouseEventArgs e) { if (MouseButtonState.Pressed.Equals(e.LeftButton) && dragActive) { DataGridRow SearchCard = new DataGridRow(); var row = (DataRowView)resultsGrid.SelectedItem; if (row == null) { return; } if (CardAdded == null) { return; } var rowid = row["id"] as string; if (rowid != null) { DataNew.Entities.MultiCard getCard = Game.GetCardById(Guid.Parse(rowid)).ToMultiCard(); DataObject dragCard = new DataObject("Card", getCard); DragDrop.DoDragDrop(SearchCard, dragCard, DragDropEffects.Copy); } } dragActive = false; }
private void EncodingListView_MouseMove(object sender, MouseEventArgs e) { var diff = _dragStart - e.GetPosition(null); if (e.LeftButton != MouseButtonState.Pressed || !(Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance) || !(Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { return; } if (EncodingListView.SelectedItems.Count == 0) { return; } var files = EncodingListView.SelectedItems.OfType <EncoderListViewItem>().Where(y => y.Status == Status.Completed && File.Exists(y.OutputFilename)).Select(x => x.OutputFilename).ToArray(); if (!files.Any()) { return; } DragDrop.DoDragDrop(this, new DataObject(DataFormats.FileDrop, files), Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl) ? DragDropEffects.Copy : DragDropEffects.Move); }
//Enters DragDrop private void DlgLineEntityConnect_PreviewMouseDown(object sender, MouseEventArgs e) { Rectangle convertedConnecter = sender as Rectangle; if (convertedConnecter == null) { return; } mouseMode = MouseMode.Connect; mw.tbMouseMode.Text = "Connect"; DlgLineEntity.Selected = convertedConnecter.Tag as DlgLineEntity; DlgLineEntity.Selected.HideConnects(); Dlg.InteractionConnection.Selected = new Dlg.InteractionConnection(); Dlg.InteractionConnection.Selected.startRect = convertedConnecter; Dlg.InteractionConnection.Selected.startInteraction = DlgLineEntity.Selected.interaction; Point relativePoint = GetRelativeLocation(convertedConnecter, mapCanvas); relativePoint.X += convertedConnecter.Width / 2; relativePoint.Y += convertedConnecter.Height / 2; Dlg.InteractionConnection.Selected.arrow = new Dlg.Arrow(relativePoint, mapCanvas); //currentConnection.arrow.StrokeThickness = 4; //currentConnection.arrow.Stroke = System.Windows.Media.Brushes.Black; Dlg.InteractionConnection.Selected.arrow.Fill = System.Windows.Media.Brushes.Black; Dlg.InteractionConnection.Selected.arrow.IsHitTestVisible = false; Dlg.InteractionConnection.Selected.arrow.Opacity = 0.6; DragDrop.DoDragDrop(convertedConnecter, new DataObject(DlgLineEntity.Selected), DragDropEffects.Move); Dlg.InteractionConnection.Selected = null; //Hide all drops and do more //Disable HitTestVisible for all interactionConnections }
private void TreeView_After_MouseMove(object sender, MouseEventArgs e) { try { if (e.LeftButton == MouseButtonState.Pressed) { UIElement element = e.OriginalSource as UIElement; bool bGridSplitter = CheckGridSplitter(element); Point currentPosition = e.GetPosition(TreeView_After); if ((Math.Abs(currentPosition.X - _lastMouseDown.X) > 10.0) || (Math.Abs(currentPosition.Y - _lastMouseDown.Y) > 10.0)) { draggedItem = (NodeViewModel)TreeView_After.SelectedItem; if ((draggedItem != null) && !bGridSplitter) { DragDropEffects finalDropEffect = DragDrop.DoDragDrop(TreeView_After, TreeView_After.SelectedValue, DragDropEffects.Move); //Checking target is not null and item is dragging(moving) if ((finalDropEffect == DragDropEffects.Move) && (_target != null)) { // A Move drop was accepted if (draggedItem.Name != _target.Name) { CopyItem(draggedItem, _target); _target = null; draggedItem = null; } } } } } } catch (Exception) { } }
private void GetDragTask(object sender, MouseEventArgs e, string taskType) { if (e.LeftButton == MouseButtonState.Pressed) { Point mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; if ( Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance) { var itemsControl = sender as ItemsControl; var item = UICommon.FindAncestor <TaskControl>((DependencyObject)e.OriginalSource); if (item == null || item.DataContext == null) { return; } var displayTask = (DisplayTask)item.DataContext; DataObject dragData = new DataObject(taskType, displayTask); DragDrop.DoDragDrop(item, dragData, DragDropEffects.Move); } } }
private void Border_PreviewMouseMove(object sender, MouseEventArgs e) { if (DragInsertEvent == null) { return; } Border panel = GetBorderFromMousePos(e); if (panel == null) { return; } if (e.LeftButton == MouseButtonState.Pressed && _LinkList.SelectedItem != null) { DragInfo dragInfo = new DragInfo(); dragInfo.PanelID = PanelID; dragInfo.DragFrom = panel; DataObject data = new DataObject(typeof(DragInfo), dragInfo); DragDrop.DoDragDrop(this, data, DragDropEffects.Move); } }
private void Icon_OnMouseMove(object sender, MouseEventArgs e) { System.Windows.Point mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { try { if (selektovanaVrsta != null) { ListViewItem listViewItem = FindAnchestor <ListViewItem>((DependencyObject)e.OriginalSource); DataObject dragData = new DataObject("vrsta", selektovanaVrsta); DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects.Move); } } catch { return; } } }
private void treeView_MouseMove(object sender, MouseEventArgs e) { try { Point currentPosition2 = e.GetPosition(m_TreeView); System.Diagnostics.Debug.WriteLine(currentPosition2); if (e.LeftButton == MouseButtonState.Pressed) { Point currentPosition = e.GetPosition(m_TreeView); if ((Math.Abs(currentPosition.X - _lastMouseDown.X) > 10.0) || (Math.Abs(currentPosition.Y - _lastMouseDown.Y) > 10.0)) { draggedItem = (TreeViewItem)m_TreeView.SelectedItem; if (draggedItem != null) { DragDropEffects finalDropEffect = DragDrop.DoDragDrop(m_TreeView, m_TreeView.SelectedValue, DragDropEffects.Move); //Checking target is not null and item is dragging(moving) if ((finalDropEffect == DragDropEffects.Move) && (_target != null)) { // A Move drop was accepted if (_target != draggedItem) //if (!draggedItem.Header.ToString().Equals(_target.Header.ToString())) { CopyItem(draggedItem, _target); _target = null; draggedItem = null; } } } } } } catch (Exception) { } }
public static void inputDirListBox_PreviewMouseMove(object sender, MouseEventArgs e) { Point mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; //Little to no f*****g idea how this works... need to do some research... if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { // Get the Dragged ListViewItem DataGrid dataGrid = sender as DataGrid; object item = dataGrid.CurrentItem; if (item != null) { // Find the data behind the ListViewItem modSourceFolder data = (modSourceFolder)item; //Initialize the drag & drop operation DataObject dragData = new DataObject("myFormat", data); DragDrop.DoDragDrop(dataGrid, dragData, DragDropEffects.Move); } } }
private void ListView_MouseMove(object sender, MouseEventArgs e) { Point mousePosition = e.GetPosition(null); Vector diff = startPoint - mousePosition; ListView listView = sender as ListView; ListViewItem listViewItem = FindAncestor <ListViewItem>((DependencyObject)e.OriginalSource); if (listViewItem != null) { Mouse.SetCursor(Cursors.Hand); } if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { if (listViewItem != null) { Manifestation manifestation = (Manifestation)listView.ItemContainerGenerator.ItemFromContainer(listViewItem); DataObject dragData = new DataObject("manifestation", manifestation); DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects.Move); } } }
private void OnDrag_MoveElement(object sender, MouseEventArgs e) { if (SelectedElementContainer == null) { return; } var mouseInListBoxPosition = e.GetPosition(this); UIElement?hoverElementContainer = GetElementAtPosition(mouseInListBoxPosition); if (hoverElementContainer == SelectedElementContainer) { return; } var draggedItem = (TItem)ItemContainerGenerator.ItemFromContainer(SelectedElementContainer); SelectedItem = draggedItem; SelectedElementContainer = null; var dragData = new DragData(this, draggedItem); DragDrop.DoDragDrop(this, new DataObject(typeof(DragData), dragData), DragDropEffects.Move); }
private void PreviewMouseMove(object sender, System.Windows.Input.MouseEventArgs e) { var itemsControl = sender as ItemsControl; if (_draggedData == null || _initialPosition == null || itemsControl == null) { return; } var currentPos = AssociatedObject.PointToScreen(e.GetPosition(AssociatedObject)); if (!MovedEnoughForDrag((_initialPosition - currentPos).Value)) { return; } _dragContentAdorner?.Detach(); _dragContentAdorner = new DragContentAdorner( itemsControl, _draggedData, itemsControl.ItemTemplate, _mouseOffsetFromItem); _dragContentAdorner.SetScreenPosition(currentPos); DragDrop.DoDragDrop(itemsControl, _draggedData, DragDropEffects.Move); CleanUpData(); }
public static void DiagramLibraryNodeToDragDrop(DependencyObject dragSource, ObservableDiagramLibraryNode diagramLibraryNode, bool useSelectedDiagrams) { if (null == dragSource) { throw new ArgumentNullException(nameof(dragSource)); } if (null == diagramLibraryNode) { throw new ArgumentNullException(nameof(diagramLibraryNode)); } DataObject data = new DataObject(); data.SetData(typeof(ObservableDiagramLibraryNode), diagramLibraryNode); data.SetData(UseSelectedDiagramsFormat, useSelectedDiagrams); if (useSelectedDiagrams && diagramLibraryNode.SelectedDiagrams.Count > 0) { AddImageFormats(data, diagramLibraryNode.SelectedDiagrams[0], 1.0f); } DragDrop.DoDragDrop(dragSource, data, DragDropEffects.Copy | DragDropEffects.Move); }
private void btn_PreviewMouseMove(object sender, MouseEventArgs e) { if (!inDrag && startPoint != null) { inDrag = true; Point mousePos = e.GetPosition(this); Vector diff = (Point)startPoint - mousePos; if (mousePos.Y <= this.ActualHeight && ((Point)startPoint).Y <= this.ActualHeight && e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { Button button = sender as Button; ApplicationInfo selectedApp = button.DataContext as ApplicationInfo; try { DragDrop.DoDragDrop(button, selectedApp, DragDropEffects.Move); setParentAutoHide(true); } catch { } // reset the stored mouse position startPoint = null; } else if (e.LeftButton != MouseButtonState.Pressed) { // reset the stored mouse position startPoint = null; } inDrag = false; } e.Handled = true; }
/// <summary> /// マウス移動処理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PreviewMouseMoveHandler(object sender, MouseEventArgs e) { if (!this.IsDragEnable) { return; } if (e.LeftButton != MouseButtonState.Pressed || !this.isButtonDown) { return; } var point = e.GetPosition(this.AssociatedObject); if (CheckDistance(point, this.origin)) { // アクティブWindowの直下のContentに対して、Adornerを付加する var window = Application.Current.Windows.OfType <Window>().FirstOrDefault(w => w.IsActive); if (window != null) { var root = window.Content as UIElement; var layer = AdornerLayer.GetAdornerLayer(root); this.dragGhost = new DragAdorner(root, (UIElement)sender, 0.5, this.dragStartPos); layer.Add(this.dragGhost); DragDrop.DoDragDrop(this.AssociatedObject, this.DragDropData, this.AllowedEffects); layer.Remove(this.dragGhost); } else { DragDrop.DoDragDrop(this.AssociatedObject, this.DragDropData, this.AllowedEffects); } this.isButtonDown = false; e.Handled = true; this.dragGhost = null; this.dragItem = null; } }
void PreviewMouseDown(object sender, MouseButtonEventArgs e) { var sc = Specifications; if (sc != null) { sc.OnMouseDown(sender, e); e.Handled = true; } else { //BeginDragSpecificationsが指定されなかった場合のデフォルト動作を定義する。 switch (sender.GetType().Name) { case "ListView": var lv = this.AssociatedObject as ListView; int index = lv.GetItemIndexAtPoint <ListViewItem>(e.GetPosition(lv)); if (index != -1) { lv.SelectedIndex = index; var data = new DataObject(); data.SetData(typeof(Person), lv.SelectedItem); data.SetData(typeof(ListView), this.AssociatedObject); DragDrop.DoDragDrop(lv, data, this.AllowedEffects); } break; } } }
/// <summary> /// Gets the target and source workspaceitem in this event /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param> private void TreeViewMouseMove(object sender, MouseEventArgs e) { try { if (e.LeftButton == MouseButtonState.Pressed) { Point currentPosition = e.GetPosition(MyTreeView); if ((Math.Abs(currentPosition.X - _lastMouseDown.X) > 10.0) || (Math.Abs(currentPosition.Y - _lastMouseDown.Y) > 10.0)) { _draggedItem = (TreeViewItem)MyTreeView.Tag; if (_draggedItem != null) { DragDropEffects finalDropEffect = DragDrop.DoDragDrop(MyTreeView, MyTreeView.SelectedValue, DragDropEffects.Move); //Checking target is not null and item is dragging(moving) if ((finalDropEffect == DragDropEffects.Move) && (_target != null)) { // A Move drop was accepted if (!_draggedItem.Header.ToString().Equals(_target.Header.ToString())) { CopyItem(_draggedItem, _target); _target = null; _draggedItem = null; } } } } } } catch (Exception err) { MessageBox.Show(err.Message, Constants.ProjectTitle, MessageBoxButton.OK); } }
private void dtGridActors_PreviewMouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed)// && !IsDragging) { int i = dtGridActors.SelectedIndex; if (i < 0) { return; } AtomDTOData currAtomData = (AtomDTOData)dtGridActors.Items[i]; Point position = e.GetPosition(null); if (Math.Abs(position.X - _startPoint.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(position.Y - _startPoint.Y) > SystemParameters.MinimumVerticalDragDistance) { _allOpsCursor = null; GiveFeedbackEventHandler handler = new GiveFeedbackEventHandler(dtGridActors_GiveFeedback); this.dtGridActors.GiveFeedback += handler; IsDragging = true; try { DataObject data = new DataObject(typeof(FormationTree), currAtomData.atom); data.SetText("Actor"); DragDropEffects de = DragDrop.DoDragDrop(dtGridActors, data, DragDropEffects.Move); } catch (Exception ex) { //this.treeViewForce.GiveFeedback -= handler; //this.treeViewForce.GiveFeedback += handler; } this.dtGridActors.GiveFeedback -= handler; IsDragging = false; } } }
private static void DragStarted(UIElement uiElt) { if (uiElt == null || _draggedElt == null) { return; } Mouse.Capture(uiElt); DataObject data = CurrentDragSourceAdvisor.GetDataObject(_draggedElt); data.SetData(DragOffsetFormat, _offsetPoint); DragDropEffects supportedEffects = CurrentDragSourceAdvisor.SupportedEffects; // Perform DragDrop DragDropEffects effects = DragDrop.DoDragDrop(_draggedElt, data, supportedEffects); CurrentDragSourceAdvisor.FinishDrag(_draggedElt, effects); // Clean up RemovePreviewAdorner(); Mouse.Capture(null); _draggedElt = null; }
/// <summary> /// 针对DataGrid的鼠标操作; /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MibDataGrid_MouseMove(object sender, MouseEventArgs e) { //(e.OriginalSource as DataGridCell).DataContext is MS.Internal.NamedObject; try { if (e.OriginalSource is DataGridCell) { Console.WriteLine("MouseMove;函数参数e反馈的实体是单元格内数据内容:" + ((e.OriginalSource as DataGridCell).Column).Header.ToString()); DyDataGrid_MIBModel SelectedIter = new DyDataGrid_MIBModel(); foreach (var iter in (e.Source as DataGrid).SelectedCells) { Console.WriteLine("User Selected:" + iter.Item.GetType()); SelectedIter = iter.Item as DyDataGrid_MIBModel; } DataGridCell item = e.OriginalSource as DataGridCell; // 在MouseMove事件当中可以添加鼠标拖拽事件; if (e.MiddleButton == System.Windows.Input.MouseButtonState.Pressed) { DragDropEffects myDropEffect = DragDrop.DoDragDrop(item, new DataGridCell_MIB_MouseEventArgs() { HeaderName = (e.OriginalSource as DataGridCell).Column.Header.ToString(), SelectedCell = SelectedIter }, DragDropEffects.Copy); } } } catch (Exception ex) { Console.WriteLine("MouseMove Exception" + ex.ToString()); } }
/// <summary> /// Called when a PreviewMouseMove event is received. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param> private void OnPreviewMouseMove(object sender, MouseEventArgs e) { if (_dragCandidate == null || !_dragStartPoint.HasValue) { return; } var delta = _dragStartPoint.Value - e.GetPosition(null); if (Math.Abs(delta.X) <= SystemParameters.MinimumHorizontalDragDistance && Math.Abs(delta.Y) <= SystemParameters.MinimumVerticalDragDistance) { return; } _dragCandidate.SetValue(DragDropAttachedProperties.IsBeingDraggedProperty, true); DragDrop.DoDragDrop(_dragCandidate, new DataObject(typeof(object), _dragCandidate.DataContext), DragDropEffects.Move); _dragCandidate.SetValue(DragDropAttachedProperties.IsBeingDraggedProperty, false); _dragCandidate = null; _dragStartPoint = null; }
// Drag = mouse down + move by a certain amount private void DragSource_PreviewMouseMove(object sender, MouseEventArgs e) { if (this.draggedData != null) { // Only drag when user moved the mouse by a reasonable amount. if (Utilities.IsMovementBigEnough(this.initialMousePosition, e.GetPosition(this.topWindow))) { this.initialMouseOffset = this.initialMousePosition - this.sourceItemContainer.TranslatePoint(new Point(0, 0), this.topWindow); DataObject data = new DataObject(this.format.Name, this.draggedData); // Adding events to the window to make sure dragged adorner comes up when mouse is not over a drop target. bool previousAllowDrop = this.topWindow.AllowDrop; this.topWindow.AllowDrop = true; this.topWindow.DragEnter += TopWindow_DragEnter; this.topWindow.DragOver += TopWindow_DragOver; this.topWindow.DragLeave += TopWindow_DragLeave; DragDropEffects effects = DragDrop.DoDragDrop((DependencyObject)sender, data, DragDropEffects.Move); // Without this call, there would be a bug in the following scenario: Click on a data item, and drag // the mouse very fast outside of the window. When doing this really fast, for some reason I don't get // the Window leave event, and the dragged adorner is left behind. // With this call, the dragged adorner will disappear when we release the mouse outside of the window, // which is when the DoDragDrop synchronous method returns. RemoveDraggedAdorner(); this.topWindow.AllowDrop = previousAllowDrop; this.topWindow.DragEnter -= TopWindow_DragEnter; this.topWindow.DragOver -= TopWindow_DragOver; this.topWindow.DragLeave -= TopWindow_DragLeave; this.draggedData = null; } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListView_PreviewMouseMove(object sender, MouseEventArgs e) { Point point = e.GetPosition(null); Vector diff = dragStartPoint - point; if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { var listView = sender as ListView; var listViewItem = FindVisualParent <ListViewItem>((DependencyObject)e.OriginalSource); if (listViewItem != null) { var record = (Record)listView .ItemContainerGenerator .ItemFromContainer(listViewItem); DataObject dragData = new DataObject(typeof(Record), record); DragDrop.DoDragDrop( listViewItem, dragData, DragDropEffects.Move); } } }
private void TileList_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) { if (AllowMultiTileSelectMenuItem.IsChecked) { return; } // Get the current mouse position Point mousePos = e.GetPosition(null); Vector diff = DragStartPoint - mousePos; if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { // Get the dragged ListViewItem ListView listView = sender as ListView; ListViewItem listViewItem = FindAnchestor <ListViewItem>((DependencyObject)e.OriginalSource); if (listViewItem == null) { return; } DataObject dragData = new DataObject(typeof(Int32), this.TilesList.TileList.Items.IndexOf(listViewItem)); DragDrop.DoDragDrop(listViewItem, dragData, DragDropEffects.Copy | DragDropEffects.Move); } }
private void listBoxItem_PreviewMouseMove(object sender, MouseEventArgs e) { var lbi = sender as ListBoxItem; if (e.LeftButton == MouseButtonState.Pressed && dragGhost == null && dragItem == lbi) { var nowPos = e.GetPosition(lbi); if (Math.Abs(nowPos.X - dragStartPos.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(nowPos.Y - dragStartPos.Y) > SystemParameters.MinimumVerticalDragDistance) { charaListBox.AllowDrop = true; var layer = AdornerLayer.GetAdornerLayer(charaListBox); dragGhost = new DragAdorner(charaListBox, lbi, 0.5, dragStartPos); layer.Add(dragGhost); DragDrop.DoDragDrop(lbi, lbi, DragDropEffects.Move); layer.Remove(dragGhost); dragGhost = null; dragItem = null; charaListBox.AllowDrop = false; } } }
private void PrikazIkonice_MouseMove(object sender, MouseEventArgs e) { System.Windows.Point mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { try { ManifestacijaKlasa selektovana = (ManifestacijaKlasa)tree.SelectedValue; if (selektovana != null) { DataObject dragData = new DataObject("manifestacija", selektovana); DragDrop.DoDragDrop(PrikazIkonice, dragData, DragDropEffects.Move); } } catch { return; } } }
private void seedsGrid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { rowIndex = GetCurrentRowIndex(e.GetPosition); if (rowIndex < 0) { return; } plantsGrid.SelectedIndex = rowIndex; Plant selectedSeed = plantsGrid.Items[rowIndex] as Plant; if (selectedSeed == null) { return; } DragDropEffects dragdropeffects = DragDropEffects.Move; if (DragDrop.DoDragDrop(plantsGrid, selectedSeed, dragdropeffects) != DragDropEffects.None) { plantsGrid.SelectedItem = selectedSeed; } }
private void myConnectionsList_PreviewMouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed && !IsDragging) { Point position = e.GetPosition(null); if (Math.Abs(position.X - _startPoint.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(position.Y - _startPoint.Y) > SystemParameters.MinimumVerticalDragDistance) { //Start DragDrop Action! { var row = UIHelpers.TryFindFromPoint <ListBoxItem>((UIElement)sender, e.GetPosition(myConnectionsList)); if (row != null) { DataObject dragData = new DataObject("ConnectionName", myConnectionsList.SelectedItem); Mouse.OverrideCursor = dragDropCursor = new GhostCursor(row).Cursor; DragDrop.DoDragDrop((DependencyObject)sender, dragData, DragDropEffects.Copy); Mouse.OverrideCursor = null; } } } } }
private void OnMouseDown() { if (Data.coin >= cost) { Debug.Log("Create Item"); GameObject _item = (GameObject)Instantiate(item, transform.position, Quaternion.identity); foreach (Behaviour childCompnent in _item.GetComponentsInChildren <Behaviour>()) { childCompnent.enabled = false; } screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position); offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, screenPoint.z)); DragDrop dd = _item.GetComponent <DragDrop>(); dd.enabled = true; dd.screenPoint = screenPoint; dd.offset = offset; dd.cost = cost; } else { Debug.Log("Koin Tidak cukup"); } }
public override bool DragAndDrop_HandleDrop(DragDrop.Package p, int x, int y) { Vector2i pos = CanvasPosToLocal(new Vector2i(x, y)); Pos dir = GetDroppedTabDirection(pos.X, pos.Y); DockedTabControl addTo = m_DockedTabControl; if (dir == Pos.Fill && addTo == null) return false; if (dir != Pos.Fill) { DockBase dock = GetChildDock(dir); addTo = dock.m_DockedTabControl; if (!m_DropFar) dock.BringToFront(); else dock.SendToBack(); } if (p.Name == "TabButtonMove") { TabButton tabButton = DragAndDrop.SourceControl as TabButton; if (null == tabButton) return false; addTo.AddPage(tabButton); } if (p.Name == "TabWindowMove") { DockedTabControl tabControl = DragAndDrop.SourceControl as DockedTabControl; if (null == tabControl) return false; if (tabControl == addTo) return false; tabControl.MoveTabsTo(addTo); } Invalidate(); return true; }
public override bool DragAndDrop_CanAcceptPackage(DragDrop.Package p) { // A TAB button dropped if (p.Name == "TabButtonMove") return true; // a TAB window dropped if (p.Name == "TabWindowMove") return true; return false; }
public override void DragAndDrop_StartDragging(DragDrop.Package package, int x, int y) { DragAndDrop.SourceControl = Parent; DragAndDrop.SourceControl.DragAndDrop_StartDragging(package, x, y); }
///////////////////////////////////////////////////////////////////////////// private void Page_Loaded(object sender, EventArgs args) { //j WebResources.DownloadUsers(); //j WebResources.DownloadAccounts(); WebResources.DownloadLayouts(); WebResources.DownloadCovers(); WebResources.DownloadBackgrounds(); WebResources.DownloadCorners(); WebResources.DownloadPhotos(); MouseMove += WebResourcesCheck; m_DocumentHolder = new DocumentHolder(); //j x_AccountsPanel.InitDocumentListener(m_DocumentHolder); //j x_ToolsPanel.InitDocumentListener(m_DocumentHolder); x_LayoutsPanel.InitDocumentListener(m_DocumentHolder); x_CoversPanel.InitDocumentListener(m_DocumentHolder); x_BackgroundsPanel.InitDocumentListener(m_DocumentHolder); x_CornersPanel.InitDocumentListener(m_DocumentHolder); x_PhotosPanel.InitDocumentListener(m_DocumentHolder); //j x_AdsPanel.InitDocumentListener(m_DocumentHolder); //j x_MainPanel.InitDocumentListener(m_DocumentHolder); //j x_PropertiesPanel.InitDocumentListener(m_DocumentHolder); // Initialize drag and drop m_DragDrop = new DragDrop(); m_DragDrop.Init(); //j m_DragDrop.AddTarget(x_MainPanel); //j m_DragDrop.DropTargetListeners += x_MainPanel.DropTarget; // Handle resizing Application.Current.Host.Content.Resized += BrowserHost_Resized; Resize(); // Initialize the static scroll viewer mouse wheel support class ScrollViewerMouseWheelSupport.Initialize(App.PageProp, MouseWheelAssociationMode.OnHover); SliderMouseWheelSupport.Initialize(App.PageProp, MouseWheelAssociationMode.OnHover); // Register a single scroll viewer x_LayoutsScrollViewer.AddMouseWheelSupport(); }
public override void DragAndDrop_StartDragging(DragDrop.Package package, int x, int y) { IsHidden = true; }
public override void DragAndDrop_HoverEnter(DragDrop.Package p, int x, int y) { if (m_TabDragControl != null) { throw new InvalidOperationException("ERROR! TabStrip::DragAndDrop_HoverEnter"); } m_TabDragControl = new Highlight(this); m_TabDragControl.MouseInputEnabled = false; m_TabDragControl.SetSize(3, Height); }
public override void DragAndDrop_HoverLeave(DragDrop.Package p) { m_DrawHover = false; }
public override void DragAndDrop_Hover(DragDrop.Package p, int x, int y) { Vector2i pos = CanvasPosToLocal(new Vector2i(x, y)); Pos dir = GetDroppedTabDirection(pos.X, pos.Y); if (dir == Pos.Fill) { if (null == m_DockedTabControl) { m_HoverRect = new Rectangle(0,0,0,0); return; } m_HoverRect = InnerBounds; return; } m_HoverRect = RenderBounds; int HelpBarWidth = 0; if (dir == Pos.Left) { HelpBarWidth = (int)(m_HoverRect.Width * 0.25f); m_HoverRect.Width = HelpBarWidth; } if (dir == Pos.Right) { HelpBarWidth = (int)(m_HoverRect.Width * 0.25f); m_HoverRect.X = m_HoverRect.Width - HelpBarWidth; m_HoverRect.Width = HelpBarWidth; } if (dir == Pos.Top) { HelpBarWidth = (int)(m_HoverRect.Height * 0.25f); m_HoverRect.Height = HelpBarWidth; } if (dir == Pos.Bottom) { HelpBarWidth = (int)(m_HoverRect.Height * 0.25f); m_HoverRect.Y = m_HoverRect.Height - HelpBarWidth; m_HoverRect.Height = HelpBarWidth; } if ((dir == Pos.Top || dir == Pos.Bottom) && !m_DropFar) { if (m_Left != null && m_Left.IsVisible) { m_HoverRect.X += m_Left.Width; m_HoverRect.Width -= m_Left.Width; } if (m_Right != null && m_Right.IsVisible) { m_HoverRect.Width -= m_Right.Width; } } if ((dir == Pos.Left || dir == Pos.Right) && !m_DropFar) { if (m_Top != null && m_Top.IsVisible) { m_HoverRect.Y += m_Top.Height; m_HoverRect.Height -= m_Top.Height; } if (m_Bottom != null && m_Bottom.IsVisible) { m_HoverRect.Height -= m_Bottom.Height; } } }
public override void DragAndDrop_HoverEnter(DragDrop.Package p, int x, int y) { m_DrawHover = true; }
// receiver public virtual void DragAndDrop_HoverEnter(DragDrop.Package p, int x, int y) { }
public override void DragAndDrop_Hover(DragDrop.Package p, int x, int y) { Vector2i localPos = CanvasPosToLocal(new Vector2i(x, y)); Control droppedOn = GetControlAt(localPos.X, localPos.Y); if (droppedOn != null && droppedOn != this) { Vector2i dropPos = droppedOn.CanvasPosToLocal(new Vector2i(x, y)); m_TabDragControl.SetBounds(new Rectangle(0, 0, 3, Height)); m_TabDragControl.BringToFront(); m_TabDragControl.SetPosition(droppedOn.X - 1, 0); if (dropPos.X > droppedOn.Width/2) { m_TabDragControl.MoveBy(droppedOn.Width - 1, 0); } m_TabDragControl.Dock = Pos.None; } else { m_TabDragControl.Dock = Pos.Left; m_TabDragControl.BringToFront(); } }
///////////////////////////////////////////////////////////////////////////// public void DropTarget(DropTargetEventType type, DragDrop dragDrop) { if (dragDrop.Target != this) return; if (!(dragDrop.Payload is Layout)) return; Layout layout = dragDrop.Payload as Layout; Point mousePoint = dragDrop.GetPosition(dragDrop.Target); if (type == DropTargetEventType.Enter) dragDrop.DefaultEnterEventHandler(dragDrop.Target); else if (type == DropTargetEventType.Over) dragDrop.DefaultOverEventHandler(dragDrop.Target); else if (type == DropTargetEventType.Leave) dragDrop.DefaultLeaveEventHandler(dragDrop.Target); else if (type == DropTargetEventType.Drop) { WebResources.DownloadLayoutPayload(layout.PayloadId, DownloadLayoutPayloadCompleted); dragDrop.DefaultDropEventHandler(dragDrop.Target); } }
public override void DragAndDrop_HoverLeave(DragDrop.Package p) { if (m_TabDragControl != null) { RemoveChild(m_TabDragControl, false); // [omeg] need to do that explicitely m_TabDragControl.Dispose(); } m_TabDragControl = null; }
// receiver public virtual bool DragAndDrop_HandleDrop(DragDrop.Package p, int x, int y) { DragAndDrop.SourceControl.Parent = this; return true; }
public override bool DragAndDrop_HandleDrop(DragDrop.Package p, int x, int y) { Vector2i LocalPos = CanvasPosToLocal(new Vector2i(x, y)); TabButton button = DragAndDrop.SourceControl as TabButton; TabControl tabControl = Parent as TabControl; if (tabControl != null && button != null) { if (button.TabControl != tabControl) { // We've moved tab controls! tabControl.AddPage(button); } } Control droppedOn = GetControlAt(LocalPos.X, LocalPos.Y); if (droppedOn != null && droppedOn != this) { Vector2i dropPos = droppedOn.CanvasPosToLocal(new Vector2i(x, y)); DragAndDrop.SourceControl.BringNextToControl(droppedOn, dropPos.X > droppedOn.Width/2); } else { DragAndDrop.SourceControl.BringToFront(); } return true; }
// receiver public virtual void DragAndDrop_HoverLeave(DragDrop.Package p) { }
// receiver public virtual bool DragAndDrop_CanAcceptPackage(DragDrop.Package p) { return false; }
// giver public virtual void DragAndDrop_StartDragging(DragDrop.Package package, int x, int y) { package.HoldOffset = CanvasPosToLocal(new Vector2i(x, y)); package.DrawControl = this; }