Widow – Diff between revs 1 and 11

Subversion Repositories:
Rev:
Only display areas with differencesIgnore whitespace
Rev 1 Rev 11
-   1 using System;
1 using System.Reflection; 2 using System.Reflection;
-   3 using System.Windows.Forms;
2 using Microsoft.Win32; 4 using Microsoft.Win32;
3   5  
4 namespace Widow 6 namespace Widow
5 { 7 {
6 public static class LaunchOnBoot 8 public static class LaunchOnBoot
7 { 9 {
8 #region Public Methods 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 }
-   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
13 ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) 53 ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
14 { 54 {
15 if (key == null) 55 if (key == null)
16 { 56 {
17 return false; 57 return false;
18 } 58 }
19   59  
20 switch (enable) 60 switch (enable)
21 { 61 {
22 case true: 62 case true:
23 key.SetValue(Constants.AssemblyName, Assembly.GetEntryAssembly().Location); 63 key.SetValue(Constants.AssemblyName, Assembly.GetEntryAssembly().Location);
24 break; 64 break;
25 default: 65 default:
26 key.DeleteValue(Constants.AssemblyName, false); 66 key.DeleteValue(Constants.AssemblyName, false);
27 break; 67 break;
28 } 68 }
29 } 69 }
30   70  
31 return true; 71 return true;
32 } 72 }
33   73  
34 public static bool Get() 74 public static bool Get()
35 { 75 {
36 using (var key = Registry.CurrentUser.OpenSubKey 76 using (var key = Registry.CurrentUser.OpenSubKey
37 ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true)) 77 ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
38 { 78 {
39 return key?.GetValue(Constants.AssemblyName) != null; 79 return key?.GetValue(Constants.AssemblyName) != null;
40 } 80 }
41 } 81 }
42   82  
43 #endregion 83 #endregion
44 } 84 }
45 } 85 }
46   86  
47
Generated by GNU Enscript 1.6.5.90.
87
Generated by GNU Enscript 1.6.5.90.
48   88  
49   89  
50   90