本文整理汇总了C#中Microsoft.Win32.PowerModeChangedEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# PowerModeChangedEventArgs类的具体用法?C# PowerModeChangedEventArgs怎么用?C# PowerModeChangedEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PowerModeChangedEventArgs类属于Microsoft.Win32命名空间,在下文中一共展示了PowerModeChangedEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SystemEvents_PowerModeChanged
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if(e.Mode == PowerModes.Resume)
{
UpdateLayout();
}
}
示例2: SystemEvents_PowerModeChanged
void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if (e.Mode == PowerModes.Resume)
{
ResetKeyboardSpeed();
}
}
示例3: SystemEvents_PowerModeChanged
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
try
{
if (e.Mode == PowerModes.Suspend)
{
//EventTrackerContext.Save(
EventQueue.Enqueue(
new LogOnEvent()
{
IsLoggedOn = false,
EventTime = DateTime.Now,
});
}
else if (e.Mode == PowerModes.Resume)
{
//EventTrackerContext.Save(
EventQueue.Enqueue(
new LogOnEvent()
{
IsLoggedOn = true,
EventTime = DateTime.Now,
});
}
}
catch (Exception ex)
{
Logger.Log(ex.ToString());
}
}
示例4: SystemEvents_PowerModeChanged
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if (AutomaticSwitching)
{
RedetectNetwork();
}
}
示例5: SystemEvents_PowerModeChanged
private static void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if ( e.Mode == PowerModes.Suspend )
{
SystemEvents.PowerModeChanged -= PowerHandeler;
Environment.Exit( 0 );
}
}
示例6: HandlePowerEvent
public static void HandlePowerEvent(PowerModeChangedEventArgs args)
{
if (args.Mode == PowerModes.Resume)
{
Logger.Log("Refreshing on system resume");
MakeWebRequest();
}
}
示例7: SystemEvents_PowerModeChanged
void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if (e.Mode == PowerModes.Resume)
{
DisposeTimer();
StartTimer(Timeout.InfiniteTimeSpan);
}
}
示例8: SystemEvents_PowerModeChanged
/// <summary>
/// Handles the PowerModeChanged event of the SystemEvents control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="PowerModeChangedEventArgs" /> instance containing the event data.</param>
async void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if (e.Mode == PowerModes.Resume && SystemEvent == SystemEvent.WakeFromSleep)
{
// This value is a bit arbitrary, but add a delay to help ensure network connections have been restored before running the task
await Task.Delay(10000).ConfigureAwait(false);
OnTriggered();
}
}
示例9: SystemEvents_PowerModeChanged
void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if (e.Mode == PowerModes.Resume)
{
if (ResumeFromSleep != null)
{
ResumeFromSleep(this, EventArgs.Empty);
}
}
}
示例10: SystemEvents_PowerModeChanged
async void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if (e.Mode == PowerModes.Resume)
{
for (int i = 0; i < 20; ++i)
{
await Task.Delay(500);
m_dev.SetEventNotification(m_notifyEvent.SafeWaitHandle.DangerousGetHandle());
}
}
}
示例11: PowerModeChanged
/// <summary>
/// Method for responding to the power mode changed event. For some reason, the scanner man
/// object gets messed up when going into suspend mode. If we release all of the scanners
/// when suspend mode is started and reaquire them when resuming, scanning can resume.
/// </summary>
/// <param name="sender"></param>
/// <param name="e">Contains the mode to identify whether we're entering or leaving suspend mode.</param>
private void PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if (e.Mode == PowerModes.Suspend)
{
Shutdown();
}
else if (e.Mode == PowerModes.Resume)
{
Startup();
}
}
示例12: SystemEvents_PowerModeChanged
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
switch (e.Mode)
{
case PowerModes.Resume:
File.AppendAllText("D:/log.txt", DateTime.Now.ToString("HH:mm:ss.fff", System.Globalization.DateTimeFormatInfo.InvariantInfo) + ": Resume");
break;
case PowerModes.Suspend:
File.AppendAllText("D:/log.txt", DateTime.Now.ToString("HH:mm:ss.fff", System.Globalization.DateTimeFormatInfo.InvariantInfo) + ": Suspend");
break;
}
}
示例13: SystemEvents_PowerModeChanged
private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if (e.Mode == PowerModes.Suspend && this.IsOpen)
{
this.resume = true;
this.Close();
}
else if (e.Mode == PowerModes.Resume && this.resume)
{
this.resume = false;
this.Open();
}
}
示例14: PowerMode
void PowerMode( object sender, PowerModeChangedEventArgs e )
{
ConsoleWriter.Write( string.Format( "****: Power mode changed event fired! {0}\n", e.Mode ), true );
if( e.Mode == PowerModes.Suspend )
foreach( var irc in _ircControllers )
irc.Close();
else
foreach( var irc in _ircControllers.Where( r => r.ExceptionalState ) )
{
ConsoleWriter.Write( "****: Bad state detected." );
irc.Close();
}
}
示例15: collected
static HandlerRoutine _controlHandler = null; // Keeps it from getting garbage collected (and null exception)
private static void OnPowerChange(Object sender, PowerModeChangedEventArgs pe)
{
Log.WriteSystemEventLog("MCEBuddy engine app OnPowerChange called by System, Event -> " + pe.Mode.ToString(), EventLogEntryType.Information);
switch (pe.Mode)
{
case PowerModes.Resume:
try
{
if (_pipeProxy.WithinConversionTimes()) // Resume only if we are within Conversion times else it will auto resume at the right time
_pipeProxy.SuspendConversion(false); // Resume
}
catch (Exception e)
{
Log.WriteSystemEventLog("MCEBuddy engine app: Error trying to resume MCEBuddy " + e.ToString(), EventLogEntryType.Warning);
}
break;
case PowerModes.Suspend:
try
{
_pipeProxy.SuspendConversion(true); // suspend and buffers are flushed when suspended
}
catch (Exception e)
{
Log.WriteSystemEventLog("MCEBuddy engine app: Error trying to suspend MCEBuddy " + e.ToString(), EventLogEntryType.Warning);
}
break;
case PowerModes.StatusChange:
try
{
Log.WriteSystemEventLog("MCEBuddy engine app: Power Status Change Notification, Power Status -> " + System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus.ToString(), EventLogEntryType.Information);
if (System.Windows.Forms.SystemInformation.PowerStatus.PowerLineStatus == System.Windows.Forms.PowerLineStatus.Offline) // If we are on battery power
{
if (MCEBuddyConf.GlobalMCEConfig.GeneralOptions.suspendOnBattery) // If we are requested to Pause on battery power
_pipeProxy.SuspendConversion(true); // Suspend it
}
else if (_pipeProxy.WithinConversionTimes()) // Resume only if we are within Conversion times else it will auto resume at the right time
_pipeProxy.SuspendConversion(false); // Resume it (assume A/C power)
}
catch (Exception e)
{
Log.WriteSystemEventLog("MCEBuddy engine app: Error trying to change suspend mode on Power Event in MCEBuddy " + e.ToString(), EventLogEntryType.Warning);
}
break;
}
}