当前位置: 首页>>代码示例>>C#>>正文


C# DataObject.SetFileDropList方法代码示例

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


在下文中一共展示了DataObject.SetFileDropList方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ToDataObject

        public static DataObject ToDataObject(this TransferDataSource data)
        {
            var retval = new DataObject ();
            foreach (var type in data.DataTypes) {
                var value = data.GetValue (type);

                if (type == TransferDataType.Text)
                    retval.SetText ((string)value);
                else if (type == TransferDataType.Uri) {
                    var uris = new StringCollection ();
                    uris.Add (((Uri)value).LocalPath);
                    retval.SetFileDropList (uris);
                } else
                    retval.SetData (type.Id, TransferDataSource.SerializeValue (value));
            }

            return retval;
        }
开发者ID:jbeaurain,项目名称:xwt,代码行数:18,代码来源:DataConverter.cs

示例2: DragStarted

		static void DragStarted(UIElement uiElt)
		{
			_isMouseDown = false;
			Mouse.Capture(uiElt);

			DataObject data = new DataObject();
			//obj.SetData(DataFormats.Text, "Text from WPF - CrossApp example");
			StringCollection files = new StringCollection();
			files.Add(@"C:\Documents and Settings\528046\Desktop\crystal_project\readme.txt");
			data.SetFileDropList(files);
			DragDropEffects supportedEffects = DragDropEffects.Move | DragDropEffects.Copy;

			// Perform DragDrop
			DragDropEffects effects = System.Windows.DragDrop.DoDragDrop(_draggedElt, data, supportedEffects);

			// Clean up
			Mouse.Capture(null);
			_draggedElt = null;
		}
开发者ID:shu2333,项目名称:dnGrep,代码行数:19,代码来源:Test.xaml.cs

示例3: Execute

        public override void Execute(object parameter)
        {
            var active = MainViewModel.ActiveDirectoryContainer.ActiveView;
            if (!active.FileSystem.IsWindowsFileSystem)
            {
                MessageBox.Show("To polecenie działa tylko w windows'owym systemie plików");
                return;
            }

            //get items to copy
            var items = MainViewModel.GetSelectedItems();
            if (items.Length == 0)
            {
                MessageBox.Show("Zaznacz obiekty do skopiowania");
                return;
            }

            //get paths to copy from items
            var paths = new StringCollection();
            foreach (IDirectoryViewItem item in items)
                paths.Add(item.FullName);

            //and here goes magic
            //set special binary data that indicates that file must be copy
            byte[] moveEffect = new byte[] { 5, 0, 0, 0 };//copy
            var dropEffect = new MemoryStream();
            dropEffect.Write(moveEffect, 0, moveEffect.Length);

            //set data object with file's paths
            DataObject data = new DataObject();
            data.SetFileDropList(paths);
            data.SetData("Preferred DropEffect", dropEffect);

            //set data object in clipboard
            Clipboard.Clear();
            //dropEffect.Close();
            Clipboard.SetDataObject(data, true);
        }
开发者ID:kkalinowski,项目名称:nex,代码行数:38,代码来源:ClipboardCopyCommand.cs

示例4: contentView_PreviewMouseMove

        private void contentView_PreviewMouseMove(object sender, MouseEventArgs e)
        {
            var senderObj = sender as ScoreboardControl;

            if (senderObj == null)
            {
                // This shouldn't happen.
                return;
            }

            // Get the current mouse position
            Point mousePos = e.GetPosition(null);
            Vector diff = this.startPoint - mousePos;

            if (e.LeftButton == MouseButtonState.Pressed &&
                (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance ||
                Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance))
            {
                string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "starboard.xbs");

               if (File.Exists(path) == false)
               {
                   return;
               }

                var strCol = new StringCollection { path };

                var o = new DataObject(DataFormats.FileDrop, strCol);
                o.SetFileDropList(strCol);
                DragDrop.DoDragDrop(senderObj, o, DragDropEffects.Copy);
            }
        }
开发者ID:ascendedguard,项目名称:starboard-dota2,代码行数:32,代码来源:ScoreboardControlPanelView.xaml.cs

示例5: OnMouseLeftButtonDown

        void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!IsMouseCaptured)
            {
                dragStart = e.GetPosition(this);
                ShellObjectCollection collection = new ShellObjectCollection();
                System.Collections.IList list =
                    (DropDataList.SelectedItems.Count > 0) ?
                        DropDataList.SelectedItems : DropDataList.Items;

                foreach (ShellObject shellObject in list)
                {
                    collection.Add(shellObject);
                }

                if (collection.Count > 0)
                {
                    // This builds a DataObject from a "Shell IDList Array" formatted memory stream.
                    // This allows drag/clipboard operations with non-file based ShellObjects (i.e., 
                    // control panel, libraries, search query results)
                    dataObject = new DataObject(
                        "Shell IDList Array",
                        collection.BuildShellIDList());

                    // Also build a file drop list
                    System.Collections.Specialized.StringCollection paths = new System.Collections.Specialized.StringCollection();
                    foreach (ShellObject shellObject in collection)
                    {
                        if (shellObject.IsFileSystemObject)
                        {
                            paths.Add(shellObject.ParsingName);
                        }
                    }
                    if (paths.Count > 0)
                        dataObject.SetFileDropList(paths);
                }
            }
        }
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:38,代码来源:DragAndDropWindow.xaml.cs

