📄 screensaversensor.cs
字号:
namespace Imps.Client.Pc.Sensor
{
using Imps.Client.Pc;
using Imps.Client.Utils;
using Imps.Client.Utils.sensmon;
using Imps.Common;
using System;
using System.Runtime.CompilerServices;
internal class ScreenSaverSensor : PresenceSensorBase, IDisposable
{
private Imps.Client.Utils.sensmon.sensmon.sens_simple_notify_proc_type m_simple_event_proc;
public ScreenSaverSensor(IFrameworkWindow frameworkWnd) : base(frameworkWnd)
{
try
{
this.m_simple_event_proc = new Imps.Client.Utils.sensmon.sensmon.sens_simple_notify_proc_type(this.on_event_simple);
Imps.Client.Utils.sensmon.sensmon.simple_subscribe(Imps.Client.Utils.sensmon.sensmon.event_id.sens_startscreensaver, this.m_simple_event_proc, IntPtr.Zero);
Imps.Client.Utils.sensmon.sensmon.simple_subscribe(Imps.Client.Utils.sensmon.sensmon.event_id.sens_stopscreensaver, this.m_simple_event_proc, IntPtr.Zero);
}
catch (Exception exception)
{
ClientLogger.WriteException("Error on subscribing screensaver events", exception);
}
}
public void Dispose()
{
try
{
if (this.m_simple_event_proc != null)
{
Imps.Client.Utils.sensmon.sensmon.simple_unsubscribe(Imps.Client.Utils.sensmon.sensmon.event_id.sens_startscreensaver, this.m_simple_event_proc);
Imps.Client.Utils.sensmon.sensmon.simple_unsubscribe(Imps.Client.Utils.sensmon.sensmon.event_id.sens_stopscreensaver, this.m_simple_event_proc);
}
}
catch (Exception exception)
{
ClientLogger.WriteException("Error on unsubscribing screensaver events", exception);
}
}
~ScreenSaverSensor()
{
this.Dispose();
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void on_event_simple(Imps.Client.Utils.sensmon.sensmon.event_id id, IntPtr context)
{
try
{
if ((base.ImpsConfig.UserSetting.SensorSetting.AwayOnScreenSaver != null) && (Imps.Client.Utils.sensmon.sensmon.event_id.sens_startscreensaver == id))
{
base.PresenseValue = MainPresence.Away;
}
else
{
base.PresenseValue = MainPresence.Online;
}
}
catch (Exception exception)
{
ClientLogger.WriteException("Error on processing screensaver events", exception);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -