Widow

Subversion Repositories:
Compare Path: Rev
With Path: Rev
?path1? @ HEAD  →  ?path2? @ 1
/trunk/Widow/Utilities.cs
@@ -1,6 +1,4 @@
using System;
using System.Reflection;
using System.Windows.Forms;
using System.Reflection;
using Microsoft.Win32;
 
namespace Widow
@@ -9,43 +7,6 @@
{
#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 InvokeIfRequired<T>(this T control, Action<T> action) where T : Control
{
if (control.InvokeRequired)
{
control.BeginInvoke((MethodInvoker) delegate { action(control); });
return;
}
 
action(control);
}
 
public static bool Set(bool enable)
{
using (var key = Registry.CurrentUser.OpenSubKey