protected override void WndProc(ref Message m) { #region 屏幕打开和关闭事件 switch (m.Msg) { case NativeMethods.WM_POWERBROADCAST: if (m.WParam == (IntPtr)NativeMethods.PBT_POWERSETTINGCHANGE) { var settings = (NativeMethods.POWERBROADCAST_SETTING)m.GetLParam( typeof(NativeMethods.POWERBROADCAST_SETTING)); if (this.MonitorEvent != null) { MonitorEventType type = (MonitorEventType)settings.Data; this.MonitorEvent(type); } } m.Result = (IntPtr)1; break; } #endregion 屏幕打开和关闭事件 #region 判断是否有全屏应用 if (m.Msg == uCallBackMsg) { switch (m.WParam.ToInt32()) { case (int)ABNotify.ABN_FULLSCREENAPP: { IntPtr hWnd = WinApi.GetForegroundWindow(); //判断当前全屏的应用是否是桌面 if (hWnd.Equals(desktopHandle) || hWnd.Equals(shellHandle)) { RunningFullScreenApp = false; break; } //判断是否全屏 if ((int)m.LParam == 1) { this.RunningFullScreenApp = true; } else { this.RunningFullScreenApp = false; } break; } default: break; } } #endregion 判断是否有全屏应用 base.WndProc(ref m); }
public MonitorEvent( string instanceName, MonitorEventType eventType, string handlerName, IRequest targetHandlerRequest, DateTime eventTime ) :base(new Guid()) { InstanceName = instanceName; EventType = eventType; HandlerName = handlerName; TargetHandlerRequest = targetHandlerRequest; EventTime = eventTime; }
public MonitorEvent( string instanceName, MonitorEventType eventType, string handlerName, string requestBody, DateTime eventTime ) :base(Guid.NewGuid()) { InstanceName = instanceName; EventType = eventType; HandlerName = handlerName; RequestBody = requestBody; EventTime = eventTime; }
public MonitorEvent( string instanceName, MonitorEventType eventType, string handlerName, string requestBody, DateTime eventTime, Exception exception = null ) : base(Guid.NewGuid()) { InstanceName = instanceName; EventType = eventType; HandlerName = handlerName; RequestBody = requestBody; EventTime = eventTime; Exception = exception; }
private void F_WndProc_MonitorEvent(MonitorEventType type) { curMonitorStatus = type; switch (type) { case MonitorEventType.PowerOff: timerS.Stop(); if (screensaver != null && screensaver.Visibility == Visibility.Visible) { screensaver.Close(); } break; case MonitorEventType.PowerOn: timerS.Interval = 15000d; // 默认15秒检测一次是否达到屏保设定时间 timerS.Start(); break; } }
public MonitorEvent( string instanceName, MonitorEventType eventType, string handlerName, string handlerFullName, string requestBody, DateTime eventTime, int elapsedMilliseconds, Exception exception = null ) : base(Guid.NewGuid()) { InstanceName = instanceName; EventType = eventType; HandlerName = handlerName; HandlerFullAssemblyName = handlerFullName; RequestBody = requestBody; EventTime = eventTime; TimeElapsedMs = elapsedMilliseconds; Exception = exception; }
private void OnMonitorEvent(string monitorUri, string uri, MonitorEventType eventType) { MonitorHandler handler = null; switch (eventType) { case MonitorEventType.Changed: handler = Changed; break; case MonitorEventType.Deleted: handler = Deleted; break; case MonitorEventType.Startexecuting: handler = Startexecuting; break; case MonitorEventType.Stopexecuting: handler = Stopexecuting; break; case MonitorEventType.Created: handler = Created; break; case MonitorEventType.MetadataChanged: handler = MetadataChanged; break; } if (handler != null) { handler(monitorUri, uri); } }
public void NativeCallback(IntPtr handle, string monitorUri, string uri, MonitorEventType eventType, IntPtr data) { _managed(monitorUri, uri, eventType); }
public MonitorEvent( string instanceName, MonitorEventType eventType, string handlerName, string handlerFullName, string requestBody, DateTime eventTime, int elapsedMilliseconds, Exception exception = null ) :base(Guid.NewGuid()) { InstanceName = instanceName; EventType = eventType; HandlerName = handlerName; HandlerFullAssemblyName = handlerFullName; RequestBody = requestBody; EventTime = eventTime; TimeElapsedMs = elapsedMilliseconds; Exception = exception; }
// internal static void ThreadLoop() { while (AddonStarted) { string cmd = Console.ReadLine(); CommandeType Type = (CommandeType)Convert.ToInt32(cmd.Split(new char[] { ':' }, 2)[0]); #region Response if (Type == CommandeType.Response) { cmd = cmd.Split(new char[] { ':' }, 2)[1]; string _Id = cmd.Split(new char[] { ':' }, 2)[0]; Responses[_Id].Value = cmd.Split(new char[] { ':' }, 2)[1]; Responses[_Id].AEvent.Set(); } #endregion #region Action Event else if (Type == CommandeType.ActionEvent) { cmd = cmd.Split(new char[] { ':' }, 2)[1]; string _WindowName = cmd.Split(new char[] { ':' }, 2)[0]; ActionId _ActionId = (ActionId)Convert.ToInt32(cmd.Split(new char[] { ':' }, 2)[1]); Task taskA = Task.Run(() => Windows[_WindowName]._OnAction(new ActionEventArgs(_ActionId))); } #endregion #region Window Event else if (Type == CommandeType.WindowInitEvent) { string _WindowName = cmd.Split(new char[] { ':' }, 2)[1]; Task taskA = Task.Run(() => Windows[_WindowName]._OnInit()); } #endregion #region Monitor Event else if (Type == CommandeType.MonitorEvent) { cmd = cmd.Split(new char[] { ':' }, 2)[1]; string _MonitorName = cmd.Split(new char[] { ':' }, 2)[0]; cmd = cmd.Split(new char[] { ':' }, 2)[1]; MonitorEventType _EventType = (MonitorEventType)Convert.ToInt32(cmd.Split(new char[] { ':' }, 2)[0]); if (_EventType == MonitorEventType.SettingsChanged) { Task taskA = Task.Factory.StartNew(() => Monitors[_MonitorName]._OnSettingsChanged()); } else if (_EventType == MonitorEventType.ScreensaverActivated) { Task taskA = Task.Factory.StartNew(() => Monitors[_MonitorName]._OnScreensaverActivated()); } else if (_EventType == MonitorEventType.ScreensaverDeactivated) { Task taskA = Task.Factory.StartNew(() => Monitors[_MonitorName]._OnScreensaverDeactivated()); } else if (_EventType == MonitorEventType.CleanStarted) { LibraryType _Library = (LibraryType)Convert.ToInt32(cmd.Split(new char[] { ':' }, 2)[1]); Task taskA = Task.Factory.StartNew(() => Monitors[_MonitorName]._OnCleanStarted(_Library)); } else if (_EventType == MonitorEventType.CleanFinished) { LibraryType _Library = (LibraryType)Convert.ToInt32(cmd.Split(new char[] { ':' }, 2)[1]); Task taskA = Task.Factory.StartNew(() => Monitors[_MonitorName]._OnCleanFinished(_Library)); } else if (_EventType == MonitorEventType.ScanStarted) { LibraryType _Library = (LibraryType)Convert.ToInt32(cmd.Split(new char[] { ':' }, 2)[1]); Task taskA = Task.Factory.StartNew(() => Monitors[_MonitorName]._OnScanStarted(_Library)); } else if (_EventType == MonitorEventType.ScanFinished) { LibraryType _Library = (LibraryType)Convert.ToInt32(cmd.Split(new char[] { ':' }, 2)[1]); Task taskA = Task.Factory.StartNew(() => Monitors[_MonitorName]._OnScanFinished(_Library)); } else if (_EventType == MonitorEventType.Notification) { cmd = cmd.Split(new char[] { ':' }, 2)[1]; string sender = cmd.Split(new char[] { ':' }, 3)[0]; string method = cmd.Split(new char[] { ':' }, 3)[1]; string data = cmd.Split(new char[] { ':' }, 3)[2]; Task taskA = Task.Factory.StartNew(() => Monitors[_MonitorName]._OnNotification(sender, method, data)); } else if (_EventType == MonitorEventType.DPMSActivated) { Task taskA = Task.Factory.StartNew(() => Monitors[_MonitorName]._OnDPMSActivated()); } else if (_EventType == MonitorEventType.DPMSDeactivated) { Task taskA = Task.Factory.StartNew(() => Monitors[_MonitorName]._OnDPMSDeactivated()); } } #endregion #region Player Event /*else if (cmd.Contains("XbmcPlayerEvent:")) * { * string newcmd = cmd.Replace("XbmcPlayerEvent:", ""); * string _PlayerName = newcmd.Split(':')[0]; * string _EventType = newcmd.Replace(_PlayerName + ":", ""); * if (_EventType.Contains("onPlayBackStarted")) * { * Task taskA = Task.Factory.StartNew(() => Players[_PlayerName]._OnPlayBackStarted(new EventArgs())); * } * else if (_EventType.Contains("onPlayBackEnded")) * { * Task taskA = Task.Factory.StartNew(() => Players[_PlayerName]._OnPlayBackEnded(new EventArgs())); * } * else if (_EventType.Contains("onPlayBackStopped")) * { * Task taskA = Task.Factory.StartNew(() => Players[_PlayerName]._OnPlayBackStopped(new EventArgs())); * } * else if (_EventType.Contains("onPlayBackPaused")) * { * Task taskA = Task.Factory.StartNew(() => Players[_PlayerName]._OnPlayBackPaused(new EventArgs())); * } * else if (_EventType.Contains("onPlayBackResumed")) * { * Task taskA = Task.Factory.StartNew(() => Players[_PlayerName]._OnPlayBackResumed(new EventArgs())); * } * else if (_EventType.Contains("onPlayBackSeek")) * { * int _time = Convert.ToInt32(_EventType.Replace("onPlayBackSeek:", "")); * Task taskA = Task.Factory.StartNew(() => Players[_PlayerName]._OnPlayBackSeek(_time)); * } * else if (_EventType.Contains("onPlayBackSeekChapter")) * { * int _chapter = Convert.ToInt32(_EventType.Replace("onPlayBackSeekChapter:", "")); * Task taskA = Task.Factory.StartNew(() => Players[_PlayerName]._OnPlayBackSeekChapter(_chapter)); * } * else if (_EventType.Contains("onPlayBackSpeedChanged")) * { * int _speed = Convert.ToInt32(_EventType.Replace("onPlayBackSpeedChanged:", "")); * Task taskA = Task.Factory.StartNew(() => Players[_PlayerName]._OnPlayBackSpeedChanged(_speed)); * } * else if (_EventType.Contains("onQueueNextItem")) * { * Task taskA = Task.Factory.StartNew(() => Players[_PlayerName]._OnQueueNextItem(new EventArgs())); * } * }*/ #endregion #region Control Event else if (Type == CommandeType.ControlEvent) { int _ControlId = Convert.ToInt32(cmd.Split(new char[] { ':' }, 2)[1]); Task taskA = Task.Factory.StartNew(() => Controls[_ControlId]._OnClick(new EventArgs())); } else if (Type == CommandeType.ControlFocusEvent) { int _ControlId = Convert.ToInt32(cmd.Split(new char[] { ':' }, 2)[1]); Task taskA = Task.Factory.StartNew(() => Controls[_ControlId]._OnFocus(new EventArgs())); } else if (Type == CommandeType.ControleDoubleClickEvent) { int _ControlId = Convert.ToInt32(cmd.Split(new char[] { ':' }, 2)[1]); Task taskA = Task.Factory.StartNew(() => Controls[_ControlId]._OnDoubleClick(new EventArgs())); } #endregion } }
private void OnMonitorEvent (string monitorUri, string uri, MonitorEventType eventType) { MonitorHandler handler = null; switch (eventType) { case MonitorEventType.Changed: handler = Changed; break; case MonitorEventType.Deleted: handler = Deleted; break; case MonitorEventType.Startexecuting: handler = Startexecuting; break; case MonitorEventType.Stopexecuting: handler = Stopexecuting; break; case MonitorEventType.Created: handler = Created; break; case MonitorEventType.MetadataChanged: handler = MetadataChanged; break; } if (handler != null) handler (monitorUri, uri); }
public void NativeCallback (IntPtr handle, string monitorUri, string uri, MonitorEventType eventType, IntPtr data) { _managed (monitorUri, uri, eventType); }