Ejemplo n.º 1
0
        private RestartOptions MapPowerMode(WebPowerMode powerMode)
        {
            switch (powerMode)
            {
            case WebPowerMode.LogOff:
                return(RestartOptions.LogOff);

            case WebPowerMode.PowerOff:
                return(RestartOptions.PowerOff);

            case WebPowerMode.Reboot:
                return(RestartOptions.Reboot);

            case WebPowerMode.ShutDown:
                return(RestartOptions.ShutDown);

            case WebPowerMode.Suspend:
                return(RestartOptions.Suspend);

            case WebPowerMode.Hibernate:
                return(RestartOptions.Hibernate);

            default:
                throw new InvalidCastException();
            }
        }
Ejemplo n.º 2
0
        public WebResult SetPowerMode(WebPowerMode powerMode)
        {
            try
            {
                if (powerMode == WebPowerMode.Screensaver)
                {
                    ScreenSaver.StartScreenSaver();
                }
                else if (powerMode == WebPowerMode.Lock)
                {
                    LockWorkStation();
                }
                else if (powerMode == WebPowerMode.ScreenOff)
                {
                    SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
                }
                else if (powerMode == WebPowerMode.ScreenOn)
                {

                }
                else
                {
                    RestartOptions option = MapPowerMode(powerMode);
                    WindowsController.ExitWindows(option, false);
                }
            }
            catch (InvalidCastException)
            {
                Log.Warn("The powerMode " + powerMode + " is not valid");
            }

            return new WebResult(true);
        }
Ejemplo n.º 3
0
        public WebBoolResult SetPowerMode(WebPowerMode powerMode)
        {
            try
            {
                if (powerMode == WebPowerMode.Screensaver)
                {
                    ScreenSaver.StartScreenSaver();
                }
                else if (powerMode == WebPowerMode.Lock)
                {
                    LockWorkStation();
                }
                else if (powerMode == WebPowerMode.ScreenOff)
                {
                    SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
                }
                else if (powerMode == WebPowerMode.ScreenOn)
                {
                }
                else
                {
                    RestartOptions option = MapPowerMode(powerMode);
                    WindowsController.ExitWindows(option, false);
                }
            }
            catch (InvalidCastException)
            {
                Log.Warn("The powerMode " + powerMode + " is not valid");
            }

            return(new WebBoolResult(true));
        }
Ejemplo n.º 4
0
        public WebResult SetPowerMode(WebPowerMode powerMode)
        {
            try
            {
                RestartOptions option = MapPowerMode(powerMode);
                WindowsController.ExitWindows(option, false);
            }
            catch (InvalidCastException)
            {
                Log.Warn("The powerMode " + powerMode + " is not valid");
            }

            return new WebResult(true);
        }
Ejemplo n.º 5
0
 private RestartOptions MapPowerMode(WebPowerMode powerMode)
 {
     switch (powerMode)
     {
         case WebPowerMode.LogOff:
             return RestartOptions.LogOff;
         case WebPowerMode.PowerOff:
             return RestartOptions.PowerOff;
         case WebPowerMode.Reboot:
             return RestartOptions.Reboot;
         case WebPowerMode.ShutDown:
             return RestartOptions.ShutDown;
         case WebPowerMode.Suspend:
             return RestartOptions.Suspend;
         case WebPowerMode.Hibernate:
             return RestartOptions.Hibernate;
         default:
             throw new InvalidCastException();
     }
 }
 public WebResult SetPowerMode(WebPowerMode powerMode)
 {
     return proxy.SetPowerMode(powerMode);
 }
 public WebBoolResult SetPowerMode(WebPowerMode powerMode)
 {
     return(Proxy.SetPowerMode(powerMode));
 }
 public WebBoolResult SetPowerMode(WebPowerMode powerMode)
 {
     return Proxy.SetPowerMode(powerMode);
 }