public EventObjects GetEventInfo(int?itbid)
        {
            var resp = new EventObjects();

            var rtv = repoFreeEvents.GetNonAsync(o => o.Itbid == itbid);

            if (rtv != null)
            {
                resp.eventDate     = rtv.StartDate;
                resp.eventName     = rtv.EventTitle;
                resp.eventLocation = rtv.EventLocation;
            }
            return(resp);
        }
Esempio n. 2
0
 /// <summary>
 /// WinEventDelegate for the creation & destruction
 /// </summary>
 /// <param name="eventType"></param>
 /// <param name="hWnd"></param>
 /// <param name="idObject"></param>
 /// <param name="idChild"></param>
 /// <param name="dwEventThread"></param>
 /// <param name="dwmsEventTime"></param>
 private void WinEventHandler(WinEvent eventType, IntPtr hWnd, EventObjects idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
 {
     if (hWnd == IntPtr.Zero || idObject != EventObjects.OBJID_WINDOW)
     {
         return;
     }
     if (eventType == WinEvent.EVENT_OBJECT_NAMECHANGE)
     {
         if (_titleChangeEvent != null)
         {
             string newTitle = new WindowDetails(hWnd).Text;
             _titleChangeEvent(new TitleChangeEventArgs {
                 HWnd = hWnd, Title = newTitle
             });
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Initializes scripts
        /// </summary>
        public override bool init()
        {
            EventObjects.eventInit(this, true);

            //Load the associated scripts
            _scripts = Scripts.instanceScripts(this, _scriptType);


            //If the bot implementes a BT, load it and use it.
            _BehaviorTrees = new List <TreeSharp.Composite>();
            if (exists(BT_EVENT_KEY))
            {
                //Grab all handlers (could be more then one BT).
                foreach (var mthHandler in events[BT_EVENT_KEY].methods)
                {
                    TreeSharp.Composite x = mthHandler.handler(mthHandler.that, null) as TreeSharp.Composite;
                    x.Start(null);
                    _BehaviorTrees.Add(x);
                }
            }


            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Call the WinEventHandler for this event
        /// </summary>
        /// <param name="hWinEventHook"></param>
        /// <param name="eventType"></param>
        /// <param name="hWnd"></param>
        /// <param name="idObject"></param>
        /// <param name="idChild"></param>
        /// <param name="dwEventThread"></param>
        /// <param name="dwmsEventTime"></param>
        private void WinEventDelegateHandler(IntPtr hWinEventHook, WinEvent eventType, IntPtr hWnd, EventObjects idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            WinEventHandler handler;

            if (_winEventHandlers.TryGetValue(hWinEventHook, out handler))
            {
                handler(eventType, hWnd, idObject, idChild, dwEventThread, dwmsEventTime);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Calls a singlecast event, returning a value
 /// </summary>
 public object callsync(string name, bool bSync, params object[] args)
 {
     return(EventObjects.callsync(this, name, bSync, args));
 }
Esempio n. 6
0
 /// <summary>
 /// Calls a singlecast event, returning a value
 /// </summary>
 public object call(string name, params object[] args)
 {
     return(EventObjects.callsync(this, name, true, args));
 }
Esempio n. 7
0
 /// <summary>
 /// Triggers an event
 /// </summary>
 public void trigger(string name, params object[] args)
 {
     EventObjects.trigger(this, name, true, args);
 }
Esempio n. 8
0
 /// <summary>
 /// Initializes events for the event object
 /// </summary>
 public void eventInit(bool bParseEvents)
 {
     EventObjects.eventInit(this, bParseEvents);
 }
Esempio n. 9
0
        /// <summary>
        /// Handle the WinEvent
        /// </summary>
        /// <param name="hWinEventHook">The Hook IntPtr</param>
        /// <param name="eventType">Event Type to handle, enum WinEvent</param>
        /// <param name="hwnd">Window handle which caused the event</param>
        /// <param name="idObject">Object ID, enum EventObjects</param>
        /// <param name="idChild">Child ID of the window</param>
        /// <param name="dwEventThread">Thread which generated the ID</param>
        /// <param name="dwmsEventTime"></param>
        private static void WinEventProc(IntPtr hWinEventHook, WinEvent eventType, IntPtr hwnd, EventObjects idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            // Check if it's an event generated by a Window
            if (hwnd == IntPtr.Zero || idObject != EventObjects.OBJID_WINDOW)
            {
                // Other events do not interest us.
                return;
            }
            String classname = null;

            // Check if the event was generated by the OLE Event Thread, which causes a lot of create/destroy
            if (oleEventThread != 0 && dwEventThread == oleEventThread)
            {
                return;
            }

            // Only get the classname when it's not a destroy (classname is not available)
            if (eventType == WinEvent.EVENT_OBJECT_CREATE)
            {
                classname = WindowDetails.GetClassName(hwnd);
                // Make sure the OleMainThreadWndClass events are ignored.
                if (oleEventThread == 0)
                {
                    if (classname == "OleMainThreadWndClass")
                    {
                        oleEventThread = dwEventThread;
                        return;
                    }
                }
            }

            LOG.DebugFormat("eventType={0},hwnd={1},classname={4},idObject={2},idChild={3},dwEventThread={5}", eventType, hwnd, idObject, idChild, classname, dwEventThread);
        }
Esempio n. 10
0
        /// <summary>
        /// WinEventDelegate for the creation & destruction
        /// </summary>
        /// <param name="hWinEventHook"></param>
        /// <param name="eventType"></param>
        /// <param name="hWnd"></param>
        /// <param name="idObject"></param>
        /// <param name="idChild"></param>
        /// <param name="dwEventThread"></param>
        /// <param name="dwmsEventTime"></param>
        private void WinEventDelegate(IntPtr hWinEventHook, WinEvent eventType, IntPtr hWnd, EventObjects idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
        {
            if (hWnd == IntPtr.Zero || idObject != EventObjects.OBJID_WINDOW)
            {
                if (idObject != EventObjects.OBJID_CARET && idObject != EventObjects.OBJID_CURSOR)
                {
                    LOG.InfoFormat("Unhandled eventType: {0}, hWnd {1}, idObject {2}, idChild {3}, dwEventThread {4}, dwmsEventTime {5}", eventType, hWnd, idObject, idChild, dwEventThread, dwmsEventTime);
                }
                return;
            }
            WindowInfo windowInfo = null;
            IntPtr     hWndParent;
            bool       isPreviouslyCreated = windowsCache.TryGetValue(hWnd, out windowInfo);

            if (windowInfo == null)
            {
                hWndParent = User32.GetParent(hWnd);
                windowInfo = WindowInfo.CreateFor(hWnd, hWndParent);
            }
            else
            {
                hWndParent = windowInfo.Parent;
            }
            if (windowInfo.Classname == "OleMainThreadWndClass")
            {
                // Not a peeps, this window is not interresting.
                return;
            }
            LOG.InfoFormat("eventType {0}, hWnd {1}, idObject {2}, idChild {3}, dwEventThread {4}, dwmsEventTime {5}", eventType, hWnd, idObject, idChild, dwEventThread, dwmsEventTime);
            switch (eventType)
            {
            case WinEvent.EVENT_OBJECT_NAMECHANGE:
                if (windowsCache.TryGetValue(hWnd, out windowInfo))
                {
                    // Force update of Text
                    windowInfo.Text = null;
                    LOG.InfoFormat("Rename {0} / {1}", windowInfo.Text, windowInfo.Classname);
                }
                else
                {
                    // Huh?
                    LOG.WarnFormat("No record of a window with hWnd {0}", hWnd);
                }
                break;

            case WinEvent.EVENT_OBJECT_CREATE:
                if (!isPreviouslyCreated)
                {
                    if (hWndParent != IntPtr.Zero)
                    {
                        WindowInfo parent;
                        if (!windowsCache.TryGetValue(hWndParent, out parent))
                        {
                            parent = WindowInfo.CreateFor(hWndParent);
                            add(parent);
                        }
                        parent.Children.Add(windowInfo);
                        LOG.InfoFormat("Added child {0} / {1} to {2} / {3} / {4}", windowInfo.Text, windowInfo.Classname, parent.Handle, parent.Text, parent.Classname);
                    }
                    else
                    {
                        add(windowInfo);
                        LOG.InfoFormat("Added {0} / {1}", windowInfo.Text, windowInfo.Classname);
                    }
                }
                else
                {
                    LOG.InfoFormat("'Activated' parent {0} / {1}", windowInfo.Text, windowInfo.Classname);
                }
                break;

            case WinEvent.EVENT_OBJECT_DESTROY:
                if (isPreviouslyCreated)
                {
                    LOG.InfoFormat("Removing {0} / {1}", windowInfo.Text, windowInfo.Classname);
                    remove(windowInfo);
                }
                else
                {
                    if (hWndParent != IntPtr.Zero)
                    {
                        if (windowsCache.TryGetValue(hWnd, out windowInfo))
                        {
                            LOG.WarnFormat("Unhandled destroy of Child from {0}", windowInfo.Text);
                            // Implement child removal
                        }
                        else
                        {
                            LOG.WarnFormat("No record of a child-window with hWnd {0}", hWnd);
                        }
                    }
                    else
                    {
                        LOG.WarnFormat("No record of a top-window with hWnd {0}", hWnd);
                    }
                }
                break;

            case WinEvent.EVENT_OBJECT_FOCUS:
                // Move the top-window with the focus to the foreground
                if (isPreviouslyCreated)
                {
                    moveToFront(windowInfo);
                    LOG.InfoFormat("Focus: {0} / {1}", windowInfo.Text, windowInfo.Classname);
                }
                break;

            case WinEvent.EVENT_OBJECT_LOCATIONCHANGE:
            case WinEvent.EVENT_SYSTEM_MOVESIZESTART:
            case WinEvent.EVENT_SYSTEM_MOVESIZEEND:
                // Move the top-window with the focus to the foreground
                if (isPreviouslyCreated)
                {
                    windowInfo.Bounds = System.Drawing.Rectangle.Empty;
                    LOG.InfoFormat("Move/resize: {2} - {0} / {1}", windowInfo.Text, windowInfo.Classname, windowInfo.Bounds);
                }
                break;
            }
        }