void GroupBox_DragOver (object sender, DragEventArgs e) { _eventsText.AppendText ("GroupBox => DragOver " + _dragoverCount++.ToString (CultureInfo.InvariantCulture) + Environment.NewLine); e.Effect = DragDropEffects.Move; }
public void DragEnter(object sender, DragEventArgs e) { DragDropFlag = true; // choose single effect if there is only one in the allowedEffects flag e.Effects = DetermineDragDropEffect(e); }
void OnDragLeave(object sender, DragEventArgs e) { if (!IsMouseOverTreeView(e.GetPosition(TreeView))) { CleanUpAdorners(); } }
protected override void OnDragEnter(DragEventArgs e) { base.OnDragEnter(e); if (!this.AllowRowReorder) { e.Effect = DragDropEffects.None; return; } if (!e.Data.GetDataPresent(DataFormats.Text)) { e.Effect = DragDropEffects.None; return; } base.OnDragEnter(e); String text = (String)e.Data.GetData(REORDER.GetType()); if (text.CompareTo(REORDER) == 0) { e.Effect = DragDropEffects.Move; } else { e.Effect = DragDropEffects.None; } }
private void textBox_DragDrop(object sender, DragEventArgs e) { // get file string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); string file = files.FirstOrDefault(); // set file TextBox textBox = sender as TextBox; textBox.Text = File.ReadAllText(file); }
/// <summary> /// Initializes a new instance of the DragEventArgs class. /// </summary> /// <param name="args">The DragEventArgs object to use as the base for /// this DragEventArgs.</param> internal DragEventArgs(DragEventArgs args) { Debug.Assert(args != null, "args must not be null."); this.AllowedEffects = args.AllowedEffects; this.MouseEventArgs = args.MouseEventArgs; this.Effects = args.Effects; this.Data = args.Data; this.OriginalSource = args.OriginalSource; }
void GroupBox_DragDrop (object sender, DragEventArgs e) { if (e.Data.GetDataPresent (DataFormats.FileDrop)) { string [] filenames = (string []) e.Data.GetData (DataFormats.FileDrop); if (filenames != null) { foreach (string fileName in filenames) _filesListBox.Items.Add ("Drop => " + fileName); } } }
private void MainForm_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { e.Effect = DragDropEffects.Copy; } else { e.Effect = DragDropEffects.None; } }
void GroupBox_DragEnter (object sender, DragEventArgs e) { if (e.Data.GetDataPresent (DataFormats.FileDrop)) { string [] filenames = (string []) e.Data.GetData (DataFormats.FileDrop); if (filenames != null) { e.Effect = DragDropEffects.Copy; foreach (string fileName in filenames) _filesListBox.Items.Add ("Enter => " + fileName); } else { e.Effect = DragDropEffects.None; } } }
private void HandleDrag(object o, DragEventArgs e) { if(!CanRotate()) return; if(e.StartPosition == e.EndPosition)return; Vector3 applydir = lastdir *0.3f + e.Direction*inverseMulti;// * 0.7f; xrot = transform.localEulerAngles.y + applydir.x * e.Force *10f; yrot += applydir.y * e.Force*1.5f; yrot = Mathf.Clamp (yrot, -60, 60); wantToBeEuler = new Vector3(-yrot, xrot, 0); wantToBeRot = Quaternion.Euler(wantToBeEuler); }
protected override void OnDragOver(DragEventArgs e) { if (!this.AllowRowReorder) { e.Effect = DragDropEffects.None; return; } if (!e.Data.GetDataPresent(DataFormats.Text)) { e.Effect = DragDropEffects.None; return; } Point cp = base.PointToClient(new Point(e.X, e.Y)); ListViewItem hoverItem = base.GetItemAt(cp.X, cp.Y); if (hoverItem == null) { e.Effect = DragDropEffects.None; return; } foreach (ListViewItem moveItem in base.SelectedItems) { if (moveItem.Index == hoverItem.Index) { e.Effect = DragDropEffects.None; hoverItem.EnsureVisible(); return; } } base.OnDragOver(e); String text = (String)e.Data.GetData(REORDER.GetType()); if (text.CompareTo(REORDER) == 0) { e.Effect = DragDropEffects.Move; hoverItem.EnsureVisible(); } else { e.Effect = DragDropEffects.None; } }
public bool AddCrossingInCell(DragEventArgs e) { GridCell OnGridCellDropped = determinePicboxLocation(simulation.gridPanel.PointToClient(new Point(e.X, e.Y))); if (OnGridCellDropped != null) { PictureBox picbox = CreatePicBox(OnGridCellDropped); Bitmap image = (Bitmap)e.Data.GetData(DataFormats.Bitmap); picbox.Image = image; picbox.SizeMode = PictureBoxSizeMode.StretchImage; simulation.gridPanel.Controls.Add(picbox); pictureBoxCrossing.Add(picbox); LinkCrossingAndGridCell(OnGridCellDropped, image); return true; } else return false; }
private static DragDropEffects DetermineDragDropEffect(DragEventArgs e) { DragDropEffects effect_out; effect_out = effectPriorityList.SingleOrDefault((effect) => e.AllowedEffects == effect); bool multiEffect = effect_out == DragDropEffects.None; if (multiEffect) { // choose the first effect from priority if there are multiple allowedEffects effect_out = effectPriorityList.FirstOrDefault((effect) => (e.AllowedEffects & effect) != DragDropEffects.None); if ((e.KeyStates & DragDropKeyStates.ShiftKey) != DragDropKeyStates.None) if ((e.KeyStates & DragDropKeyStates.ControlKey) != DragDropKeyStates.None) effect_out = e.AllowedEffects & DragDropEffects.Link; else effect_out = e.AllowedEffects & DragDropEffects.Move; } return effect_out; }
void TreeView_DragDrop (object sender, DragEventArgs e) { // Retrieve the client coordinates of the drop location. Point targetPoint = _treeView.PointToClient (new Point (e.X, e.Y)); // Retrieve the node at the drop location TreeNode targetNode = _treeView.GetNodeAt (targetPoint); // Retrieve the node that was dragged. TreeNode draggedNode = (TreeNode) e.Data.GetData (typeof (TreeNode)); // Confirm that the node at the drop location is not // the dragged node or a descendant of the dragged node. if (draggedNode != targetNode && !ContainsNode (draggedNode, targetNode)) { // If it is a move operation, remove the node from its current // location and add it to the node at the drop location. if (e.Effect == DragDropEffects.Move) { _eventsText.AppendText ("DragDrop (Move): " + draggedNode.Text + " => " + targetNode.Text + Environment.NewLine); draggedNode.Remove (); targetNode.Nodes.Add (draggedNode); } // If it is a copy operation, clone the dragged node // and add it to the node at the drop location if (e.Effect == DragDropEffects.Copy) { _eventsText.AppendText ("DragDrop (Move): " + draggedNode.Text + " => " + targetNode.Text + Environment.NewLine); targetNode.Nodes.Add ((TreeNode) draggedNode.Clone ()); } // Expand the node at the location // to show the dropped node. targetNode.Expand (); } else { _eventsText.AppendText ("DragDrop (Descendant): " + draggedNode.Text + " => " + targetNode.Text + Environment.NewLine); } }
public void DragDrop(object sender, DragEventArgs e) { if (DragDropFlag) { e.Effects = DetermineDragDropEffect(e); IDataObject dataObject = e.Data; DataObjectBase dataWrapper = DataObjectBase.GetDataObjectWrapper(dataObject); TextBox uiTb = sender as TextBox; if (dataWrapper != null && uiTb != null) { debugText.Clear(); debugText.Append(dataWrapper.DataString); e.Handled = true; } else { try { debugText.Append("" //*/ + "e.AllowedEffect: " + e.AllowedEffects.ToString() + "\r\n" + "e.Data: " + e.Data.GetData(e.Data.GetFormats()[0]).ToString() + "\r\n" + "e.Effect: " + e.Effects.ToString() + "\r\n" + "e.KeyState: " + e.KeyStates.ToString() + "\r\n" /*/ /* + "e.AllowedEffect: " + e.AllowedEffect.ToString() + "\r\n" + "e.Data: " + e.Data.GetData(e.Data.GetFormats()[0]).ToString() + "\r\n" + "e.Effect: " + e.Effect.ToString() + "\r\n" + "e.KeyState: " + e.KeyState.ToString() + "\r\n" + "e.X: " + e.X.ToString() + "\r\n" + "e.Y: " + e.Y.ToString() + "\r\n" //*/ ); } catch (Exception) { ;} } } }
private void textBox2_DragEnter(object sender, DragEventArgs e) { string[] dd = (string[])e.Data.GetData(DataFormats.FileDrop, false); textBox2.Text = dd[0]; }
private void TabStrip_DragLeave(object sender, DragEventArgs e) { VerticalTabView.CanReorderTabs = true; }
private void StackPanel_DragEnter(object sender, DragEventArgs e) { e.Effects = DragDropEffects.Copy; }
private void multiSelectTreeview1_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Move | DragDropEffects.Copy; }
private void lstScriptActions_DragDrop(object sender, DragEventArgs e) { //Return if the items are not selected in the ListView control. if (lstScriptActions.SelectedItems.Count == 0) { return; } CreateUndoSnapshot(); //Returns the location of the mouse pointer in the ListView control. Point cp = lstScriptActions.PointToClient(new Point(e.X, e.Y)); //Obtain the item that is located at the specified location of the mouse pointer. ListViewItem dragToItem = lstScriptActions.GetItemAt(cp.X, cp.Y); if (dragToItem == null) { return; } //Obtain the index of the item at the mouse pointer. int dragIndex = dragToItem.Index; //foreach (ListViewItem command in lstScriptActions.SelectedItems) //{ // if (command.Tag is Core.AutomationCommands.EndLoopCommand) // { // for (int i = 0; i < dragIndex; i++) // { // if (lstScriptActions.Items[i].Tag is Core.AutomationCommands.BeginLoopCommand) // { // } // } // } //} ListViewItem[] sel = new ListViewItem[lstScriptActions.SelectedItems.Count]; for (int i = 0; i <= lstScriptActions.SelectedItems.Count - 1; i++) { sel[i] = lstScriptActions.SelectedItems[i]; } for (int i = 0; i < sel.GetLength(0); i++) { //Obtain the ListViewItem to be dragged to the target location. ListViewItem dragItem = sel[i]; int itemIndex = dragIndex; if (itemIndex == dragItem.Index) { return; } if (dragItem.Index < itemIndex) { itemIndex++; } else { itemIndex = dragIndex + i; } //Insert the item at the mouse pointer. ListViewItem insertItem = (ListViewItem)dragItem.Clone(); lstScriptActions.Items.Insert(itemIndex, insertItem); //Removes the item from the initial location while //the item is moved to the new location. lstScriptActions.Items.Remove(dragItem); FormatCommandListView(); } }
private void _onTableListDrop(DragEventArgs e) { handleDrop(e); }
private IEnumerable TryGetInsertItems(DragEventArgs e) { return(e.Data.GetData(DataFormats.FileDrop) as IEnumerable ?? e.Data.GetData(typeof(IBlog[])) as IEnumerable); }
public static bool CanDragAndDrop(DragEventArgs e) { return((e.Data.GetDataPresent(typeof(TreeNode)) && ((TreeNode)e.Data.GetData(typeof(TreeNode))).Tag is MetaColumn) || e.Data.GetDataPresent(typeof(Button))); }
public override void Drop(DragEventArgs e, int index) { Debug.Assert(!DisableDrop); if (DisableDrop) { return; } string[] files = e.Data.GetData(AssemblyTreeNode.DataFormat) as string[]; if (files == null) { files = e.Data.GetData(DataFormats.FileDrop) as string[]; } if (files != null && files.Length > 0) { LoadedAssembly newSelectedAsm = null; bool newSelectedAsmExisted = false; var oldIgnoreSelChg = MainWindow.Instance.TreeView_SelectionChanged_ignore; try { lock (assemblyList.GetLockObj()) { int numFiles = assemblyList.Count_NoLock; var old = assemblyList.IsReArranging; try { MainWindow.Instance.TreeView_SelectionChanged_ignore = true; var assemblies = (from file in files where file != null select assemblyList.OpenAssembly(file) into node where node != null select node).Distinct().ToList(); var oldAsm = new Dictionary <LoadedAssembly, bool>(assemblies.Count); foreach (LoadedAssembly asm in assemblies) { int nodeIndex = assemblyList.IndexOf_NoLock(asm); oldAsm[asm] = nodeIndex < numFiles; if (newSelectedAsm == null) { newSelectedAsm = asm; newSelectedAsmExisted = oldAsm[asm]; } if (nodeIndex < index) { index--; } numFiles--; assemblyList.IsReArranging = oldAsm[asm]; assemblyList.RemoveAt_NoLock(nodeIndex); assemblyList.IsReArranging = old; } assemblies.Reverse(); foreach (LoadedAssembly asm in assemblies) { assemblyList.IsReArranging = oldAsm[asm]; assemblyList.Insert_NoLock(index, asm); assemblyList.IsReArranging = old; } } finally { assemblyList.IsReArranging = old; } } if (newSelectedAsm != null) { if (!newSelectedAsmExisted) { MainWindow.Instance.TreeView_SelectionChanged_ignore = oldIgnoreSelChg; } var node = MainWindow.Instance.FindTreeNode(newSelectedAsm.AssemblyDefinition) ?? MainWindow.Instance.FindTreeNode(newSelectedAsm.ModuleDefinition); if (node != null) { MainWindow.Instance.treeView.FocusNode(node); MainWindow.Instance.treeView.SelectedItem = node; } } } finally { MainWindow.Instance.TreeView_SelectionChanged_ignore = oldIgnoreSelChg; } } }
private void NewCheatForm_DragEnter(object sender, DragEventArgs e) { e.Set(DragDropEffects.Copy); }
void panel1_DragOver(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Move; }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtDragDrop_DragEnter(object sender, DragEventArgs e) { ViewMouseDropAllow_FilePath(e); }
/// <summary> /// Virtual method reporting the drag leave is going to happen /// </summary> protected override void OnDragLeave(DragEventArgs e) { base.OnDragLeave(e); if (e.Handled) { return; } _textEditor.OnDragLeave(e); }
private void buton_DragEnter(object sender, DragEventArgs e) { result.Text = "TextBoxDraggedOnButton"; }
private void tvProcessPlanningModule_DragDrop(object sender, DragEventArgs e) { //获得拖放中的节点 TreeNode moveNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); TreeNode parentNode = moveNode.Parent; ///如果该节点不是卡片模版时,则不允许进行拖动 if (moveNode.SelectedImageKey != "card") { return; } //根据鼠标坐标确定要移动到的目标节点 Point pt; TreeNode targeNode; pt = ((TreeView)(sender)).PointToClient(new Point(e.X, e.Y)); targeNode = this.tvProcessPlanningModule.GetNodeAt(pt); TreeNode targeParent = targeNode.Parent; //如果目标节点无子节点则添加为同级节点,反之添加到下级节点的未端 TreeNode NewMoveNode = (TreeNode)moveNode.Clone(); int moveIndex = moveNode.Tag.ToString().IndexOf("@"); string moveId = string.Empty; if (moveIndex > 0) { moveId = moveNode.Tag.ToString().Substring(0, moveIndex); } int targeIndex = targeNode.Tag.ToString().IndexOf("@"); string tagId = string.Empty; if (targeIndex > 0) { tagId = targeNode.Tag.ToString().Substring(0, targeIndex); } int parentIndex = parentNode.Tag.ToString().IndexOf("@"); string parentName = string.Empty; if (parentIndex > 0) { parentName = parentNode.Tag.ToString().Substring(parentIndex + 1); } if (targeNode.Parent == moveNode.Parent) { tvProcessPlanningModule.BeginUpdate(); ProcessPlanningModuleBLL.ChangeTwoCardSortOrder(moveId, moveNode.Name, tagId, targeNode.Name, parentName); parentNode.Nodes.Clear(); ShowCardModuleByParentCode(parentName, parentNode); tvProcessPlanningModule.TreeViewNodeSorter = new Kingdee.CAPP.UI.Common.NodeSorter(); tvProcessPlanningModule.EndUpdate(); tvProcessPlanningModule.Focus(); tvProcessPlanningModule.SelectedNode = targeParent; if (tvProcessPlanningModule.SelectedNode != null) { tvProcessPlanningModule.SelectedNode.EnsureVisible(); } return; } object busiessId = moveId; string prevParentNode = parentName; TreeNodeCollection targeNodes = null; if (targeNode.ImageKey == "card") { targeNodes = targeNode.Parent.Nodes; } else if (targeNode.ImageKey == "planning") { targeNodes = targeNode.Nodes; } foreach (TreeNode nod in targeNodes) { if (nod.Tag.ToString().StartsWith(moveId)) { MessageBox.Show("目标节点下已包含相同的模版,无法移动", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } if (targeNode.Nodes.Count == 0) { if (targeNode.ImageKey == "card") { targeNode.Parent.Nodes.Insert(targeNode.Index, NewMoveNode); } else if (targeNode.ImageKey == "planning") { targeNode.Nodes.Insert(targeNode.Index, NewMoveNode); targeNode.Expand(); } } else { targeNode.Nodes.Insert(targeNode.Nodes.Count, NewMoveNode); } //更新数据库内节点的从属关系 UpdatePlanningModule(targeNode.Parent.Tag.ToString().Substring(targeNode.Parent.Tag.ToString().IndexOf("@") + 1), prevParentNode, busiessId); tvProcessPlanningModule.SelectedNode = NewMoveNode; //展开目标节点,便于显示拖放效果 targeNode.Expand(); //移除拖放的节点 moveNode.Remove(); tvProcessPlanningModule.TreeViewNodeSorter = new Kingdee.CAPP.UI.Common.NodeSorter(); tvProcessPlanningModule.Focus(); tvProcessPlanningModule.SelectedNode = targeParent; if (tvProcessPlanningModule.SelectedNode != null) { tvProcessPlanningModule.SelectedNode.EnsureVisible(); } }
//deny dragdrops protected override void OnDragDrop(DragEventArgs de) { de.Effect = DragDropEffects.None; }
private void window_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { string[] str = (string[]) e.Data.GetData(DataFormats.FileDrop); if (File.Exists(str[0])) { LoadExe(str[0]); } } }
private void textBox3_DragEnter(object sender, DragEventArgs e) { }
private void VideoShitbox_DragDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); Logic.MediaFileDragDrop(files); Invalidate(); prevDragX = -1; } }
private void tabMain_DragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); loadSAV((Util.Prompt(MessageBoxButtons.YesNo, "FlagDiff Researcher:", "Yes: Old Save" + Environment.NewLine + "No: New Save") == DialogResult.Yes) ? B_LoadOld : B_LoadNew, files[0]); }
private void VideoShitbox_DragOver(object sender, DragEventArgs e) { if (prevDragX == e.X) return; prevDragX = e.X; var point = this.PointToClient(new Point(e.X, e.Y)); Logic.MediaFileDragMove(point.X); }
private void dragHandle_DragEnter(object sender, DragEventArgs e) { throw new NotImplementedException(); }
private void FSE_Drop(object sender, DragEventArgs e) { ButtonExt btn = sender as ButtonExt; string[] fileData = (string[])e.Data.GetData(DataFormats.FileDrop); if (fileData.Length > 0) { object temp = btn.Content; btn.Content = fileData[0]; if (Source.Content.ToString() != source && Target.Content.ToString() != target) { if (FSOpt.IsDirectory(Source.Content.ToString()) != FSOpt.IsDirectory(Target.Content.ToString())) { // warning MessageBox msg = new MessageBox(this.Owner as MainWindow, "The type of the file entries are different!"); msg.Owner = this.Owner; msg.ShowDialog(); btn.Content = temp; } } } }
/// <summary> /// Shuffles the panels around. /// </summary> /// <param name="sender">The dragging panel.</param> /// <param name="args">Drag event args.</param> private void DragDockPanel_DragMoved(object sender, DragEventArgs args) { Point mousePosInHost = args.MouseEventArgs.GetPosition(this); int currentRow = (int)Math.Floor(mousePosInHost.Y / (this.ActualHeight / (double)this.rows)); int currentColumn = (int)Math.Floor(mousePosInHost.X / (this.ActualWidth / (double)this.columns)); // Stores the panel we will swap with DragDockPanel swapPanel = null; // Loop through children to see if there is a panel to swap with foreach (UIElement child in this.panels) { DragDockPanel panel = child as DragDockPanel; // If the panel is not the dragging panel and is in the current row // or current column... mark it as the panel to swap with if (panel != this.draggingPanel && Grid.GetColumn(panel) == currentColumn && Grid.GetRow(panel) == currentRow) { swapPanel = panel; break; } } // If there is a panel to swap with if (swapPanel != null) { // Store the new row and column int draggingPanelNewColumn = Grid.GetColumn(swapPanel); int draggingPanelNewRow = Grid.GetRow(swapPanel); // Update the swapping panel row and column Grid.SetColumn(swapPanel, Grid.GetColumn(this.draggingPanel)); Grid.SetRow(swapPanel, Grid.GetRow(this.draggingPanel)); // Update the dragging panel row and column Grid.SetColumn(this.draggingPanel, draggingPanelNewColumn); Grid.SetRow(this.draggingPanel, draggingPanelNewRow); // Animate the layout to the new positions this.AnimatePanelLayout(); } }
private void DraggedOnTab(object sender, DragEventArgs e) { result.Text = "TextBoxDraggedOnTab"; }
private void handleDrop(DragEventArgs e) { var file = Dnd.tryToGetFileOrDirectoryFromDroppedObject(e); mapFile(file); }
private void FilePathBox_DragDrop(object sender, DragEventArgs e) { FilePathBox.Text = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString(); }
private void window_DragOver(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { if ((e.AllowedEffect & DragDropEffects.Copy) != 0) { e.Effect = DragDropEffects.Copy; } } }
private void lbValidatatorForms_DragDrop(object sender, DragEventArgs e) { handleDrop(e); }
void lblAllMoves_DragDrop(object sender, DragEventArgs e) { int oldSlot = Convert.ToInt32(e.Data.GetData(typeof(int))); Network.Messenger.SendSwapMoves(oldSlot, Array.IndexOf(lblAllMoves, sender)); }
private void lbValidatatorForms_DragEnter(object sender, DragEventArgs e) { Dnd.setEffect(e); }
private void VideoShitbox_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) { e.Effect = DragDropEffects.Copy; string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); Logic.MediaFileDragEnter(files, Width); //foreach (string file in files) // Trace.WriteLine(file); } }
private void tvMappings_DragEnter(object sender, DragEventArgs e) { Dnd.setEffect(e); }
private void FSE_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { e.Effects = DragDropEffects.All; } else { e.Effects = DragDropEffects.None; } }
private void tvMappings_DragDrop(object sender, DragEventArgs e) { mapFile(Dnd.tryToGetFileOrDirectoryFromDroppedObject(e)); }
/// <summary> /// Drops the dragging panel. /// </summary> /// <param name="sender">The dragging panel.</param> /// <param name="args">Drag event args.</param> private void DragDockPanel_DragFinished(object sender, DragEventArgs args) { // Set dragging panel back to null this.draggingPanel = null; // Update the layout (to reset all panel positions) this.UpdatePanelLayout(); }
private void DropObject_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Copy; BackColor = cDragOverColor; }
/// <summary> /// Keeps a reference to the dragging panel. /// </summary> /// <param name="sender">The dragging panel.</param> /// <param name="args">Drag event args.</param> private void DragDockPanel_DragStarted(object sender, DragEventArgs args) { DragDockPanel panel = sender as DragDockPanel; // Keep reference to dragging panel this.draggingPanel = panel; }
private void DropObject_DragDrop(object sender, DragEventArgs e) { BackColor = cDragOutColor; // o2Messages.sendMessage_DnDQueue_SendInfoMessage("A drop item was received"); var oDataReceived = new List <object>(); String[] sFormats = e.Data.GetFormats(); foreach (string sFormat in sFormats) { oDataReceived.Add(e.Data.GetData(sFormat)); } foreach (Object oObject in oDataReceived) { Type tObjectBaseType = oObject.GetType().BaseType; if (tObjectBaseType != null && tObjectBaseType == typeof(Dnd.DnDAction)) { processReceivedDnDActionObject((Dnd.DnDAction)oObject); return; } } if (bAcceptNonO2ObjectsAndFireThemAsObjects) { // check if it there is a file name in there: if (oDataReceived.GetType().Name == "List`1") { List <Object> lObject = oDataReceived; foreach (Object oItem in lObject) { String sdata = oItem.ToString(); if (oItem.GetType().Name == "String") { if (File.Exists(sdata)) { // Messages.sendMessage_DnDQueue_SendInfoMessage("Data drop was a file"); eDnDAction_ObjectDataReceived_Event(sdata); return; } } if (oItem.GetType().Name == "String[]") { var asStrings = (String[])oItem; foreach (String sString in asStrings) { if (File.Exists(sString)) { // Messages.sendMessage_DnDQueue_SendInfoMessage("Data drop was a file"); eDnDAction_ObjectDataReceived_Event(sString); return; } if (Directory.Exists(sString)) { // Messages.sendMessage_DnDQueue_SendInfoMessage("Data drop was a Directory"); eDnDAction_ObjectDataReceived_Event(sString); return; } } } } } // if not sent it as an object // Messages.sendMessage_DnDQueue_SendInfoMessage( // "Unrecognized DnD object was droped, but since bAcceptNonO2ObjectsAndFireThemAsObjects is set, we will invoke the events using the received object"); invokeObjectDataReceivedEventWithDataReceived(oDataReceived); } // else // Messages.sendMessage_DnDQueue_SendInfoMessage("Error: wrong type was dropped on the current host"); }
private void textBox_DragEnter(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) e.Effect = DragDropEffects.Copy; }
private void pbBoxSlot_DragDrop(object sender, DragEventArgs e) { DragInfo.slotDestination = this; DragInfo.slotDestinationSlotNumber = getSlot(sender); DragInfo.slotDestinationOffset = getPKXOffset(DragInfo.slotDestinationSlotNumber); DragInfo.slotDestinationBoxNumber = CB_BoxSelect.SelectedIndex; // Check for In-Dropped files (PKX,SAV,ETC) string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (Directory.Exists(files[0])) { return; } if (SAV.getIsSlotLocked(DragInfo.slotDestinationBoxNumber, DragInfo.slotDestinationSlotNumber)) { DragInfo.slotDestinationSlotNumber = -1; // Invalidate WinFormsUtil.Alert("Unable to set to locked slot."); return; } if (DragInfo.slotSourceOffset < 0) // file { if (files.Length <= 0) { return; } string file = files[0]; FileInfo fi = new FileInfo(file); if (!PKX.getIsPKM(fi.Length) && !MysteryGift.getIsMysteryGift(fi.Length)) { return; } byte[] data = File.ReadAllBytes(file); MysteryGift mg = MysteryGift.getMysteryGift(data, fi.Extension); PKM temp = mg != null?mg.convertToPKM(SAV) : PKMConverter.getPKMfromBytes(data, prefer: SAV.Generation); string c; PKM pk = PKMConverter.convertToFormat(temp, SAV.PKMType, out c); if (pk == null) { WinFormsUtil.Error(c); Console.WriteLine(c); return; } string[] errata = SAV.IsPKMCompatible(pk); if (errata.Length > 0) { string concat = string.Join(Environment.NewLine, errata); if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, concat, "Continue?")) { Console.WriteLine(c); Console.WriteLine(concat); return; } } DragInfo.setPKMtoDestination(SAV, pk); getQuickFiller(SlotPictureBoxes[DragInfo.slotDestinationSlotNumber], pk); Console.WriteLine(c); } else { PKM pkz = DragInfo.getPKMfromSource(SAV); if (!DragInfo.SourceValid) { } // not overwritable, do nothing else if (ModifierKeys == Keys.Alt && DragInfo.DestinationValid) // overwrite { // Clear from slot if (DragInfo.SameBox) { getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], SAV.BlankPKM); // picturebox } DragInfo.setPKMtoSource(SAV, SAV.BlankPKM); } else if (ModifierKeys != Keys.Control && DragInfo.DestinationValid) // move { // Load data from destination PKM pk = ((PictureBox)sender).Image != null ? DragInfo.getPKMfromDestination(SAV) : SAV.BlankPKM; // Set destination pokemon image to source picture box if (DragInfo.SameBox) { getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], pk); } // Set destination pokemon data to source slot DragInfo.setPKMtoSource(SAV, pk); } else if (DragInfo.SameBox) // clone { getQuickFiller(SlotPictureBoxes[DragInfo.slotSourceSlotNumber], pkz); } // Copy from temp to destination slot. DragInfo.setPKMtoDestination(SAV, pkz); getQuickFiller(SlotPictureBoxes[DragInfo.slotDestinationSlotNumber], pkz); e.Effect = DragDropEffects.Link; Cursor = DefaultCursor; } if (DragInfo.SourceParty || DragInfo.DestinationParty) { parent.setParty(); } if (DragInfo.slotSource == null) // another instance or file { parent.notifyBoxViewerRefresh(); DragInfo.Reset(); } }
/// <summary> /// Virtual method reporting the drag enter is going to happen /// </summary> protected override void OnDrop(DragEventArgs e) { base.OnDrop(e); if (e.Handled) { return; } if (_textEditor != null) { _textEditor.OnDrop(e); } }
private void ColorChooserForm_DragEnter(object sender, DragEventArgs e) { e.Set(DragDropEffects.Move); }
private void MainForm_DragDrop(object sender, DragEventArgs e) { var paths = (string[])e.Data.GetData(DataFormats.FileDrop, false); if (CheckFilePath(paths[0])) { ReadRssFromFile(paths[0]); } }
private void PicAvatar_DragEnter(object sender, DragEventArgs e) { e.Effect = DragDropEffects.Copy; }