public void DragDrop_FilesAttached_ShouldSucceed() { var browserStub = MockRepository.GenerateStub<IExtendedWebBrowser>(); _dragAndDropEvent.AddDragDropSource (browserStub); var dataObjectStub = MockRepository.GenerateStub<IDataObject>(); dataObjectStub.Stub (_ => _.GetData (DataFormats.FileDrop)).Return (_filePaths); var eventArgs = new ExtendedDragEventHandlerArgs (dataObjectStub, 0, 1, 1, DragDropEffects.All, DragDropEffects.None, _documentHandle); eventArgs.Current = _droppableElementData; var wasRaised = false; _dragAndDropEvent.DragDrop += (source, name, arguments) => { Assert.That (source, Is.InstanceOf<DragAndDropEvent>()); Assert.That (arguments, Is.InstanceOf<DragDropEventData>()); Assert.That (((DragDropEventData) arguments).Names, Is.EquivalentTo (_filePaths)); Assert.That (((DragDropEventData) arguments).ResourceHandles, Is.Not.Empty); wasRaised = true; }; browserStub.Raise (_ => _.DragDrop += null, browserStub, eventArgs); Assert.That (wasRaised, Is.True); }
public int DragEnter(IDataObject pDataObj, uint grfKeyState, tagPOINT pt, ref uint pdwEffect) { _currendDataObject = null; if (pDataObj != null) _currendDataObject = new DataObject (pDataObj); var args = new ExtendedDragEventHandlerArgs ( _currendDataObject, (int) grfKeyState, pt.X, pt.Y, DragDropEffects.All, ToWinForms ((NativeDragDropEffects) pdwEffect)); _extendedTridentWebBrowser.OnDragEnter (args); if (args.Handled) pdwEffect = (uint) ToNative (args.Effect); return HResult.S_OK; }
public void DragDrop_RequiredAttributesNotFound_ShouldNotBeCalled() { var browserStub = MockRepository.GenerateStub<IExtendedWebBrowser>(); _dragAndDropEvent.AddDragDropSource (browserStub); var dataObjectStub = MockRepository.GenerateStub<IDataObject>(); dataObjectStub.Stub (_ => _.GetData (DataFormats.FileDrop)).Return (_filePaths); var eventArgs = new ExtendedDragEventHandlerArgs (dataObjectStub, 0, 1, 1, DragDropEffects.All, DragDropEffects.None, _documentHandle); eventArgs.Current = _nonDroppableElementData; var wasRaised = false; _dragAndDropEvent.DragDrop += (source, name, arguments) => wasRaised = true; browserStub.Raise (_ => _.DragDrop += null, browserStub, eventArgs); Assert.That (wasRaised, Is.False); }
public void OnDragOver (ExtendedDragEventHandlerArgs e) { var element = ElementAt (e.X, e.Y); var document = element != null ? element.Document : Document; if (element != null) e.Current = new HtmlElementData (element.Id, GetRelevantAttributes (element)); e.Document = DocumentIdentifier.GetOrCreateDocumentHandle (document); e.Effect = DragDropEffects.None; if (DragOver != null) DragOver (this, e); if (e.Droppable && e.Effect == DragDropEffects.None) e.Effect = c_defaulEffect; else if (!e.Droppable) e.Effect = DragDropEffects.None; e.Handled = true; }
// when hovering things public void OnDragOver(object sender, ExtendedDragEventHandlerArgs e) { var current = e.Current; if (_elementUnderCursor.Value == null || (current != null && !_elementUnderCursor.Value.Equals (current))) _elementUnderCursor = new KeyValuePair<HtmlDocumentHandle, HtmlElementData> (e.Document, current); e.Droppable = IsDroppable (current); var args = new DragEventData(); args.Names = GetFileNames (e.Data); if (DragOver != null) DragOver (this, c_dragOverEventName, args); var effect = GetMouseEffect (current); if (e.Droppable && effect > 0) e.Effect = (DragDropEffects) effect; }
// when entering the window public void OnDragEnter(object sender, ExtendedDragEventHandlerArgs e) { if (e.Current != null) _enterElement = new KeyValuePair<HtmlDocumentHandle, HtmlElementData> (e.Document, e.Current); _elementUnderCursor = _enterElement; var args = new DragDropEventData(); args.Names = GetFileNames (e.Data); if (DragEnter != null) DragEnter (this, c_dragEnterEventName, args); }
public void OnDragDrop(object sender, ExtendedDragEventHandlerArgs e) { var current = e.Current; e.Droppable = IsDroppable (current); if (DragDrop != null && e.Droppable) { var paths = GetFileNames (e.Data); var resources = paths.Select ( p => (File.GetAttributes (p) & FileAttributes.Directory) == FileAttributes.Directory ? new DirectoryInfo (p) as FileSystemInfo : new FileInfo (p) as FileSystemInfo ).ToArray(); var handles = ResourceManager.AddResources (resources); var args = new DragDropEventData { ResourceHandles = handles.Select (r => r.ToString()).ToArray(), Names = paths }; DragDrop (this, c_dragDropEventName, args); } }