コード例 #1
0
    public void TestConstructor()
    {
        increment = 0;
        IEventTarget eventTarget = (IEventTarget)doc.DocumentElement;

        // Add first event listener
        eventTarget.AddEventListener("mousemove", new EventListener(OnMouseMove), false);
        eventTarget.DispatchEvent(new Event("uievent", "mousemove", true, false));
        Assert.AreEqual(1, increment);

        // Add second event listener
        // "If multiple identical EventListeners are registered on the same EventTarget with the same
        //  parameters the duplicate instances are discarded. They do not cause the EventListener to
        //  be called twice and since they are discarded they do not need to be removed with the removeEventListener method."
        eventTarget.AddEventListener("mousemove", new EventListener(OnMouseMove), false);
        eventTarget.DispatchEvent(new Event("uievent", "mousemove", true, false));
        Assert.AreEqual(2, increment);

        // Remove first event listener
        eventTarget.RemoveEventListener("mousemove", new EventListener(OnMouseMove), false);
        eventTarget.DispatchEvent(new Event("uievent", "mousemove", true, false));
        Assert.AreEqual(2, increment);

        // Remove second event listener
        // "Calling removeEventListener with arguments which do not identify any currently registered EventListener on the EventTarget has no effect."
        eventTarget.RemoveEventListener("mousemove", new EventListener(OnMouseMove), false);
        eventTarget.DispatchEvent(new Event("uievent", "mousemove", true, false));
        Assert.AreEqual(2, increment);
    }
コード例 #2
0
        /// <summary>Collects options from the given gameobject (or any parent in the hierarchy).</summary>
        public ContextEvent collectOptions(GameObject go)
        {
            triggerGameObject = go;

            if (go == null)
            {
                return(null);
            }

            // Create a context event:
            ContextEvent ce = createEvent();

            // Locate it at the gameobject:
            Vector2 pos = rootScreenLocation;

            ce.clientX = pos.x;
            ce.clientY = pos.y;

            trigger = PowerUI.Input.ResolveTarget(go);

            if (trigger != null)
            {
                // Great - dispatch to it (which can change the coords if it wants):
                trigger.dispatchEvent(ce);
            }

            return(ce);
        }
コード例 #3
0
        /// <summary>
        /// Dispatch the event as described in the specification.
        /// http://www.w3.org/TR/DOM-Level-3-Events/
        /// </summary>
        /// <param name="target">The target of the event.</param>
        /// <returns>A boolean if the event has been cancelled.</returns>
        internal Boolean Dispatch(IEventTarget target)
        {
            _flags |= EventFlags.Dispatch;
            _target = target;

            var eventPath = new List <IEventTarget>();

            if (target is Node parent)
            {
                while ((parent = parent.Parent !) != null)
                {
                    eventPath.Add(parent);
                }
            }

            _phase = EventPhase.Capturing;
            DispatchAt(eventPath.Reverse <IEventTarget>());
            _phase = EventPhase.AtTarget;

            if ((_flags & EventFlags.StopPropagation) != EventFlags.StopPropagation)
            {
                CallListeners(target);
            }

            if (_bubbles)
            {
                _phase = EventPhase.Bubbling;
                DispatchAt(eventPath);
            }

            _flags  &= ~EventFlags.Dispatch;
            _phase   = EventPhase.None;
            _current = null !;
            return((_flags & EventFlags.Canceled) == EventFlags.Canceled);
        }
コード例 #4
0
ファイル: EventModel.cs プロジェクト: podlipensky/sharpcanvas
 /// <summary>
 /// This method should be shared between Window and any HTMLElement
 /// </summary>
 /// <param name="eventTarget"></param>
 /// <param name="type"></param>
 /// <param name="listener"></param>
 /// <param name="useCapture"></param>
 public static void addEventListener(IEventTarget eventTarget, Dictionary<string, List<IEventRegistration>> events, string type, ScriptFunction listener, bool useCapture)
 {
     //events always contain event's names without 'on' prefix
     type = NormalizeEventName(type);
     EventRegistration eventRegistration = new EventRegistration((UserControl)eventTarget, type, listener,
                                                                     useCapture ? EventPhases.CAPTURING_PHASE : EventPhases.BUBBLING_PHASE);
     if (!events.ContainsKey(type))
     {
         var eventRegistrations = new List<IEventRegistration>();
         eventRegistrations.Add(eventRegistration);
         events.Add(type, eventRegistrations);
     }
     else
     {
         bool alreadySubscribed = false;
         foreach (IEventRegistration existingRegistration in events[type])
         {
             if(existingRegistration.Listener.ToString() == listener.ToString() &&
                 existingRegistration.Target == eventTarget)
             {
                 alreadySubscribed = true;
                 break;
             }
         }
         if (!alreadySubscribed)
         {
             events[type].Add(eventRegistration);
         }
     }
 }
コード例 #5
0
ファイル: MouseEvent.cs プロジェクト: codebutler/savagesvg
        public MouseEvent(
			string namespaceUri,
			string eventType,
			bool bubbles,
			bool cancelable,
			IAbstractView view,
			long detail,
			long screenX,
			long screenY,
			long clientX,
			long clientY,
			bool ctrlKey,
			bool altKey,
			bool shiftKey,
			bool metaKey,
			ushort button,
			IEventTarget relatedTarget,
			bool altGraphKey)
        {
            InitMouseEventNs(
                namespaceUri, eventType, bubbles, cancelable, view, detail,
                screenX, screenY, clientX, clientY,
                ctrlKey, altKey, shiftKey, metaKey, button,
                relatedTarget, altGraphKey);
        }
コード例 #6
0
        public void InitMouseEventNs(
            string namespaceUri,
            string eventType,
            bool bubbles,
            bool cancelable,
            IAbstractView view,
            long detail,
            long screenX,
            long screenY,
            long clientX,
            long clientY,
            bool ctrlKey,
            bool altKey,
            bool shiftKey,
            bool metaKey,
            ushort button,
            IEventTarget relatedTarget,
            bool altGraphKey)
        {
            InitUiEventNs(
                namespaceUri, eventType, bubbles, cancelable, view, detail);

            this.screenX       = screenX;
            this.screeny       = screeny;
            this.clientX       = clientX;
            this.clientY       = clientY;
            this.crtlKey       = crtlKey;
            this.shiftKey      = shiftKey;
            this.altKey        = altKey;
            this.metaKey       = metaKey;
            this.button        = button;
            this.relatedTarget = relatedTarget;
            this.altGraphKey   = altGraphKey;
        }
コード例 #7
0
ファイル: MouseEvent.cs プロジェクト: zellus/SharpVectors
 public MouseEvent(string eventType, bool bubbles, bool cancelable, IAbstractView view,
                   long detail, long screenX, long screenY, long clientX, long clientY, bool ctrlKey,
                   bool altKey, bool shiftKey, bool metaKey, ushort button, IEventTarget relatedTarget)
 {
     InitMouseEvent(eventType, bubbles, cancelable, view, detail, screenX, screenY,
                    clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);
 }
