本文整理汇总了C#中System.Windows.Forms.DragEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DragEventArgs类的具体用法?C# DragEventArgs怎么用?C# DragEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DragEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了DragEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: pAppList_DragDrop
private void pAppList_DragDrop(object sender, DragEventArgs e)
{
try
{
Array aryFiles = ((Array)e.Data.GetData(DataFormats.FileDrop));
for (int i = 0; i < aryFiles.Length; i++)
{
if (File.Exists(aryFiles.GetValue(i).ToString()))
{
string dest = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "api",
Path.GetFileName(aryFiles.GetValue(i).ToString()));
if (File.Exists(dest))
{
MessageBox.Show(string.Format("[{0}]文件已存在",aryFiles.GetValue(i).ToString()));
continue;
}
File.Copy(aryFiles.GetValue(i).ToString(),dest);
}
}
}
catch (Exception exception)
{
MessageBox.Show(exception.ToString());
}
}
示例2: lstVw_DragDrop
private void lstVw_DragDrop(object sender, DragEventArgs e)
{
if (readOnlyMode) return;
string s = (string)e.Data.GetData(DataFormats.Html);
List<string> urls = new List<string>();
string sourceUrl = GetSourceURL(s);
if (sourceUrl != null)
{
WebBrowser wb = new WebBrowser();
wb.DocumentText = s;
do { Application.DoEvents(); } while (wb.ReadyState != WebBrowserReadyState.Complete);
urls.AddRange(ExtractUrls(wb.Document.Links, "href", sourceUrl));
urls.AddRange(ExtractUrls(wb.Document.Images, "src", sourceUrl));
wb.Dispose();
}
var items = new List<ListViewItem>();
items.AddRange(urls.Select(url => CreateNewItem(url)));
populateItems(items);
if (urls.Count > 0)
this.OnAttachedFileDeleted(e);
updateToolBarButtons();
}
示例3: OnDragDrop
protected override void OnDragDrop(DragEventArgs drgevent) {
if (drgevent.Data.GetDataPresent(DataFormats.FileDrop)) {
string[] filelist = (string[])drgevent.Data.GetData(DataFormats.FileDrop, false);
if (filelist.Length != 1) {
MessageBox.Show(
"アイテムは1つだけドロップしてください。",
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
string path = filelist[0];
if (_mode == FileBrowseStyle.Directory && !Directory.Exists(path)) {
MessageBox.Show(
"ファイルではなくフォルダをドロップしてください。",
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else if (_mode != FileBrowseStyle.Directory && Directory.Exists(path)) {
MessageBox.Show(
"フォルダではなくファイルをドロップしてください。",
Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
pathComboBox.Text = path;
}
}
示例4: lvReadingQueue_DragDrop
private void lvReadingQueue_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof (Book)))
{
var book = (Book) e.Data.GetData(typeof (Book));
// if is already in reading queue, do not add it again
foreach (ListViewItem existingItem in lvReadingQueue.Items)
{
if (((Book) existingItem.Tag).Id == book.Id)
return;
}
var insertIndex = lvReadingQueue.Items.Count;
Point cp = lvReadingQueue.PointToClient(new Point(e.X, e.Y));
ListViewItem dragToItem = lvReadingQueue.GetItemAt(cp.X, cp.Y);
if (dragToItem != null)
{
insertIndex = dragToItem.Index;
}
var item = new ListViewItem(book.Title);
item.Tag = book;
lvReadingQueue.Items.Insert(insertIndex, item);
applicationService.QueueForReading(book.Id, insertIndex);
}
}
示例5: button1_DragEnter
private void button1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.Copy;
}
示例6: OnDragDrop
protected override void OnDragDrop(DragEventArgs e)
{
OnDragOver(e);
if (e.Effect == DragDropEffects.None) return;
Item item = (Item)e.Data.GetData(typeof(Item));
if (e.Effect == DragDropEffects.Link) {
if (Item == null) {
Item = new Item(item.ID, (byte)(item.Count/2), Slot, item.Damage);
item.Count -= Item.Count;
} else {
byte count = Item.Count;
Item.Count = Math.Min((byte)(count+item.Count/2), (byte)64);
item.Count -= (byte)(Item.Count-count);
}
} else if (e.Effect == DragDropEffects.Move && Item != null && item.ID == Item.ID && Item.Damage == item.Damage) {
byte count = (byte)Math.Min((int)Item.Count + item.Count, item.Stack);
byte over = (byte)Math.Max((int)Item.Count + item.Count - item.Stack, 0);
Item = new Item(Item.ID, count, Slot, Item.Damage);
other = (over>0) ? new Item(Item.ID, over) : null;
} else {
other = Item; Item = item;
if (e.Effect == DragDropEffects.Copy)
Item = new Item(Item.ID, Item.Count, Slot, Item.Damage);
else Item.Slot = Slot;
}
LostFocus += OnLostFocus;
Select();
}
示例7: lblMagicDragArea_DragDrop
private void lblMagicDragArea_DragDrop(object sender, DragEventArgs e)
{
List<string> files = validateDrop(e.Data);
if (files.Count == 0) return;
try
{
foreach (var file in files)
{
var prefs = GetCuePrefs();
string ext = Path.GetExtension(file).ToUpper();
Disc disc = null;
if (ext == ".ISO")
disc = Disc.FromIsoPath(file);
else if(ext == ".CUE")
disc = Disc.FromCuePath(file, prefs);
string baseName = Path.GetFileNameWithoutExtension(file);
baseName += "_hawked";
prefs.ReallyDumpBin = true;
var cueBin = disc.DumpCueBin(baseName, GetCuePrefs());
Dump(cueBin, Path.GetDirectoryName(file), prefs);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "oops! error");
throw;
}
}
示例8: lbDrop_DragEnter
void lbDrop_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.All;
else
e.Effect = DragDropEffects.None;
}
示例9: MainFormDragOver
void MainFormDragOver(object sender, DragEventArgs e)
{
//permitir el arraster sobre la forma
if (e.Data.GetDataPresent(DataFormats.FileDrop)){
e.Effect = DragDropEffects.Copy;
}
}
示例10: OnDragDrop
protected override void OnDragDrop(DragEventArgs e)
{
if (IsOurDrag(e.Data))
{
ArrayList draggedNodes = (ArrayList)e.Data.GetData(typeof(ArrayList));
TreeNode targetNode = base.GetNodeAt(PointToClient(new Point(e.X,e.Y)));
targetNode = ChangeDropTarget(targetNode);
if (draggedNodes != null && targetNode != null)
DragNodes(draggedNodes,targetNode,e.Effect);
}
else if (IsFileDrop(e.Data))
{
TreeNode targetNode = base.GetNodeAt(PointToClient(new Point(e.X,e.Y)));
targetNode = ChangeDropTarget(targetNode);
if (targetNode == null) return;
// the data is in the form of an array of paths
Array aFiledrop = (Array)e.Data.GetData(DataFormats.FileDrop);
// make a string array
string[] paths = new string[aFiledrop.Length];
for (int i=0; i<paths.Length; i++)
paths[i] = aFiledrop.GetValue(i) as string;
// queue the copy/move operation so we don't hang this thread and block the calling app
BeginInvoke(new OnFileDropHandler(OnFileDrop),new object[]{paths,targetNode});
// somehow querycontinuedrag doesn't work in this case
UnhighlightTarget();
}
else base.OnDragDrop(e);
}
示例11: TextBox1DragDrop
private void TextBox1DragDrop(object sender, DragEventArgs e)
{
try
{
Array array = (Array)e.Data.GetData(DataFormats.FileDrop);
if (array != null)
{
string text = array.GetValue(0).ToString();
int num = text.LastIndexOf(".", StringComparison.Ordinal);
if (num != -1)
{
string text2 = text.Substring(num);
text2 = text2.ToLower();
if (text2 == ".exe" || text2 == ".dll")
{
Activate();
textBox1.Text = text;
int num2 = text.LastIndexOf("\\", StringComparison.Ordinal);
if (num2 != -1)
{
DirectoryName = text.Remove(num2, text.Length - num2);
}
if (DirectoryName.Length == 2)
{
DirectoryName += "\\";
}
}
}
}
}
catch
{
}
}
示例12: OnDragOver
protected override void OnDragOver(DragEventArgs e)
{
base.OnDragOver(e);
if (IsOurDrag(e.Data))
e.Effect = (e.KeyState == 9) ? DragDropEffects.Copy : DragDropEffects.Move;
else if (IsFileDrop(e.Data))
e.Effect = DragDropEffects.Copy;
else
return;
TreeNode node = base.GetNodeAt(PointToClient(new Point(e.X,e.Y)));
node = ChangeDropTarget(node);
if (node != null)
{
if (!base.SelectedNodes.Contains(node))
HighlightTarget(node);
}
else
{
e.Effect = DragDropEffects.None;
}
DragScroll(e);
}
示例13: BostList_DragEnter
private void BostList_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(string)))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
示例14: dataGridView1_DragDrop
private void dataGridView1_DragDrop(object sender, DragEventArgs e)
{
try
{
// The mouse locations are relative to the screen, so they must be
// converted to client coordinates.
var clientPoint = dataGridView1.PointToClient(new Point(e.X, e.Y));
// Get the row index of the item the mouse is below.
rowIndexOfItemUnderMouseToDrop = dataGridView1.HitTest(clientPoint.X, clientPoint.Y).RowIndex;
// If the drag operation was a move then remove and insert the row.
if (e.Effect == DragDropEffects.Move)
{
//var rowToMove2 = e.Data.GetData(typeof(DataGridViewRow)) as DataGridViewRow;
var rowToMove = dtDataControl.Rows[rowIndexFromMouseDown];
var row = dtDataControl.NewRow();
for (int i = 0; i < dtDataControl.Columns.Count; i++)
row[i] = rowToMove[i];
dtDataControl.Rows.RemoveAt(rowIndexFromMouseDown);
dtDataControl.Rows.InsertAt(row, rowIndexOfItemUnderMouseToDrop);
dataGridView1.CurrentCell = dataGridView1[1, rowIndexOfItemUnderMouseToDrop];
dtDataControl.AcceptChanges();
Console.WriteLine("OK");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
示例15: DragOver
private void DragOver(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.None;
foreach (Type CurrentType in AcceptTypes)
{
if (e.Data.GetDataPresent(CurrentType.FullName))
{
bool Cancel = false;
if (CurrentType.IsArray)
{
object[] objs = (object[])(e.Data.GetData(CurrentType.FullName));
foreach (object obj in objs)
{
VerifyContents(obj, ref Cancel);
if (Cancel)
break;
}
}
else
VerifyContents(e.Data.GetData(CurrentType.FullName), ref Cancel);
if (! Cancel)
e.Effect = DragDropEffects.Link;
}
}
}