本文整理汇总了C#中DragEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DragEventArgs类的具体用法?C# DragEventArgs怎么用?C# DragEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DragEventArgs类属于命名空间,在下文中一共展示了DragEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GroupBox_DragOver
void GroupBox_DragOver (object sender, DragEventArgs e)
{
_eventsText.AppendText ("GroupBox => DragOver "
+ _dragoverCount++.ToString (CultureInfo.InvariantCulture)
+ Environment.NewLine);
e.Effect = DragDropEffects.Move;
}
示例2: OnDragLeave
void OnDragLeave(object sender, DragEventArgs e)
{
if (!IsMouseOverTreeView(e.GetPosition(TreeView)))
{
CleanUpAdorners();
}
}
示例3: DragEnter
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);
}
示例4: OnDragEnter
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;
}
}
示例5: DragEventArgs
/// <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;
}
示例6: GroupBox_DragDrop
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);
}
}
}
示例7: textBox_DragDrop
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);
}
示例8: MainForm_DragEnter
private void MainForm_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
示例9: GroupBox_DragEnter
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;
}
}
}
示例10: HandleDrag
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);
}
示例11: OnDragOver
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;
}
}
示例12: AddCrossingInCell
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;
}
示例13: DetermineDragDropEffect
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;
}
示例14: TreeView_DragDrop
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);
}
}
示例15: DragDrop
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) { ;}
}
}
}