示例6: treeDragStarted

        private void treeDragStarted(UIElement uiElt)
        {
            _isMouseDown = false;
            Mouse.Capture(uiElt);

            DataObject data = new DataObject();

            if (tvSearchResult.SelectedItem is FormattedGrepLine)
            {
                FormattedGrepLine selectedNode = (FormattedGrepLine)tvSearchResult.SelectedItem;
                data.SetData(DataFormats.Text, selectedNode.GrepLine.LineText);
            }
            else if (tvSearchResult.SelectedItem is FormattedGrepResult)
            {
                FormattedGrepResult result = (FormattedGrepResult)tvSearchResult.SelectedItem;
                StringCollection files = new StringCollection();
                files.Add(result.GrepResult.FileNameReal);
                data.SetFileDropList(files);
            }


            DragDropEffects supportedEffects = DragDropEffects.Move | DragDropEffects.Copy;
            // Perform DragDrop
            DragDropEffects effects = System.Windows.DragDrop.DoDragDrop(_draggedElt, data, supportedEffects);

            // Clean up
            Mouse.Capture(null);
            _draggedElt = null;
        }
开发者ID:shu2333,项目名称:dnGrep,代码行数:29,代码来源:ResultsTree.xaml.cs

示例7: CopyOnClipboard

        public void CopyOnClipboard()
        {
            try
            {
                if (!isEmpty)
                {
                    if (IsAudio)
                    {
                        Clipboard.SetAudio(Audio);
                    }
                    else if (IsText)
                    {
                        Clipboard.SetText(Text);
                    }
                    else if (IsFile)
                    {

                        //Impostare il l'effetto taglia per rimuovere dai file temporanei
                        MemoryStream dropEffect = new MemoryStream();
                        dropEffect.Write(CUT_EFFECT, 0, CUT_EFFECT.Length);
                        DataObject data = new DataObject();
                        data.SetFileDropList(FileDropList);
                        data.SetData("Preferred DropEffect", dropEffect);
                        Clipboard.Clear();
                        Clipboard.SetDataObject(data, true);

                    }
                    else
                    {

                        MemoryStream ms = new MemoryStream(Image);
                        ms.Position = 0;
                        BitmapImage image = new BitmapImage();
                        image.BeginInit();
                        image.StreamSource = ms;
                        image.EndInit();
                        Clipboard.SetImage(image);
                    }
                }
            }
            catch (Exception ex) { Trace.TraceError("Exception in CopyOnClipboard()", ex.StackTrace); }
        }
开发者ID:giu-fio,项目名称:remote-control-server,代码行数:42,代码来源:MyClibpoard.cs

示例8: ToDataObject

		public static DataObject ToDataObject (this TransferDataSource data)
		{
			var retval = new DataObject ();
			foreach (var type in data.DataTypes) {
				var value = data.GetValue (type);

				if (type == TransferDataType.Text) {
					retval.SetText ((string)value);
				}
				else if (type == TransferDataType.Uri) {
					Uri uri = (Uri)value;
					if (uri.IsFile) {
						var uris = new StringCollection ();
						uris.Add (uri.LocalPath);
						retval.SetFileDropList (uris);
					} else {
						string strOrig = uri.ToString();
						string str = strOrig + ((char)0);
						char[] chars = str.ToArray();
						byte[] bytes = Encoding.UTF8.GetBytes(chars, 0, chars.Length);
						MemoryStream stream = new MemoryStream(bytes);
						retval.SetData ("UniformResourceLocator", stream);
					}
				} else
					retval.SetData (type.Id, TransferDataSource.SerializeValue (value));
			}

			string anyUri = data.LinkUri != null ? data.LinkUri.ToString() : null;
			string anyPath = data.LinkTmpPath;
			if (anyUri != null && anyPath != null) {
				// write tmp file to disk with /path/to/tmp/Page-Title.url
				string urlContents = "[InternetShortcut]\nURL=" + anyUri;
				File.WriteAllText(anyPath, urlContents);
				StringCollection strCollect = new StringCollection();
				strCollect.Add(anyPath);
				retval.SetFileDropList(strCollect);
			}

			return retval;
		}
开发者ID:TheBrainTech,项目名称:xwt,代码行数:40,代码来源:DataConverter.cs

