Ejemplo n.º 1
0
        /// <summary>
        /// Registers Power Notification
        /// </summary>
        private void RegisterPowerNotification(IntPtr handle, NotifyType notifyType, Guid powerSettings)
        {
            switch (notifyType)
            {
            case NotifyType.Window:
                _registeredPowerNotifications.Add(PowerNotification.RegisterPowerSettingNotification(handle, ref powerSettings, PowerNotification.DeviceNotifyType.DEVICE_NOTIFY_WINDOW_HANDLE));
                break;

            case NotifyType.Service:
                _registeredPowerNotifications.Add(PowerNotification.RegisterPowerSettingNotification(handle, ref powerSettings, PowerNotification.DeviceNotifyType.DEVICE_NOTIFY_SERVICE_HANDLE));
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Unregisters all Device and Power Notifications previously registered with RegisterPowerNotification and RegisterDeviceNotification
        /// </summary>
        /// <param name="handle">Window handle</param>
        public void UnRegisterNotifications(IntPtr handle)
        {
            foreach (var item in _registeredDeviceNotifications)
            {
                DeviceNotification.UnregisterDeviceNotification(item);
            }

            foreach (var item in _registeredPowerNotifications)
            {
                PowerNotification.UnregisterPowerSettingNotification(item);
            }

            SessionNotification.WTSUnRegisterSessionNotificationEx(SessionNotification.WTS_CURRENT_SERVER, handle);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Transforms a Message to NotificationDetail
        /// </summary>
        public static NotificationDetail Transform(ref Message m)
        {
            NotificationDetail nd = new NotificationDetail();

            if (_ignoreMessages.Contains(m.Msg))
            {
                return(null);
            }

            nd.Power  = PowerNotification.TransformMessage(ref m);
            nd.Device = DeviceNotification.TransformMessage(ref m);
            if ((nd.Power != null) || (nd.Device != null))
            {
                return(nd);
            }

            return(null);
        }
Ejemplo n.º 4
0
 protected override void PowerEvent(PowerNotification.PowerEventInfo e)
 {
     this.Log(EventLogEntryType.Information, string.Format("PowerEvent {0}", e));
 }
Ejemplo n.º 5
0
 internal void ServiceSendPowerEvent(PowerNotification.PowerEventInfo e)
 {
     PowerEvent(e);
 }
Ejemplo n.º 6
0
 protected abstract void PowerEvent(PowerNotification.PowerEventInfo e);