コード例 #8
0
ファイル: CharacterManager.cs プロジェクト: kaerber/kmud
 public static Character Create(Character template, IEventTarget specialization)
 {
     return(new Character(template)
     {
         Class = specialization
     });
 }
コード例 #9
0
 public MouseEvent(
     EventType eventType,
     bool bubbles,
     bool cancelable,
     IAbstractView view,
     long detail,
     long screenX,
     long screenY,
     long clientX,
     long clientY,
     bool ctrlKey,
     bool altKey,
     bool shiftKey,
     bool metaKey,
     ushort button,
     IEventTarget relatedTarget,
     bool altGraphKey)
 {
     InitMouseEventNs(
         eventType.NamespaceUri, eventType.Name,
         bubbles, cancelable, view, detail,
         screenX, screenY, clientX, clientY,
         ctrlKey, altKey, shiftKey, metaKey, button,
         relatedTarget, altGraphKey);
 }
コード例 #10
0
ファイル: Event.cs プロジェクト: podlipensky/sharpcanvas
 public Event(string type, IEventTarget target, EventArgs args, bool bubbles, bool cancelable)
 {
     _type = type;
     _target = target;
     _bubbles = bubbles;
     _cancelable = cancelable;
     _args = args;
 }
コード例 #11
0
 private static void AddUnsubscribeFromSourceHandler(IEventSource source, IEventTarget target)
 {
     source.End += () =>
     {
         source.Send -= target.ProcessMessage;
         target.EndProcessing();
     };
 }
コード例 #12
0
 public static Event CreateEvent(string type, IEventTarget target, EventArgs args, bool bubbles, bool cancelable)
 {
     if(args is MouseEventArgs)
     {
         return new MouseEvent(type, target, args, bubbles, cancelable);
     }
     return new Event(type, target, args, bubbles, cancelable);
 }
コード例 #13
0
        /// <summary>
        /// Firing a simple event named e means that a trusted event with a
        /// name, which does not bubble, is not cancelable and which uses the
        /// Event interface. It is created and dispatched at the given target.
        /// </summary>
        /// <param name="target">The target of the simple event.</param>
        /// <param name="eventName">The name of the event to be fired.</param>
        /// <param name="bubble">Optional parameter to enable bubbling.</param>
        /// <param name="cancelable">Should it be cancelable?</param>
        /// <returns>
        /// True if the element was cancelled, otherwise false.
        /// </returns>
        public static Boolean FireSimpleEvent(this IEventTarget target, String eventName, Boolean bubble = false, Boolean cancelable = false)
        {
            var ev = new Event {
                IsTrusted = true
            };

            ev.Init(eventName, bubble, cancelable);
            return(ev.Dispatch(target));
        }
コード例 #14
0
        /// <summary>
        /// Firing an event means dispatching the initialized (and trusted)
        /// event at the specified event target.
        /// </summary>
        /// <param name="target">
        /// The target, where the event has been invoked.
        /// </param>
        /// <param name="initializer">The used initializer.</param>
        /// <param name="targetOverride">
        /// The current event target, if different to the invoked target.
        /// </param>
        /// <returns>
        /// True if the element was cancelled, otherwise false.
        /// </returns>
        public static Boolean Fire <T>(this IEventTarget target, Action <T> initializer, EventTarget targetOverride = null)
            where T : Event, new()
        {
            var ev = new T {
                IsTrusted = true
            };

            initializer(ev);
            return(ev.Dispatch(targetOverride ?? target));
        }
コード例 #15
0
        public void EventHandler(
            IEvent @event)
        {
            IEventTarget target = @event.CurrentTarget;

            events.Add(@event);

            foreach (ListenerRemover listener in listeners)
            {
                target.RemoveEventListener("foo", new EventListener(listener.EventHandler), false);
            }
        }
コード例 #16
0
        public void Init(String type, Boolean bubbles, Boolean cancelable)
        {
            _flags |= EventFlags.Initialized;

            if (!_flags.HasFlag(EventFlags.Dispatch))
            {
                _flags     &= ~(EventFlags.StopPropagation | EventFlags.StopImmediatePropagation | EventFlags.Canceled);
                IsTrusted   = false;
                _target     = null;
                _type       = type;
                _bubbles    = bubbles;
                _cancelable = cancelable;
            }
        }
コード例 #17
0
ファイル: MouseEvent.cs プロジェクト: asmboom/HtmlRenderer
 public void Init(String type, Boolean bubbles, Boolean cancelable, IWindow view, Int32 detail, Int32 screenX, Int32 screenY, Int32 clientX, Int32 clientY, Boolean ctrlKey, Boolean altKey, Boolean shiftKey, Boolean metaKey, MouseButton button, IEventTarget target)
 {
     Init(type, bubbles, cancelable, view, detail);
     ScreenX        = screenX;
     ScreenY        = screenY;
     ClientX        = clientX;
     ClientY        = clientY;
     IsCtrlPressed  = ctrlKey;
     IsMetaPressed  = metaKey;
     IsShiftPressed = shiftKey;
     IsAltPressed   = altKey;
     Button         = button;
     Target         = target;
 }
コード例 #18
0
ファイル: MouseEvent.cs プロジェクト: podlipensky/sharpcanvas
 public MouseEvent(string type, IEventTarget target, EventArgs e, bool bubbles, bool cancelable)
     : base(type, target, e, bubbles, cancelable)
 {
     int x = Cursor.Position.X;
     int y = Cursor.Position.Y;
     if (e is MouseEventArgs)
     {
         x = (e as MouseEventArgs).X;
         y = (e as MouseEventArgs).Y;
     }
     pageX = x;
     pageY = y;
     if (e is KeyEventArgs)
     {
         keyCode = (int)((KeyEventArgs)e).KeyCode;
     }
 }
コード例 #19
0
        public bool WillTriggerNs(string namespaceUri, string type)
        {
            XmlNode     node      = (XmlNode)this.eventTarget;
            XmlNodeList ancestors = node.SelectNodes("ancestor::node()");

            for (int i = 0; i < ancestors.Count; i++)
            {
                IEventTarget ancestor = ancestors[i] as IEventTarget;

                if (ancestor.HasEventListenerNs(namespaceUri, type))
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #20
0
ファイル: MouseEvent.cs プロジェクト: zellus/SharpVectors
        public void InitMouseEvent(string eventType, bool bubbles, bool cancelable, IAbstractView view,
                                   long detail, long screenX, long screenY, long clientX, long clientY, bool ctrlKey,
                                   bool altKey, bool shiftKey, bool metaKey, ushort button, IEventTarget relatedTarget)
        {
            InitUiEvent(eventType, bubbles, cancelable, view, detail);

            _screenX       = screenX;
            _screeny       = screenY;
            _clientX       = clientX;
            _clientY       = clientY;
            _crtlKey       = ctrlKey;
            _shiftKey      = shiftKey;
            _altKey        = altKey;
            _metaKey       = metaKey;
            _button        = button;
            _relatedTarget = relatedTarget;
        }
コード例 #21
0
ファイル: Input.cs プロジェクト: labiel1/DreamHouse_Gaminp
		/// <summary>Attempts to resolve a Gameobject to an event target. Prefers to use Input.TargetResolver but falls back searching for 
		/// a script on the gameobject which implements it. Will search up the hierarchy too.</summary>
		public static IEventTarget ResolveTarget(GameObject toResolve){
			
			// Got a target resolver?
			IEventTarget result=null;
			
			if(TargetResolver!=null){
				
				// Great - try resolving now:
				bool cancelEvent;
				result=TargetResolver(toResolve,out cancelEvent);
				
				if(cancelEvent || result!=null){
					return result;
				}
				
			}
			
			// Look for a MonoBehaviour on the GameObject which implements IEventTarget instead:
			while(toResolve!=null){
				
				// Try getting it:
				result=toResolve.GetComponent<IEventTarget>();
				
				if(result!=null){
					break;
				}
				
				// Try the parent:
				Transform parent=toResolve.transform.parent;
				
				if(parent==null){
					break;
				}
				
				// Next in the hierarchy:
				toResolve=parent.gameObject;
				
			}
			
			return result;
			
		}
コード例 #22
0
        /// <summary>Collects options at the given pointer location.</summary>
        public ContextEvent collectOptions(InputPointer ip)
        {
            // Create an oncontextmenu event:
            ContextEvent ce = createEvent();

            ce.trigger = ip;
            ce.clientX = ip.DocumentX;
            ce.clientY = ip.DocumentY;

            // Collect from a 2D element:
            trigger = ip.ActiveOverTarget;

            if (trigger != null)
            {
                // Collect:
                trigger.dispatchEvent(ce);
                return(ce);
            }

            return(ce);
        }
コード例 #23
0
        /// <summary>
        /// Retargets <paramref name="A"/> against object <paramref name="B"/>
        /// </summary>
        /// <param name="A"></param>
        /// <param name="B"></param>
        /// <returns></returns>
        internal static EventTarget retarget_event(IEventTarget A, IEventTarget B)
        {/* Docs: https://dom.spec.whatwg.org/#retarget */
            while (A is object)
            {
                if (!(A is Node))
                {
                    return((EventTarget)A);
                }
                if (A is Node nA && nA.getRootNode() is ShadowRoot)
                {
                    return((EventTarget)A);
                }
                if (B is Node nB && DOMCommon.Is_Shadow_Including_Inclusive_Ancestor(((Node)A).getRootNode(), (Node)B))
                {
                    return((EventTarget)A);
                }

                A = (((Node)A).getRootNode() as DocumentFragment).Host;
            }

            return(null);
        }
コード例 #24
0
        /// <summary>Collects options at the given pointer location.</summary>
        public ContextEvent collectOptions(InputPointer ip)
        {
            // Create an oncontextmenu event:
            ContextEvent ce = createEvent();

            ce.trigger = ip;
            ce.clientX = ip.DocumentX;
            ce.clientY = ip.DocumentY;

            // Collect from a 2D element:
            triggerElement = ip.ActiveOver;
            trigger        = triggerElement;

            if (trigger != null)
            {
                // Collect:
                trigger.dispatchEvent(ce);

                triggerGameObject = null;
                return(ce);
            }

            // Collect from a 3D object:
            if (ip.LatestHitSuccess)
            {
                // Try to resolve the hit gameobject to an IEventTarget:
                triggerGameObject = ip.LatestHit.transform.gameObject;
                trigger           = ip.ResolveTarget();

                if (trigger != null)
                {
                    // Great - dispatch to it:
                    trigger.dispatchEvent(ce);
                }
            }

            return(ce);
        }
コード例 #25
0
        /// <summary>Collects options from the given HTML element.</summary>
        public ContextEvent collectOptions(Element e)
        {
            trigger = e;

            if (e == null)
            {
                return(null);
            }

            // Create a context event:
            ContextEvent ce = createEvent();

            // Locate it at the element:
            Vector2 pos = rootScreenLocation;

            ce.clientX = pos.x;
            ce.clientY = pos.y;

            // Collect:
            e.dispatchEvent(ce);

            return(ce);
        }
コード例 #26
0
ファイル: Event.cs プロジェクト: h82258652/AngleSharp
        internal Boolean Dispatch(EventTarget target)
        {
            _flags |= EventFlags.Dispatch;
            _target = target;

            var eventPath = new List <EventTarget>();
            var parent    = target as Node;

            if (parent != null)
            {
                while ((parent = parent.Parent) != null)
                {
                    eventPath.Add(parent);
                }
            }

            _phase = EventPhase.Capturing;
            DispatchAt(eventPath.Reverse <EventTarget>());
            _phase = EventPhase.AtTarget;

            if (!_flags.HasFlag(EventFlags.StopPropagation))
            {
                CallListeners(target);
            }

            if (_bubbles)
            {
                _phase = EventPhase.Bubbling;
                DispatchAt(eventPath);
            }

            _flags  &= ~EventFlags.Dispatch;
            _phase   = EventPhase.None;
            _current = null;
            return(!_flags.HasFlag(EventFlags.Canceled));
        }
コード例 #27
0
ファイル: MouseEvent.cs プロジェクト: JackieyLi/AngleSharp
 /// <summary>
 /// Creates a new event and initializes it.
 /// </summary>
 /// <param name="type">The type of the event.</param>
 /// <param name="bubbles">If the event is bubbling.</param>
 /// <param name="cancelable">If the event is cancelable.</param>
 /// <param name="view">Sets the associated view for the UI event.</param>
 /// <param name="detail">Sets the detail id for the UI event.</param>
 /// <param name="screenX">Sets the screen X coordinate.</param>
 /// <param name="screenY">Sets the screen Y coordinate.</param>
 /// <param name="clientX">Sets the client X coordinate.</param>
 /// <param name="clientY">Sets the client Y coordinate.</param>
 /// <param name="ctrlKey">Sets if the control key was pressed.</param>
 /// <param name="altKey">Sets if the alt key was pressed.</param>
 /// <param name="shiftKey">Sets if the shift key was pressed.</param>
 /// <param name="metaKey">Sets if the meta key was pressed.</param>
 /// <param name="button">Sets which button has been pressed.</param>
 /// <param name="target">The target of the mouse event.</param>
 public MouseEvent(String type, Boolean bubbles, Boolean cancelable, IWindow view, Int32 detail, Int32 screenX, Int32 screenY, Int32 clientX, Int32 clientY, Boolean ctrlKey, Boolean altKey, Boolean shiftKey, Boolean metaKey, MouseButton button, IEventTarget target)
 {
     Init(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, target);
 }
コード例 #28
0
ファイル: MouseEvent.cs プロジェクト: JackieyLi/AngleSharp
 public void Init(String type, Boolean bubbles, Boolean cancelable, IWindow view, Int32 detail, Int32 screenX, Int32 screenY, Int32 clientX, Int32 clientY, Boolean ctrlKey, Boolean altKey, Boolean shiftKey, Boolean metaKey, MouseButton button, IEventTarget target)
 {
     Init(type, bubbles, cancelable, view, detail);
     ScreenX = screenX;
     ScreenY = screenY;
     ClientX = clientX;
     ClientY = clientY;
     IsCtrlPressed = ctrlKey;
     IsMetaPressed = metaKey;
     IsShiftPressed = shiftKey;
     IsAltPressed = altKey;
     Button = button;
     Target = target;
 }
コード例 #29
0
ファイル: Event.cs プロジェクト: Wojdav/AngleSharp
 void CallListeners(IEventTarget target)
 {
     _current = target;
     target.InvokeEventListener(this);
 }
コード例 #30
0
ファイル: Event.cs プロジェクト: Wojdav/AngleSharp
        /// <summary>
        /// Dispatch the event as described in the specification.
        /// http://www.w3.org/TR/DOM-Level-3-Events/
        /// </summary>
        /// <param name="target">The target of the event.</param>
        /// <returns>A boolean if the event has been cancelled.</returns>
        internal Boolean Dispatch(IEventTarget target)
        {
            _flags |= EventFlags.Dispatch;
            _target = target;

            var eventPath = new List<IEventTarget>();
            var parent = target as Node;

            if (parent != null)
            {
                while ((parent = parent.Parent) != null)
                {
                    eventPath.Add(parent);
                }
            }

            _phase = EventPhase.Capturing;
            DispatchAt(eventPath.Reverse<IEventTarget>());
            _phase = EventPhase.AtTarget;

            if ((_flags & EventFlags.StopPropagation) != EventFlags.StopPropagation)
            {
                CallListeners(target);
            }

            if (_bubbles)
            {
                _phase = EventPhase.Bubbling;
                DispatchAt(eventPath);
            }

            _flags &= ~EventFlags.Dispatch;
            _phase = EventPhase.None;
            _current = null;
            return (_flags & EventFlags.Canceled) == EventFlags.Canceled;
        }
コード例 #31
0
ファイル: Event.cs プロジェクト: Wojdav/AngleSharp
        public void Init(String type, Boolean bubbles, Boolean cancelable)
        {
            _flags |= EventFlags.Initialized;

            if ((_flags & EventFlags.Dispatch) != EventFlags.Dispatch)
            {
                _flags &= ~(EventFlags.StopPropagation | EventFlags.StopImmediatePropagation | EventFlags.Canceled);
                IsTrusted = false;
                _target = null;
                _type = type;
                _bubbles = bubbles;
                _cancelable = cancelable;
            }
        }
コード例 #32
0
ファイル: FocusEvent.cs プロジェクト: JackieyLi/AngleSharp
 public void Init(String type, Boolean bubbles, Boolean cancelable, IWindow view, Int32 detail, IEventTarget target)
 {
     Init(type, bubbles, cancelable, view, detail);
     Target = target;
 }
コード例 #33
0
 /// <summary>
 /// Creates a new event and initializes it.
 /// </summary>
 /// <param name="type">The type of the event.</param>
 /// <param name="bubbles">If the event is bubbling.</param>
 /// <param name="cancelable">If the event is cancelable.</param>
 /// <param name="view">Sets the associated view for the UI event.</param>
 /// <param name="detail">Sets the detail id for the UI event.</param>
 /// <param name="screenX">Sets the screen X coordinate.</param>
 /// <param name="screenY">Sets the screen Y coordinate.</param>
 /// <param name="clientX">Sets the client X coordinate.</param>
 /// <param name="clientY">Sets the client Y coordinate.</param>
 /// <param name="button">Sets which button has been pressed.</param>
 /// <param name="target">The target of the mouse event.</param>
 /// <param name="modifiersList">A list with keyboard modifiers that have been pressed.</param>
 /// <param name="deltaX">The mouse wheel delta in X direction.</param>
 /// <param name="deltaY">The mouse wheel delta in Y direction.</param>
 /// <param name="deltaZ">The mouse wheel delta in Z direction.</param>
 /// <param name="deltaMode">The delta mode for the wheel event.</param>
 public WheelEvent(String type, Boolean bubbles, Boolean cancelable, IWindow view, Int32 detail, Int32 screenX, Int32 screenY, Int32 clientX, Int32 clientY, MouseButton button, IEventTarget target, String modifiersList, Double deltaX, Double deltaY, Double deltaZ, WheelMode deltaMode)
 {
     Init(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY, button, target, modifiersList, deltaX, deltaY, deltaZ, deltaMode);
 }
コード例 #34
0
ファイル: MouseEvent.cs プロジェクト: asmboom/HtmlRenderer
 /// <summary>
 /// Creates a new event and initializes it.
 /// </summary>
 /// <param name="type">The type of the event.</param>
 /// <param name="bubbles">If the event is bubbling.</param>
 /// <param name="cancelable">If the event is cancelable.</param>
 /// <param name="view">Sets the associated view for the UI event.</param>
 /// <param name="detail">Sets the detail id for the UI event.</param>
 /// <param name="screenX">Sets the screen X coordinate.</param>
 /// <param name="screenY">Sets the screen Y coordinate.</param>
 /// <param name="clientX">Sets the client X coordinate.</param>
 /// <param name="clientY">Sets the client Y coordinate.</param>
 /// <param name="ctrlKey">Sets if the control key was pressed.</param>
 /// <param name="altKey">Sets if the alt key was pressed.</param>
 /// <param name="shiftKey">Sets if the shift key was pressed.</param>
 /// <param name="metaKey">Sets if the meta key was pressed.</param>
 /// <param name="button">Sets which button has been pressed.</param>
 /// <param name="target">The target of the mouse event.</param>
 public MouseEvent(String type, Boolean bubbles, Boolean cancelable, IWindow view, Int32 detail, Int32 screenX, Int32 screenY, Int32 clientX, Int32 clientY, Boolean ctrlKey, Boolean altKey, Boolean shiftKey, Boolean metaKey, MouseButton button, IEventTarget target)
 {
     Init(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, target);
 }
コード例 #35
0
ファイル: Event.cs プロジェクト: neelendu/AngleSharp
 void CallListeners(EventTarget target)
 {
     _current = target;
     target.CallEventListener(this);
 }
コード例 #36
0
        /// <summary>
        /// Processes mouse events.
        /// </summary>
        /// <param name="type">
        /// A string describing the type of mouse event that occured.
        /// </param>
        /// <param name="e">
        /// The <see cref="MouseEventArgs">MouseEventArgs</see> that contains
        /// the event data.
        /// </param>
        public void OnMouseEvent(string type, MouseEventArgs e)
        {
            if (idMapRaster != null)
            {
                try
                {
                    Color      pixel     = idMapRaster.GetPixel(e.X, e.Y);
                    SvgElement grElement = GetElementFromColor(pixel);
                    if (grElement != null)
                    {
                        IEventTarget target;
                        if (grElement.ElementInstance != null)
                        {
                            target = grElement.ElementInstance as IEventTarget;
                        }
                        else
                        {
                            target = grElement as IEventTarget;
                        }

                        if (target != null)
                        {
                            switch (type)
                            {
                            case "mousemove":
                            {
                                if (currentTarget == target)
                                {
                                    target.DispatchEvent(new MouseEvent(
                                                             EventType.MouseMove, true, false,
                                                             null, // todo: put view here
                                                             0,    // todo: put detail here
                                                             e.X, e.Y, e.X, e.Y,
                                                             false, false, false, false,
                                                             0, null, false));
                                }
                                else
                                {
                                    if (currentTarget != null)
                                    {
                                        currentTarget.DispatchEvent(new MouseEvent(
                                                                        EventType.MouseOut, true, false,
                                                                        null, // todo: put view here
                                                                        0,    // todo: put detail here
                                                                        e.X, e.Y, e.X, e.Y,
                                                                        false, false, false, false,
                                                                        0, null, false));
                                    }

                                    target.DispatchEvent(new MouseEvent(
                                                             EventType.MouseOver, true, false,
                                                             null, // todo: put view here
                                                             0,    // todo: put detail here
                                                             e.X, e.Y, e.X, e.Y,
                                                             false, false, false, false,
                                                             0, null, false));
                                }
                                break;
                            }

                            case "mousedown":
                                target.DispatchEvent(new MouseEvent(
                                                         EventType.MouseDown, true, false,
                                                         null, // todo: put view here
                                                         0,    // todo: put detail here
                                                         e.X, e.Y, e.X, e.Y,
                                                         false, false, false, false,
                                                         0, null, false));
                                currentDownTarget = target;
                                currentDownX      = e.X;
                                currentDownY      = e.Y;
                                break;

                            case "mouseup":
                                target.DispatchEvent(new MouseEvent(
                                                         EventType.MouseUp, true, false,
                                                         null, // todo: put view here
                                                         0,    // todo: put detail here
                                                         e.X, e.Y, e.X, e.Y,
                                                         false, false, false, false,
                                                         0, null, false));
                                if (/*currentDownTarget == target &&*/ Math.Abs(currentDownX - e.X) < 5 && Math.Abs(currentDownY - e.Y) < 5)
                                {
                                    target.DispatchEvent(new MouseEvent(
                                                             EventType.Click, true, false,
                                                             null, // todo: put view here
                                                             0,    // todo: put detail here
                                                             e.X, e.Y, e.X, e.Y,
                                                             false, false, false, false,
                                                             0, null, false));
                                }
                                currentDownTarget = null;
                                currentDownX      = 0;
                                currentDownY      = 0;
                                break;
                            }
                            currentTarget = target;
                        }
                        else
                        {
                            // jr patch
                            if (currentTarget != null && type == "mousemove")
                            {
                                currentTarget.DispatchEvent(new MouseEvent(
                                                                EventType.MouseOut, true, false,
                                                                null, // todo: put view here
                                                                0,    // todo: put detail here
                                                                e.X, e.Y, e.X, e.Y,
                                                                false, false, false, false,
                                                                0, null, false));
                            }
                            currentTarget = null;
                        }
                    }
                    else
                    {
                        // jr patch
                        if (currentTarget != null && type == "mousemove")
                        {
                            currentTarget.DispatchEvent(new MouseEvent(
                                                            EventType.MouseOut, true, false,
                                                            null, // todo: put view here
                                                            0,    // todo: put detail here
                                                            e.X, e.Y, e.X, e.Y,
                                                            false, false, false, false,
                                                            0, null, false));
                        }
                        currentTarget = null;
                    }
                }
                catch
                {
                }
            }
        }
コード例 #37
0
ファイル: WheelEvent.cs プロジェクト: JackieyLi/AngleSharp
 public void Init(String type, Boolean bubbles, Boolean cancelable, IWindow view, Int32 detail, Int32 screenX, Int32 screenY, Int32 clientX, Int32 clientY, MouseButton button, IEventTarget target, String modifiersList, Double deltaX, Double deltaY, Double deltaZ, WheelMode deltaMode)
 {
     Init(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY, 
         modifiersList.IsCtrlPressed(), modifiersList.IsAltPressed(), modifiersList.IsShiftPressed(), modifiersList.IsMetaPressed(), button, target);
     DeltaX = deltaX;
     DeltaY = deltaY;
     DeltaZ = deltaZ;
     DeltaMode = deltaMode;
 }
コード例 #38
0
        /// <summary>
        /// Processes mouse events.
        /// </summary>
        /// <param name="type">
        /// A string describing the type of mouse event that occured.
        /// </param>
        /// <param name="e">
        /// The <see cref="MouseEventArgs">MouseEventArgs</see> that contains
        /// the event data.
        /// </param>
        public void OnMouseEvent(string type, MouseEventArgs e)
        {
            if (idMapRaster != null)
            {
                try
                {
                    Color pixel = idMapRaster.GetPixel(e.X, e.Y);
                    SvgElement grElement = GetElementFromColor(pixel);
                    if (grElement != null)
                    {
                        IEventTarget target;
                        if (grElement.ElementInstance != null)
                            target = grElement.ElementInstance as IEventTarget;
                        else
                            target = grElement as IEventTarget;

                        if (target != null)
                        {
                            switch (type)
                            {
                                case "mousemove":
                                    {
                                        if (currentTarget == target)
                                        {
                                            target.DispatchEvent(new MouseEvent(
                                                EventType.MouseMove, true, false,
                                                null, // todo: put view here
                                                0, // todo: put detail here
                                                e.X, e.Y, e.X, e.Y,
                                                false, false, false, false,
                                                0, null, false));
                                        }
                                        else
                                        {
                                            if (currentTarget != null)
                                            {
                                                currentTarget.DispatchEvent(new MouseEvent(
                                                    EventType.MouseOut, true, false,
                                                    null, // todo: put view here
                                                    0, // todo: put detail here
                                                    e.X, e.Y, e.X, e.Y,
                                                    false, false, false, false,
                                                    0, null, false));
                                            }

                                            target.DispatchEvent(new MouseEvent(
                                                EventType.MouseOver, true, false,
                                                null, // todo: put view here
                                                0, // todo: put detail here
                                                e.X, e.Y, e.X, e.Y,
                                                false, false, false, false,
                                                0, null, false));
                                        }
                                        break;
                                    }
                                case "mousedown":
                                    target.DispatchEvent(new MouseEvent(
                                        EventType.MouseDown, true, false,
                                        null, // todo: put view here
                                        0, // todo: put detail here
                                        e.X, e.Y, e.X, e.Y,
                                        false, false, false, false,
                                        0, null, false));
                                    currentDownTarget = target;
                                    currentDownX = e.X;
                                    currentDownY = e.Y;
                                    break;
                                case "mouseup":
                                    target.DispatchEvent(new MouseEvent(
                                        EventType.MouseUp, true, false,
                                        null, // todo: put view here
                                        0, // todo: put detail here
                                        e.X, e.Y, e.X, e.Y,
                                        false, false, false, false,
                                        0, null, false));
                                    if (/*currentDownTarget == target &&*/ Math.Abs(currentDownX - e.X) < 5 && Math.Abs(currentDownY - e.Y) < 5)
                                    {
                                        target.DispatchEvent(new MouseEvent(
                                          EventType.Click, true, false,
                                          null, // todo: put view here
                                          0, // todo: put detail here
                                          e.X, e.Y, e.X, e.Y,
                                          false, false, false, false,
                                          0, null, false));
                                    }
                                    currentDownTarget = null;
                                    currentDownX = 0;
                                    currentDownY = 0;
                                    break;
                            }
                            currentTarget = target;
                        }
                        else
                        {

                            // jr patch
                            if (currentTarget != null && type == "mousemove")
                            {
                                currentTarget.DispatchEvent(new MouseEvent(
                                  EventType.MouseOut, true, false,
                                  null, // todo: put view here
                                  0, // todo: put detail here
                                  e.X, e.Y, e.X, e.Y,
                                  false, false, false, false,
                                  0, null, false));
                            }
                            currentTarget = null;
                        }
                    }
                    else
                    {
                        // jr patch
                        if (currentTarget != null && type == "mousemove")
                        {
                            currentTarget.DispatchEvent(new MouseEvent(
                              EventType.MouseOut, true, false,
                              null, // todo: put view here
                              0, // todo: put detail here
                              e.X, e.Y, e.X, e.Y,
                              false, false, false, false,
                              0, null, false));
                        }
                        currentTarget = null;
                    }
                }
                catch
                {
                }
            }
        }
コード例 #39
0
ファイル: WheelEvent.cs プロジェクト: fjwuyongzhi/AngleSharp
 public WheelEvent(String type, Boolean bubbles = false, Boolean cancelable = false, IWindow view = null, Int32 detail = 0, Int32 screenX = 0, Int32 screenY = 0, Int32 clientX = 0, Int32 clientY = 0, MouseButton button = MouseButton.Primary, IEventTarget target = null, String modifiersList = null, Double deltaX = 0.0, Double deltaY = 0.0, Double deltaZ = 0.0, WheelMode deltaMode = WheelMode.Pixel)
 {
     Init(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY, button, target, modifiersList ?? String.Empty, deltaX, deltaY, deltaZ, deltaMode);
 }
コード例 #40
0
ファイル: EventModel.cs プロジェクト: podlipensky/sharpcanvas
 public static void removeEventListener(IEventTarget eventTarget, string type, ScriptFunction listener, bool useCapture)
 {
     //events always contain event's names without 'on' prefix
     type = NormalizeEventName(type);
     Dictionary<string, List<IEventRegistration>> events = eventTarget.GetEventsCollection();
     EventPhases phase = useCapture ? EventPhases.CAPTURING_PHASE : EventPhases.BUBBLING_PHASE;
     if (events.ContainsKey(type))
     {
         IEventRegistration toRemove = null;
         foreach (IEventRegistration eventRegistration in events[type])
         {
           if(eventRegistration.ApplyToPhase == phase)
           {
               toRemove = eventRegistration;
               break;
           }
         }
         if(toRemove != null)
         {
             events[type].Remove(toRemove);
         }
     }
 }
コード例 #41
0
 /// <summary>
 /// Adds listener to<see cref="IEventSource"/> Send event and returns the listener.
 /// </summary>
 /// <param name="source">Source to which add the listener.</param>
 /// <param name="target">Target to which link the source. This is returned after linking.</param>
 /// <returns>The target of linking.</returns>
 public static IEventTarget LinkTo(this IEventSource source, IEventTarget target)
 {
     source.Send += target.ProcessMessage;
     AddUnsubscribeFromSourceHandler(source, target);
     return target;
 }
コード例 #42
0
ファイル: UIEvent.cs プロジェクト: podlipensky/sharpcanvas
 public UIEvent(string type, IEventTarget target, EventArgs args, bool bubbles, bool cancelable)
     : base(type, target, args, bubbles, cancelable)
 {
 }
コード例 #43
0
        private void ProcessMouseEvents(string type, MouseEventArgs e)
        {
            //Color pixel = _idMapRaster.GetPixel(e.X, e.Y);
            //SvgElement svgElement = GetElementFromColor(pixel);

            SvgElement svgElement    = null;
            var        hitTestResult = _hitTestHelper.HitTest(e.X, e.Y);

            if (hitTestResult != null)
            {
                svgElement = hitTestResult.Element;
            }

            if (type == "mouseup")
            {
                type = type.Trim();
            }

            if (svgElement == null)
            {
                // jr patch
                if (_currentTarget != null && type == "mousemove")
                {
                    _currentTarget.DispatchEvent(new MouseEvent(EventType.MouseOut, true, false,
                                                                null, // todo: put view here
                                                                0,    // todo: put detail here
                                                                e.X, e.Y, e.X, e.Y,
                                                                false, false, false, false,
                                                                0, null, false));
                }
                _currentTarget = null;
                return;
            }

            IEventTarget target;

            if (svgElement.ElementInstance != null)
            {
                target = svgElement.ElementInstance as IEventTarget;
            }
            else
            {
                target = svgElement as IEventTarget;
            }

            if (target == null)
            {
                // jr patch
                if (_currentTarget != null && type == "mousemove")
                {
                    _currentTarget.DispatchEvent(new MouseEvent(EventType.MouseOut, true, false,
                                                                null, // todo: put view here
                                                                0,    // todo: put detail here
                                                                e.X, e.Y, e.X, e.Y,
                                                                false, false, false, false,
                                                                0, null, false));
                }
                _currentTarget = null;
                return;
            }

            switch (type)
            {
            case "mousemove":
            {
                if (_currentTarget == target)
                {
                    target.DispatchEvent(new MouseEvent(EventType.MouseMove, true, false,
                                                        null, // todo: put view here
                                                        0,    // todo: put detail here
                                                        e.X, e.Y, e.X, e.Y,
                                                        false, false, false, false,
                                                        0, null, false));
                }
                else
                {
                    if (_currentTarget != null)
                    {
                        _currentTarget.DispatchEvent(new MouseEvent(EventType.MouseOut, true, false,
                                                                    null, // todo: put view here
                                                                    0,    // todo: put detail here
                                                                    e.X, e.Y, e.X, e.Y,
                                                                    false, false, false, false,
                                                                    0, null, false));
                    }

                    target.DispatchEvent(new MouseEvent(EventType.MouseOver, true, false,
                                                        null, // todo: put view here
                                                        0,    // todo: put detail here
                                                        e.X, e.Y, e.X, e.Y,
                                                        false, false, false, false,
                                                        0, null, false));
                }
                break;
            }

            case "mousedown":
                target.DispatchEvent(new MouseEvent(EventType.MouseDown, true, false,
                                                    null, // todo: put view here
                                                    0,    // todo: put detail here
                                                    e.X, e.Y, e.X, e.Y,
                                                    false, false, false, false,
                                                    0, null, false));
                _currentDownTarget = target;
                _currentDownX      = e.X;
                _currentDownY      = e.Y;
                break;

            case "mouseup":
                target.DispatchEvent(new MouseEvent(EventType.MouseUp, true, false,
                                                    null, // todo: put view here
                                                    0,    // todo: put detail here
                                                    e.X, e.Y, e.X, e.Y,
                                                    false, false, false, false,
                                                    0, null, false));
                if (Math.Abs(_currentDownX - e.X) < 5 && Math.Abs(_currentDownY - e.Y) < 5)
                {
                    target.DispatchEvent(new MouseEvent(EventType.Click, true, false,
                                                        null, // todo: put view here
                                                        0,    // todo: put detail here
                                                        e.X, e.Y, e.X, e.Y,
                                                        false, false, false, false,
                                                        0, null, false));
                }
                _currentDownTarget = null;
                _currentDownX      = 0;
                _currentDownY      = 0;
                break;
            }
            _currentTarget = target;
        }
コード例 #44
0
 public void Init(String type, Boolean bubbles, Boolean cancelable, IWindow view, Int32 detail, Int32 screenX, Int32 screenY, Int32 clientX, Int32 clientY, MouseButton button, IEventTarget target, String modifiersList, Double deltaX, Double deltaY, Double deltaZ, WheelMode deltaMode)
 {
     Init(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY,
          modifiersList.IsCtrlPressed(), modifiersList.IsAltPressed(), modifiersList.IsShiftPressed(), modifiersList.IsMetaPressed(), button, target);
     DeltaX    = deltaX;
     DeltaY    = deltaY;
     DeltaZ    = deltaZ;
     DeltaMode = deltaMode;
 }
コード例 #45
0
ファイル: Event.cs プロジェクト: fjwuyongzhi/AngleSharp
 void CallListeners(EventTarget target)
 {
     _current = target;
     target.CallEventListener(this);
 }
コード例 #46
0
ファイル: MouseEvent.cs プロジェクト: codebutler/savagesvg
        public void InitMouseEventNs(
			string namespaceUri,
			string eventType,
			bool bubbles,
			bool cancelable,
			IAbstractView view,
			long detail,
			long screenX,
			long screenY,
			long clientX,
			long clientY,
			bool ctrlKey,
			bool altKey,
			bool shiftKey,
			bool metaKey,
			ushort button,
			IEventTarget relatedTarget,
			bool altGraphKey)
        {
            InitUiEventNs(
                namespaceUri, eventType, bubbles, cancelable, view, detail);

            this.screenX = screenX;
            this.screeny = screeny;
            this.clientX = clientX;
            this.clientY = clientY;
            this.crtlKey = crtlKey;
            this.shiftKey = shiftKey;
            this.altKey = altKey;
            this.metaKey = metaKey;
            this.button = button;
            this.relatedTarget = relatedTarget;
            this.altGraphKey = altGraphKey;
        }
コード例 #47
0
ファイル: FocusEvent.cs プロジェクト: JackieyLi/AngleSharp
 /// <summary>
 /// Creates a new event and initializes it.
 /// </summary>
 /// <param name="type">The type of the event.</param>
 /// <param name="bubbles">If the event is bubbling.</param>
 /// <param name="cancelable">If the event is cancelable.</param>
 /// <param name="view">Sets the associated view for the UI event.</param>
 /// <param name="detail">Sets the detail id for the UIevent.</param>
 /// <param name="target">The target that is being focused.</param>
 public FocusEvent(String type, Boolean bubbles, Boolean cancelable, IWindow view, Int32 detail, IEventTarget target)
 {
     Init(type, bubbles, cancelable, view, detail, target);
 }
コード例 #48
0
 /// <summary>
 /// Creates a new event and initializes it.
 /// </summary>
 /// <param name="type">The type of the event.</param>
 /// <param name="bubbles">If the event is bubbling.</param>
 /// <param name="cancelable">If the event is cancelable.</param>
 /// <param name="view">Sets the associated view for the UI event.</param>
 /// <param name="detail">Sets the detail id for the UIevent.</param>
 /// <param name="target">The target that is being focused.</param>
 public FocusEvent(String type, Boolean bubbles, Boolean cancelable, IWindow view, Int32 detail, IEventTarget target)
 {
     Init(type, bubbles, cancelable, view, detail, target);
 }
コード例 #49
0
ファイル: MouseEvent.cs プロジェクト: Wojdav/AngleSharp
 public MouseEvent(String type, Boolean bubbles = false, Boolean cancelable = false, IWindow view = null, Int32 detail = 0, Int32 screenX = 0, Int32 screenY = 0, Int32 clientX = 0, Int32 clientY = 0, Boolean ctrlKey = false, Boolean altKey = false, Boolean shiftKey = false, Boolean metaKey = false, MouseButton button = MouseButton.Primary, IEventTarget relatedTarget = null)
 {
     Init(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget);
 }
コード例 #50
0
ファイル: WheelEvent.cs プロジェクト: JackieyLi/AngleSharp
 /// <summary>
 /// Creates a new event and initializes it.
 /// </summary>
 /// <param name="type">The type of the event.</param>
 /// <param name="bubbles">If the event is bubbling.</param>
 /// <param name="cancelable">If the event is cancelable.</param>
 /// <param name="view">Sets the associated view for the UI event.</param>
 /// <param name="detail">Sets the detail id for the UI event.</param>
 /// <param name="screenX">Sets the screen X coordinate.</param>
 /// <param name="screenY">Sets the screen Y coordinate.</param>
 /// <param name="clientX">Sets the client X coordinate.</param>
 /// <param name="clientY">Sets the client Y coordinate.</param>
 /// <param name="button">Sets which button has been pressed.</param>
 /// <param name="target">The target of the mouse event.</param>
 /// <param name="modifiersList">A list with keyboard modifiers that have been pressed.</param>
 /// <param name="deltaX">The mouse wheel delta in X direction.</param>
 /// <param name="deltaY">The mouse wheel delta in Y direction.</param>
 /// <param name="deltaZ">The mouse wheel delta in Z direction.</param>
 /// <param name="deltaMode">The delta mode for the wheel event.</param>
 public WheelEvent(String type, Boolean bubbles, Boolean cancelable, IWindow view, Int32 detail, Int32 screenX, Int32 screenY, Int32 clientX, Int32 clientY, MouseButton button, IEventTarget target, String modifiersList, Double deltaX, Double deltaY, Double deltaZ, WheelMode deltaMode)
 {
     Init(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY, button, target, modifiersList, deltaX, deltaY, deltaZ, deltaMode);
 }
コード例 #51
0
        /// <summary>
        /// Firing an event means dispatching the initialized (and trusted) event
        /// at the specified event target.
        /// </summary>
        /// <param name="target">The target of the event.</param>
        /// <param name="initializer">The used initializer.</param>
        /// <param name="currentTarget">The current event target, if different to the target.</param>
        /// <returns>True if the element was cancelled, otherwise false.</returns>
        public static Boolean Fire <T>(this EventTarget target, Action <T> initializer, IEventTarget currentTarget = null)
            where T : Event, new()
        {
            var ev = new T {
                IsTrusted = true
            };

            initializer(ev);
            //TODO dispatch at currentTarget for target (!)
            return(ev.Dispatch(target));
        }
コード例 #52
0
ファイル: FocusEvent.cs プロジェクト: h82258652/AngleSharp
 public void Init(String type, Boolean bubbles, Boolean cancelable, IWindow view, Int32 detail, IEventTarget target)
 {
     Init(type, bubbles, cancelable, view, detail);
     Target = target;
 }
コード例 #53
0
 /// <summary>
 /// Copy events subscriptions from events collection to the target object
 /// </summary>
 /// <param name="target"></param>
 /// <param name="events"></param>
 public void CloneEvents(IEventTarget target, Dictionary<string, List<ScriptFunction>> events)
 {
     foreach (var pair in events)
     {
         foreach (ScriptFunction function in pair.Value)
         {
             target.addEventListener(pair.Key, function, false);
         }
     }
 }
コード例 #54
0
 public WheelEvent(String type, Boolean bubbles = false, Boolean cancelable = false, IWindow view = null, Int32 detail = 0, Int32 screenX = 0, Int32 screenY = 0, Int32 clientX = 0, Int32 clientY = 0, MouseButton button = MouseButton.Primary, IEventTarget target = null, String modifiersList = null, Double deltaX = 0.0, Double deltaY = 0.0, Double deltaZ = 0.0, WheelMode deltaMode = WheelMode.Pixel)
 {
     Init(type, bubbles, cancelable, view, detail, screenX, screenY, clientX, clientY, button, target, modifiersList ?? String.Empty, deltaX, deltaY, deltaZ, deltaMode);
 }
コード例 #55
0
ファイル: GdiRenderer.cs プロジェクト: codebutler/savagesvg
        /// <summary>
        /// Processes mouse events.
        /// </summary>
        /// <param name="type">
        /// A string describing the type of mouse event that occured.
        /// </param>
        /// <param name="e">
        /// The <see cref="MouseEventArgs">MouseEventArgs</see> that contains
        /// the event data.
        /// </param>
        public void OnMouseEvent(string type, int x, int y)
        {
            if (idMapRaster != null)
            {
            try
            {
                Color pixel = idMapRaster.GetPixel(x, y);
                GraphicsNode grNode = _getGraphicsNodeFromColor(pixel);

                if (grNode != null)
                {
                    SvgElement grElement = (SvgElement)grNode.Element;
                    IEventTarget target;
                    if (grElement.ElementInstance != null)
                        target = grElement.ElementInstance as IEventTarget;
                    else
                        target = grElement as IEventTarget;

                    if (target != null)
                    {
                        switch (type)
                        {
                        case "mousemove":
                            {
                                if (currentTarget == target)
                                {
                                    target.DispatchEvent(new MouseEvent(
                                                             EventType.MouseMove, true, false,
                                                             null, // todo: put view here
                                                             0, // todo: put detail here
                                                             x, y, x, y,
                                                             false, false, false, false,
                                                             0, null, false));
                                }
                                else
                                {
                                    if (currentTarget != null)
                                    {
                                        currentTarget.DispatchEvent(new MouseEvent(
                                                                        EventType.MouseOut, true, false,
                                                                        null, // todo: put view here
                                                                        0, // todo: put detail here
                                                                        x, y, x, y,
                                                                        false, false, false, false,
                                                                        0, null, false));
                                    }

                                    target.DispatchEvent(new MouseEvent(
                                                             EventType.MouseOver, true, false,
                                                             null, // todo: put view here
                                                             0, // todo: put detail here
                                                             x, y, x, y,
                                                             false, false, false, false,
                                                             0, null, false));
                                }
                                break;
                            }
                        case "mousedown":
                            target.DispatchEvent(new MouseEvent(
                                                     EventType.MouseDown, true, false,
                                                     null, // todo: put view here
                                                     0, // todo: put detail here
                                                     x, y, x, y,
                                                     false, false, false, false,
                                                     0, null, false));
                            currentDownTarget = target;
                            currentDownX = x;
                            currentDownY = y;
                            break;
                        case "mouseup":
                            target.DispatchEvent(new MouseEvent(
                                                     EventType.MouseUp, true, false,
                                                     null, // todo: put view here
                                                     0, // todo: put detail here
                                                     x, y, x, y,
                                                     false, false, false, false,
                                                     0, null, false));
                            if (/*currentDownTarget == target &&*/ Math.Abs(currentDownX-x) < 5 && Math.Abs(currentDownY-y) < 5)
                            {
                                target.DispatchEvent(new MouseEvent(
                                                         EventType.Click, true, false,
                                                         null, // todo: put view here
                                                         0, // todo: put detail here
                                                         x, y, x, y,
                                                         false, false, false, false,
                                                         0, null, false));
                            }
                            currentDownTarget = null;
                            currentDownX = 0;
                            currentDownY = 0;
                            break;
                        }
                        currentTarget = target;
                    }
                    else
                    {

                        // jr patch
                        if (currentTarget != null && type == "mousemove")
                        {
                            currentTarget.DispatchEvent(new MouseEvent(
                                                            EventType.MouseOut, true, false,
                                                            null, // todo: put view here
                                                            0, // todo: put detail here
                                                            x, y, x, y,
                                                            false, false, false, false,
                                                            0, null, false));
                        }
                        currentTarget = null;
                    }
                }
                else
                {
                    // jr patch
                    if (currentTarget != null && type == "mousemove")
                    {
                        currentTarget.DispatchEvent(new MouseEvent(
                                                        EventType.MouseOut, true, false,
                                                        null, // todo: put view here
                                                        0, // todo: put detail here
                                                        x, y, x, y,
                                                        false, false, false, false,
                                                        0, null, false));
                    }
                    currentTarget = null;
                }
            }
            catch
            {
            }
            }
        }