示例9: SetSystem

		public void SetSystem()
		{
			var dataObj = new DataObject();

			dataObj.SetText(Text, TextDataFormat.UnicodeText);
			dataObj.SetData(typeof(NELocalClipboard), PID);

			if (IsCut.HasValue)
			{
				var dropList = new StringCollection();
				dropList.AddRange(Strings.ToArray());
				dataObj.SetFileDropList(dropList);
				dataObj.SetData("Preferred DropEffect", new MemoryStream(BitConverter.GetBytes((int)(IsCut == true ? DragDropEffects.Move : DragDropEffects.Copy | DragDropEffects.Link))));
			}

			if (Image != null)
				dataObj.SetImage(Image);

			Clipboard.SetDataObject(dataObj, true);
		}
开发者ID:xyandro,项目名称:NeoEdit,代码行数:20,代码来源:ClipboardData.cs

示例10: ClipboardReceived

        private void ClipboardReceived(object sender, RunWorkerCompletedEventArgs eventArgs)
        {
            if (!eventArgs.Cancelled && eventArgs.Error == null)
            {
                ArrayList data = (ArrayList)eventArgs.Result;
                if (data != null)
                {
                    DataObject dataObj = new DataObject();
                    Console.WriteLine("Count: " + data.Count);
                    for (int i = 0; i < data.Count; i++)
                    {
                        string format = (string)data[i++];
                        Console.WriteLine(format);
                        dataObj.SetData(format, data[i]);
                    }

                    if (dataObj.ContainsFileDropList())
                    {
                        StringCollection files = dataObj.GetFileDropList();
                        dataObj = new DataObject();
                        StringCollection adjusted = new StringCollection();
                        foreach (string f in files)
                        {
                            if (!f.StartsWith("\\"))
                            {
                                string toadd = "\\\\" + Ip + "\\" + f.Replace(":", "");
                                Console.WriteLine(toadd);
                                adjusted.Add(toadd);
                            }
                            else
                            {
                                adjusted.Add(f);
                            }
                        }
                        dataObj.SetFileDropList(adjusted);
                    }
                    Clipboard.SetDataObject(dataObj);

                }
            }
        }
开发者ID:fabriziogueli,项目名称:Mouse-Keyboard-Remote-Control-Client,代码行数:41,代码来源:Server.cs

示例11: OnMouseMove

        protected override void OnMouseMove(MouseEventArgs args)
        {
            if(args.LeftButton == MouseButtonState.Pressed
                && clickedIn) {
                Point cursorAt = args.GetPosition(this);

                if(Math.Abs(cursorAt.X - clickStarted.X) > 5 ||
                    Math.Abs(cursorAt.Y - clickStarted.Y) > 5) {
                    DataObject dragData = new DataObject(
                        typeof(Node),
                        Node);
                    string root = System.IO.Path.GetDirectoryName(
                        Node.Project.SavePath);

                    if(Node is File)
                        dragData.SetFileDropList(new StringCollection {
                                Path.Combine(root, (DataContext as File).RealPath)
                            });
                    else if(Node is OtherFile)
                        dragData.SetFileDropList(new StringCollection {
                                Path.Combine(root, (DataContext as OtherFile).RealPath)
                            });
                    else if(Node is ExternalFile)
                        dragData.SetFileDropList(new StringCollection {
                                (DataContext as ExternalFile).RealPath
                            });
                    else if(Node is ExternalFolder)
                        dragData.SetFileDropList(new StringCollection {
                                (DataContext as ExternalFolder).RealPath
                            });

                    DragDrop.DoDragDrop(this, DataContext, DragDropEffects.Move | DragDropEffects.Link);

                    args.Handled = true;
                }
            }
            else {
                clickedIn = false;
                base.OnMouseMove(args);
            }
        }
开发者ID:faboo,项目名称:faux,代码行数:41,代码来源:NodeTreeItem.cs

示例12: SetClipboard

        public void SetClipboard(string Ip, Object obj)
        {
            try
            {
                ArrayList data = (ArrayList)obj;
                if (data != null)
                {
                    DataObject dataObj = new DataObject();
                    Console.WriteLine("Count: " + data.Count);
                    for (int i = 0; i < data.Count; i++)
                    {
                        string format = (string)data[i++];
                        Console.WriteLine(format);
                        dataObj.SetData(format, data[i]);
                    }
                    if (dataObj.ContainsFileDropList())
                    {
                        StringCollection files = dataObj.GetFileDropList();
                        dataObj = new DataObject();
                        StringCollection adjusted = new StringCollection();
                        foreach (string f in files)
                        {
                            if (!f.StartsWith("\\"))
                            {
                                string toadd = "\\\\" + Ip + "\\" + f.Replace(":", "");
                                Console.WriteLine(toadd);
                                adjusted.Add(toadd);
                            }
                            else
                            {
                                adjusted.Add(f);
                            }
                        }
                        dataObj.SetFileDropList(adjusted);
                    }
                    Clipboard.SetDataObject(dataObj);

                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
开发者ID:alessioscicolone,项目名称:Mouse-Keyboard-Remote-Control-Server,代码行数:44,代码来源:MyClipBoard.cs


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