/[NexusPowerControl]/trunk/NexusPowerControl/MainUI.cs
ViewVC logotype

Diff of /trunk/NexusPowerControl/MainUI.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/NexusPowerControl/MainUI.cs	2011/10/25 07:39:27	23
+++ trunk/NexusPowerControl/MainUI.cs	2011/10/25 07:46:52	24
@@ -1,4 +1,6 @@
-´╗┐using System;
+´╗┐#define TEST_NEXUS_POWER_COMMAND // when defined will, run the NexusPowerCommand in normal, non-hidden mode
+#define DONOT_CLOSE_MAIN_FORM_WHEN_TESTING_NEXUS_POWER_COMMAND // when defined, will not close the main form, when executing NexusPowerCommand operation
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
@@ -6,6 +8,7 @@
 using System.Linq;
 using System.Text;
 using System.Windows.Forms;
+using System.Diagnostics;
 
 namespace NexusPowerControl
 {
@@ -65,26 +68,76 @@
         private void btnShutdown_Click(object sender, EventArgs e)
         {
             // shutdown the computer
+            Process p = new Process();
+            p.StartInfo.FileName = ThemeConstants.PowerCommandApplication;
+            p.StartInfo.Arguments = "/shutdown";
+#if !TEST_NEXUS_POWER_COMMAND
+            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
+#endif
+            p.Start();
+#if !DONOT_CLOSE_MAIN_FORM_WHEN_TESTING_NEXUS_POWER_COMMAND
+            this.Close();
+#endif
         }
 
         private void btnRestart_Click(object sender, EventArgs e)
         {
             // restart the computer
+            Process p = new Process();
+            p.StartInfo.FileName = ThemeConstants.PowerCommandApplication;
+            p.StartInfo.Arguments = "/restart";
+#if !TEST_NEXUS_POWER_COMMAND
+            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
+#endif
+            p.Start();
+#if !DONOT_CLOSE_MAIN_FORM_WHEN_TESTING_NEXUS_POWER_COMMAND
+            this.Close();
+#endif
         }
 
         private void btnLogoff_Click(object sender, EventArgs e)
         {
             // logoff the current user
+            Process p = new Process();
+            p.StartInfo.FileName = ThemeConstants.PowerCommandApplication;
+            p.StartInfo.Arguments = "/logoff";
+#if !TEST_NEXUS_POWER_COMMAND
+            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
+#endif
+            p.Start();
+#if !DONOT_CLOSE_MAIN_FORM_WHEN_TESTING_NEXUS_POWER_COMMAND
+            this.Close();
+#endif
         }
 
         private void btnLockScreen_Click(object sender, EventArgs e)
         {
             // lock the screen
+            Process p = new Process();
+            p.StartInfo.FileName = ThemeConstants.PowerCommandApplication;
+            p.StartInfo.Arguments = "/lock";
+#if !TEST_NEXUS_POWER_COMMAND
+            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
+#endif
+            p.Start();
+#if !DONOT_CLOSE_MAIN_FORM_WHEN_TESTING_NEXUS_POWER_COMMAND
+            this.Close();
+#endif
         }
 
         private void btnSleep_Click(object sender, EventArgs e)
         {
             // put the computer to sleep
+            Process p = new Process();
+            p.StartInfo.FileName = ThemeConstants.PowerCommandApplication;
+            p.StartInfo.Arguments = "/sleep";
+#if !TEST_NEXUS_POWER_COMMAND
+            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
+#endif
+            p.Start();
+#if !DONOT_CLOSE_MAIN_FORM_WHEN_TESTING_NEXUS_POWER_COMMAND
+            this.Close();
+#endif
         }
 
         private void btnClose_Click(object sender, EventArgs e)

 

  ViewVC Help
Powered by ViewVC 1.1.22