Widow – Diff between revs 1 and 11
?pathlinks?
Rev 1 | Rev 11 | |||
---|---|---|---|---|
Line -... | Line 1... | |||
- | 1 | using System; |
||
1 | using System.Reflection; |
2 | using System.Reflection; |
|
- | 3 | using System.Windows.Forms; |
||
2 | using Microsoft.Win32; |
4 | using Microsoft.Win32; |
|
Line 3... | Line 5... | |||
3 | |
5 | |
|
4 | namespace Widow |
6 | namespace Widow |
|
5 | { |
7 | { |
|
6 | public static class LaunchOnBoot |
8 | public static class LaunchOnBoot |
|
7 | { |
9 | { |
|
Line -... | Line 10... | |||
- | 10 | #region Public Methods |
||
- | 11 | |
||
- | 12 | /// <summary> |
||
- | 13 | /// Enable double buffering for an arbitrary control. |
||
- | 14 | /// </summary> |
||
- | 15 | /// <param name="control">the control to enable double buffering for</param> |
||
- | 16 | /// <returns>true on success</returns> |
||
- | 17 | /// <remarks>Do not enable double buffering on RDP: https://devblogs.microsoft.com/oldnewthing/20060103-12/?p=32793</remarks> |
||
- | 18 | public static bool SetDoubleBuffered(this Control control) |
||
- | 19 | { |
||
- | 20 | if (SystemInformation.TerminalServerSession) |
||
- | 21 | { |
||
- | 22 | return false; |
||
- | 23 | } |
||
- | 24 | |
||
- | 25 | var dgvType = control.GetType(); |
||
- | 26 | var pi = dgvType.GetProperty("DoubleBuffered", |
||
- | 27 | BindingFlags.Instance | BindingFlags.NonPublic); |
||
- | 28 | if (pi == null) |
||
- | 29 | { |
||
- | 30 | return false; |
||
- | 31 | } |
||
- | 32 | |
||
- | 33 | pi.SetValue(control, true, null); |
||
- | 34 | |
||
- | 35 | return true; |
||
- | 36 | } |
||
- | 37 | |
||
- | 38 | public static void Execute(this Control control, Action lambda) |
||
- | 39 | { |
||
- | 40 | if (control.InvokeRequired) |
||
- | 41 | { |
||
- | 42 | control.Invoke((MethodInvoker) lambda.Invoke); |
||
- | 43 | } |
||
- | 44 | else |
||
- | 45 | { |
||
- | 46 | lambda.Invoke(); |
||
- | 47 | } |
||
8 | #region Public Methods |
48 | } |
|
9 | |
49 | |
|
10 | public static bool Set(bool enable) |
50 | public static bool Set(bool enable) |
|
11 | { |
51 | { |
|
12 | using (var key = Registry.CurrentUser.OpenSubKey |
52 | using (var key = Registry.CurrentUser.OpenSubKey |