Widow

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ 10  →  ?path2? @ 11
/trunk/Widow/Utilities.cs
@@ -1,4 +1,6 @@
using System.Reflection;
using System;
using System.Reflection;
using System.Windows.Forms;
using Microsoft.Win32;
 
namespace Widow
@@ -7,6 +9,44 @@
{
#region Public Methods
 
/// <summary>
/// Enable double buffering for an arbitrary control.
/// </summary>
/// <param name="control">the control to enable double buffering for</param>
/// <returns>true on success</returns>
/// <remarks>Do not enable double buffering on RDP: https://devblogs.microsoft.com/oldnewthing/20060103-12/?p=32793</remarks>
public static bool SetDoubleBuffered(this Control control)
{
if (SystemInformation.TerminalServerSession)
{
return false;
}
 
var dgvType = control.GetType();
var pi = dgvType.GetProperty("DoubleBuffered",
BindingFlags.Instance | BindingFlags.NonPublic);
if (pi == null)
{
return false;
}
 
pi.SetValue(control, true, null);
 
return true;
}
 
public static void Execute(this Control control, Action lambda)
{
if (control.InvokeRequired)
{
control.Invoke((MethodInvoker) lambda.Invoke);
}
else
{
lambda.Invoke();
}
}
 
public static bool Set(bool enable)
{
using (var key = Registry.CurrentUser.OpenSubKey