• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Forms.DragEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Forms.DragEventArgs的典型用法代码示例。如果您正苦于以下问题:C# DragEventArgs类的具体用法?C# DragEventArgs怎么用?C# DragEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DragEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了DragEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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());
            }
        }
开发者ID:idefav,项目名称:ToolsManager,代码行数:26,代码来源:MainForm.cs


示例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();
        }
开发者ID:aureliopires,项目名称:gisa,代码行数:27,代码来源:FicheirosOrderManager.cs


示例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;
            }
        }
开发者ID:syego,项目名称:thumbnail_poller,代码行数:28,代码来源:FileBrowsePanel.cs


示例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);
            }
        }
开发者ID:gedgei,项目名称:BookDbSharp,代码行数:30,代码来源:MainForm.cs


示例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;
 }
开发者ID:3020group,项目名称:MovieOrganizer,代码行数:7,代码来源:Form1.cs


示例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();
		}
开发者ID:Nhale,项目名称:INVedit,代码行数:28,代码来源:ItemSlot.cs


示例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;
			}
		}
开发者ID:ddugovic,项目名称:RASuite,代码行数:28,代码来源:MainDiscoForm.cs


示例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;
 }
开发者ID:darkguy2008,项目名称:gamepower-free,代码行数:7,代码来源:frmMain.cs


示例9: MainFormDragOver

 void MainFormDragOver(object sender, DragEventArgs e)
 {
     //permitir el arraster sobre la forma
     if (e.Data.GetDataPresent(DataFormats.FileDrop)){
         e.Effect = DragDropEffects.Copy;
     }
 }
开发者ID:diniremix,项目名称:SharpDevelop-Apps,代码行数:7,代码来源:MainForm.cs


示例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);
        }
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:34,代码来源:DragDropTreeView.cs


示例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
     {
     }
 }
开发者ID:destnity,项目名称:AntiTamperEOF,代码行数:34,代码来源:Form1.cs


示例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);
        }
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:26,代码来源:DragDropTreeView.cs


示例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;
 }
开发者ID:lythm,项目名称:orb3d,代码行数:7,代码来源:BotListForm.cs


示例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());
            }
        }
开发者ID:khaha2210,项目名称:CodeNewTeam,代码行数:32,代码来源:frmQuickReorderTestSequence.cs


示例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;
				}
			}
		}
开发者ID:aureliopires,项目名称:gisa,代码行数:26,代码来源:GenericDragDrop.cs


示例16: frm_DragDrop

 private void frm_DragDrop(object sender, DragEventArgs e)
 {
     Array a = (Array)e.Data.GetData(DataFormats.FileDrop);
     if (a != null)
     {
         string s = a.GetValue(0).ToString();
         bool isDirectory = Directory.Exists(s);
         if (isDirectory)
         {
             _directory = s;
         }
         bool isFile = File.Exists(s);
         if (isFile)
         {
             string filepart = s.Substring(s.LastIndexOf("\\") + 1);
             string pattern = patternMacro(filepart);
             txtPattern.Text = pattern;
             txtNewName.Text = filepart;
             _directory = s.Substring(0, s.LastIndexOf("\\"));
         }
         if (!isDirectory && !isFile)
         {
             // Something odd, just ignore
         }
         this.Activate();	// in the case Explorer overlaps this form
     }
     RefreshGrid();
 }
开发者ID:daveroberts,项目名称:RegexRenamer,代码行数:28,代码来源:Form1.cs


示例17: DragDrop

		private void DragDrop(object sender, DragEventArgs e)
		{
			try
			{
				foreach (Type CurrentType in AcceptTypes)
				{
					if (e.Data.GetDataPresent(CurrentType.FullName))
					{
						if (CurrentType.IsArray)
						{
							object[] objs = (object[])(e.Data.GetData(CurrentType.FullName));
							foreach (object obj in objs)
								AcceptContents(obj);
						}
						else
							AcceptContents(e.Data.GetData(CurrentType.FullName));

						e.Effect = DragDropEffects.Link;
					}
				}
			}
			catch (Exception ex)
			{
				Trace.WriteLine(ex);
				Debug.Assert(false, ex.ToString());
				throw;
			}
		}
开发者ID:aureliopires,项目名称:gisa,代码行数:28,代码来源:GenericDragDrop.cs


示例18: ProcessDataObject

        public static string ProcessDataObject(DragEventArgs e) {
            // If the dropped object is from ArcCatalog then export the geodatabase
            // to XML and return pathname.
            if (e.Data.GetDataPresent("ESRI Names")) {
                return GeodatabaseUtility.ExportXml(e);
            }

            // If a use dropped one or more files then get first file and verify that it
            // has a "xml" or "diagram" extension.
            if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
                object drop = e.Data.GetData(DataFormats.FileDrop);
                if (drop == null) { return null; }

                string[] files = drop as string[];
                if (files == null) { return null; }
                if (files.Length != 1) { return null; }

                string file = files[0];
                string extension = System.IO.Path.GetExtension(file);
                switch (extension.ToUpper()) {
                    case ".XML":
                    case ".DIAGRAM":
                        return file;
                    default:
                        return null;
                }
            }

            // Invalid DataObject. Return Null.
            return null;
        }
开发者ID:savagemat,项目名称:arcgis-diagrammer,代码行数:31,代码来源:GeodatabaseUtility.cs


示例19: ActionHolder_DragEnter

 private void ActionHolder_DragEnter(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(typeof(ActionHolder)))
     {
         e.Effect = DragDropEffects.Move | DragDropEffects.Copy | DragDropEffects.Scroll;
     }
 }
开发者ID:thomaswp,项目名称:StoryArc,代码行数:7,代码来源:ActionHolder.cs


示例20: ExportXml

        public static string ExportXml(DragEventArgs e) {
            // Get dropped object
            if (!e.Data.GetDataPresent("ESRI Names")) { return null; }
            object drop = e.Data.GetData("ESRI Names");

            // Convert to byte array
            MemoryStream memoryStream = (MemoryStream)drop;
            byte[] bytes = memoryStream.ToArray();
            object byteArray = (object)bytes;

            // Get First WorkpaceName
            INameFactory nameFactory = new NameFactoryClass();
            IEnumName enumName = nameFactory.UnpackageNames(ref byteArray);
            IName name = enumName.Next();
            IWorkspaceName workspaceName = name as IWorkspaceName;
            if (workspaceName != null){
                return GeodatabaseUtility.ExportWorkspaceXml(workspaceName);
            };

            MessageBox.Show(
                Resources.TEXT_DROPPED_OBJECT_NOT_VALID_GEODATABASE,
                Resources.TEXT_APPLICATION,
                MessageBoxButtons.OK,
                MessageBoxIcon.Error,
                MessageBoxDefaultButton.Button1,
                MessageBoxOptions.DefaultDesktopOnly);
            return null;
        }
开发者ID:savagemat,项目名称:arcgis-diagrammer,代码行数:28,代码来源:GeodatabaseUtility.cs



注:本文中的System.Windows.Forms.DragEventArgs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Forms.DrawItemEventArgs类代码示例发布时间:2022-05-26
下一篇:
C# Forms.Document类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap