Пример #1
0
        void Context_DragDrop(object sender, DragEventArgs e)
        {
            if (!AcceptDrop)
            {
                return;
            }

            var tagsPrefix = GetTagsPrefix();

            ClipboardUrl cbUrl;

            if (ClipboardUrl.TryParse(e.Data, out cbUrl))
            {
                FileActionFactory f = new FileActionFactory();
                var action          = f.FromUrl(cbUrl.Url, cbUrl.Title);
                action.Name = tagsPrefix + action.Name;
                actions.AddOrUpdate(action);
                return;
            }

            // right-mouse drag - add recursive
            bool recursive = (e.Effect == DragDropEffects.Link);

            var pathList = Sidi.IO.PathList.Get(e.Data);

            if (pathList != null)
            {
                context.AddJob(new Job(pathList.ToString(), () => { Add(pathList, tagsPrefix); }));
                return;
            }

            log.WarnFormat("Dropped data could not be added. Available formats:\r\n{0}", e.Data.GetFormats().ListFormat());
        }
Пример #2
0
        public static bool TryParse(IDataObject data, out ClipboardUrl clipboardUrl)
        {
            try
            {
                var c = new ClipboardUrl();
                if (data.GetDataPresent(FileGroupDescriptorWFormat))
                {
                    var d = data.GetData(FileGroupDescriptorWFormat);
                    c.Title = System.IO.Path.GetFileNameWithoutExtension(ReadFileDescriptorW((MemoryStream)d));
                }
                if (data.GetDataPresent(UniformResourceLocatorWFormat))
                {
                    c.Url = ((Stream)data.GetData(UniformResourceLocatorWFormat))
                            .ReadFixedLengthUnicodeString(260);
                }
                else if (data.GetDataPresent(FileContentsFormat))
                {
                    c.Url = ReadUrl((Stream)data.GetData(FileContentsFormat));
                }

                clipboardUrl = c;
                return(c.Url != null);
            }
            catch (Exception)
            {
                Dump(data);
                clipboardUrl = null;
                return(false);
            }
        }