protected virtual void OnApplicationChanged(ApplicationChangedEventArgs e) { if (ApplicationChanged != null) { ApplicationChanged(this, e); } }
private async void OnApplicationChanged(object sender, ApplicationChangedEventArgs e) { Logger.LogWarning($"Application change detected."); var previousTopicFilters = e.Previous?.TopicFilters; var currentTopicFilters = e.Current?.TopicFilters; await UnsubscribeTopics(previousTopicFilters); await SubscribeToTopics(currentTopicFilters); }
protected override void OnApplicationChanged(ApplicationChangedEventArgs appChangedArgs) { EventHandler <ApplicationChangedEventArgs> handlerCopy = m_applicationChanged; if (handlerCopy != null) { handlerCopy(this, appChangedArgs); Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "Fired the application changed event callback."); } }
private void EngineSettings_ApplicationSettingsChanged(object sender, ApplicationChangedEventArgs e) { if (!e.Settings.AllowViewportSettingsOverride) { Prevented(); } else { var vud = m_addUserDataSection.Settings; Allowed(vud); } }
private void PointCapture_ForegroundApplicationsChanged(object sender, ApplicationChangedEventArgs appsChanged) { if (appsChanged.Applications != null) { var userAppList = appsChanged.Applications.Where(application => application is UserApp).ToList(); if (userAppList.Count == 0) { return; } UpdateBlockTouchInputThreshold(userAppList.Cast <UserApp>().Max(app => app.BlockTouchInputThreshold)); } }
private void Instance_ForegroundApplicationsChanged(object sender, ApplicationChangedEventArgs appsChanged) { var hotKeyActions = appsChanged.Applications.Where(application => application is UserApp && application.Actions != null).SelectMany(app => app.Actions).Where(a => a != null && a.Hotkey != null).ToList(); hotKeyActions.AddRange(ApplicationManager.Instance.GetGlobalApplication().Actions.Where(a => a.Hotkey != null)); if (hotKeyActions.Count == 0) { UnloadHotKeys(); } else { RegisterHotKeys(hotKeyActions); } }
protected virtual void OnApplicationChanged(ApplicationChangedEventArgs appChangedArgs) { EventHandler <ApplicationChangedEventArgs> handlerCopy = m_applicationChanged; if (handlerCopy != null) { if (SynchronizingObject != null && SynchronizingObject.InvokeRequired) { SynchronizingObject.BeginInvoke(handlerCopy, new object[] { this, appChangedArgs }); } else { handlerCopy(this, appChangedArgs); } Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "Fired the application changed event callback."); } }
static void ApplicationChangedCallback(object state, bool timedOut) { SafeCollabData eventData = null; int errorCode = 0; Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "ApplicationChangedCallback() called."); while (true){ ApplicationChangedEventArgs appChangedArgs = null; // // Get the event data for the fired event // try{ lock (LockAppChangedEvent){ if (s_safeAppChangedEvent.IsInvalid) return; errorCode = UnsafeCollabNativeMethods.PeerCollabGetEventData(s_safeAppChangedEvent, out eventData); } if (errorCode == UnsafeCollabReturnCodes.PEER_S_NO_EVENT_DATA) break; else if (errorCode != 0){ Logging.P2PTraceSource.TraceEvent(TraceEventType.Error, 0, "PeerCollabGetEventData returned with errorcode {0}", errorCode); throw PeerToPeerException.CreateFromHr(SR.GetString(SR.Collab_GetApplicationChangedDataFailed), errorCode); } PEER_COLLAB_EVENT_DATA ped = (PEER_COLLAB_EVENT_DATA)Marshal.PtrToStructure(eventData.DangerousGetHandle(), typeof(PEER_COLLAB_EVENT_DATA)); if (ped.eventType == PeerCollabEventType.MyApplicationChanged){ PEER_EVENT_APPLICATION_CHANGED_DATA appData = ped.applicationChangedData; PEER_APPLICATION pa = (PEER_APPLICATION)Marshal.PtrToStructure(appData.pApplication, typeof(PEER_APPLICATION)); PeerApplication peerApplication = CollaborationHelperFunctions.ConvertPEER_APPLICATIONToPeerApplication(pa); ; if (appData.pEndPoint != IntPtr.Zero){ // // This means its an endpoint on my contact which is not on the local machine // so we dont care // return; } appChangedArgs = new ApplicationChangedEventArgs( null, null, appData.changeType, peerApplication); } } finally{ if (eventData != null) eventData.Dispose(); } // // Fire the callback with the marshalled event args data // EventHandler<ApplicationChangedEventArgs> handlerCopy = s_applicationChanged; if ((appChangedArgs != null) && (handlerCopy != null)){ if (SynchronizingObject != null && SynchronizingObject.InvokeRequired) SynchronizingObject.BeginInvoke(handlerCopy, new object[] { null, appChangedArgs }); else handlerCopy(null, appChangedArgs); Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "Fired the application changed event callback."); } } Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "Leaving ApplicationChangedCallback()."); }
internal override void ApplicationChangedCallback(object state, bool timedOut) { SafeCollabData eventData = null; int errorCode = 0; Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "ApplicationChangedCallback() called."); if (m_Disposed) return; while (true) { ApplicationChangedEventArgs appChangedArgs = null; // // Get the event data for the fired event // try{ lock (LockAppChangedEvent){ if (m_safeAppChangedEvent.IsInvalid) return; errorCode = UnsafeCollabNativeMethods.PeerCollabGetEventData(m_safeAppChangedEvent, out eventData); } if (errorCode == UnsafeCollabReturnCodes.PEER_S_NO_EVENT_DATA) break; else if (errorCode != 0){ Logging.P2PTraceSource.TraceEvent(TraceEventType.Error, 0, "PeerCollabGetEventData returned with errorcode {0}", errorCode); throw PeerToPeerException.CreateFromHr(SR.GetString(SR.Collab_GetApplicationChangedDataFailed), errorCode); } PEER_COLLAB_EVENT_DATA ped = (PEER_COLLAB_EVENT_DATA)Marshal.PtrToStructure(eventData.DangerousGetHandle(), typeof(PEER_COLLAB_EVENT_DATA)); if (ped.eventType == PeerCollabEventType.MyApplicationChanged){ PEER_EVENT_APPLICATION_CHANGED_DATA appData = ped.applicationChangedData; PEER_APPLICATION pa = (PEER_APPLICATION)Marshal.PtrToStructure(appData.pApplication, typeof(PEER_APPLICATION)); PeerApplication peerApplication = CollaborationHelperFunctions.ConvertPEER_APPLICATIONToPeerApplication(pa); ; PeerEndPoint peerEndPoint = null; if (appData.pEndPoint != IntPtr.Zero){ PEER_ENDPOINT pe = (PEER_ENDPOINT)Marshal.PtrToStructure(appData.pEndPoint, typeof(PEER_ENDPOINT)); peerEndPoint = CollaborationHelperFunctions.ConvertPEER_ENDPOINTToPeerEndPoint(pe); } appChangedArgs = new ApplicationChangedEventArgs(peerEndPoint, null, appData.changeType, peerApplication); } } finally{ if (eventData != null) eventData.Dispose(); } // // Fire the callback with the marshalled event args data // if(appChangedArgs != null) OnApplicationChanged(appChangedArgs); } Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "Leaving ApplicationChangedCallback()."); }
protected override void OnApplicationChanged(ApplicationChangedEventArgs appChangedArgs) { EventHandler<ApplicationChangedEventArgs> handlerCopy = m_applicationChanged; if (handlerCopy != null){ handlerCopy(this, appChangedArgs); Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "Fired the application changed event callback."); } }
private void ApplicationChangedCallback(object state, bool timedOut) { SafeCollabData eventData = null; int errorCode = 0; Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "ApplicationChangedCallback() called."); if (m_Disposed) { return; } while (true) { ApplicationChangedEventArgs appChangedArgs = null; // // Get the event data for the fired event // try{ lock (LockAppChangedEvent) { if (m_safeAppChangedEvent.IsInvalid) { return; } errorCode = UnsafeCollabNativeMethods.PeerCollabGetEventData(m_safeAppChangedEvent, out eventData); } if (errorCode == UnsafeCollabReturnCodes.PEER_S_NO_EVENT_DATA) { break; } else if (errorCode != 0) { Logging.P2PTraceSource.TraceEvent(TraceEventType.Error, 0, "PeerCollabGetEventData returned with errorcode {0}", errorCode); throw PeerToPeerException.CreateFromHr(SR.GetString(SR.Collab_GetApplicationChangedDataFailed), errorCode); } PEER_COLLAB_EVENT_DATA ped = (PEER_COLLAB_EVENT_DATA)Marshal.PtrToStructure(eventData.DangerousGetHandle(), typeof(PEER_COLLAB_EVENT_DATA)); if (ped.eventType == PeerCollabEventType.EndPointApplicationChanged) { PEER_EVENT_APPLICATION_CHANGED_DATA appData = ped.applicationChangedData; PEER_APPLICATION pa = (PEER_APPLICATION)Marshal.PtrToStructure(appData.pApplication, typeof(PEER_APPLICATION)); PeerApplication peerApplication = CollaborationHelperFunctions.ConvertPEER_APPLICATIONToPeerApplication(pa);; // // Check if the Guid of the fired app is indeed our guid // if (Guid.Equals(m_id, peerApplication.Id)) { PeerContact peerContact = null; PeerEndPoint peerEndPoint = null; if (appData.pContact != IntPtr.Zero) { PEER_CONTACT pc = (PEER_CONTACT)Marshal.PtrToStructure(appData.pContact, typeof(PEER_CONTACT)); peerContact = CollaborationHelperFunctions.ConvertPEER_CONTACTToPeerContact(pc); } if (appData.pEndPoint != IntPtr.Zero) { PEER_ENDPOINT pe = (PEER_ENDPOINT)Marshal.PtrToStructure(appData.pEndPoint, typeof(PEER_ENDPOINT)); peerEndPoint = CollaborationHelperFunctions.ConvertPEER_ENDPOINTToPeerEndPoint(pe); } appChangedArgs = new ApplicationChangedEventArgs(peerEndPoint, peerContact, appData.changeType, peerApplication); } } } finally{ if (eventData != null) { eventData.Dispose(); } } // // Fire the callback with the marshalled event args data // if (appChangedArgs != null) { OnApplicationChanged(appChangedArgs); } } Logging.P2PTraceSource.TraceEvent(TraceEventType.Information, 0, "Leaving ApplicationChangedCallback()."); }