Exemplo n.º 1
0
        public static void DoAction(SystemStateAction action)
        {
            switch (action)
            {
            case SystemStateAction.Suspend:
                ServiceRegistration.Get <ISystemStateService>().Suspend();
                return;

            case SystemStateAction.Hibernate:
                ServiceRegistration.Get <ISystemStateService>().Hibernate();
                return;

            case SystemStateAction.Shutdown:
                ServiceRegistration.Get <ISystemStateService>().Shutdown();
                return;

            case SystemStateAction.Restart:
                ServiceRegistration.Get <ISystemStateService>().Restart();
                return;

            case SystemStateAction.Logoff:
                ServiceRegistration.Get <ISystemStateService>().Logoff();
                return;


            case SystemStateAction.CloseMP:
                ServiceRegistration.Get <IScreenControl>().Shutdown();
                return;

            case SystemStateAction.MinimizeMP:
                ServiceRegistration.Get <IScreenControl>().Minimize();
                return;
            }
        }
Exemplo n.º 2
0
        public static string GetResourceIdentifierForMenuItem(SystemStateAction systemStateAction, bool timerActive = false)
        {
            switch (systemStateAction)
            {
            case SystemStateAction.Suspend:
                return(RES_SYSTEM_SUSPEND_MENU_ITEM);

            case SystemStateAction.Hibernate:
                return(RES_SYSTEM_HIBERNATE_MENU_ITEM);

            case SystemStateAction.Shutdown:
                return(RES_SYSTEM_SHUTDOWN_MENU_ITEM);

            case SystemStateAction.Logoff:
                return(RES_SYSTEM_LOGOFF_MENU_ITEM);

            case SystemStateAction.Restart:
                return(RES_SYSTEM_RESTART_MENU_ITEM);

            case SystemStateAction.SleepTimer:
                return(timerActive ? RES_SYSTEM_SLEEPTIMER_STOP_MENU_ITEM : RES_SYSTEM_SLEEPTIMER_CFG_MENU_ITEM);

            case SystemStateAction.CloseMP:
                return(RES_MEDIAPORTAL_SHUTDOWN_MENU_ITEM);

            case SystemStateAction.MinimizeMP:
                return(RES_MEDIAPORTAL_MINIMIZE_MENU_ITEM);

            default:
                return(string.Empty);
            }
        }
Exemplo n.º 3
0
        private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            // update
            if (System.Threading.Monitor.TryEnter(_syncObject) == false)
            {
                return;
            }
            try
            {
                if (!_actSystemState.HasValue && _needConfigRead)
                {
                    _needConfigRead = false;
                    GetShutdownActionsFromSettings();
                }

                UpdateButtonEnabled();

                if (_actSystemState.HasValue)
                {
                    // calculate Remaining Minutes
                    TimeSpan ts      = DateTime.Now - _startTime;
                    int      minutes = (int)ts.TotalMinutes;
                    int      rMin    = InitialMinutes - minutes;

                    if (RemainingMinutes != rMin)
                    {
                        RemainingMinutes = rMin;
                    }

                    ILocalization localization = ServiceRegistration.Get <ILocalization>();

                    string actionString = localization.ToString(Consts.GetResourceIdentifierForMenuItem(_actSystemState.Value));
                    string res          = localization.ToString((RemainingMinutes <= 1) ? "[SleepTimer.ShutdownTextSingle]" : "[SleepTimer.ShutdownTextMulti]",
                                                                actionString, RemainingMinutes);

                    if (res != ShutdownText)
                    {
                        ShutdownText = res;
                    }

                    if (RemainingMinutes <= 0)
                    {
                        // finished, stop SleepTimer and do the action
                        SystemStateAction toDo = _actSystemState.Value;
                        Stop();
                        DoAction(toDo);
                    }
                }
                else
                {
                    ShutdownText     = string.Empty;
                    RemainingMinutes = 0;
                }
            }
            finally
            {
                System.Threading.Monitor.Exit(_syncObject);
            }
        }
Exemplo n.º 4
0
        private void SetLastSleepTimerAction(SystemStateAction action)
        {
            ISettingsManager          settingsManager = ServiceRegistration.Get <ISettingsManager>();
            SystemStateDialogSettings settings        = settingsManager.Load <SystemStateDialogSettings>();

            settings.LastSleepTimerAction = action;
            settingsManager.Save(settings);
        }
Exemplo n.º 5
0
        protected void DoAction(SystemStateAction action)
        {
            // I don't like this way, but I need it...
            DoClose(action);

            switch (action)
            {
            case SystemStateAction.Suspend:
                ServiceRegistration.Get <ISystemStateService>().Suspend();
                return;

            case SystemStateAction.Hibernate:
                ServiceRegistration.Get <ISystemStateService>().Hibernate();
                return;

            case SystemStateAction.Shutdown:
                ServiceRegistration.Get <ISystemStateService>().Shutdown();
                return;

            case SystemStateAction.Restart:
                ServiceRegistration.Get <ISystemStateService>().Restart();
                return;

            case SystemStateAction.Logoff:
                ServiceRegistration.Get <ISystemStateService>().Logoff();
                return;

            case SystemStateAction.CloseMP:
                ServiceRegistration.Get <IScreenControl>().Shutdown();
                return;

            case SystemStateAction.MinimizeMP:
                ServiceRegistration.Get <IScreenControl>().Minimize();
                return;

            case SystemStateAction.RestartMP:
                ServiceRegistration.Get <IScreenControl>().Restart();
                return;

            case SystemStateAction.SleepTimer:
                SleepTimerModel stm = ServiceRegistration.Get <IWorkflowManager>().GetModel(Consts.WF_STATE_ID_SLEEP_TIMER_MODEL) as SleepTimerModel;
                if (stm == null || stm.IsSleepTimerActive == false)
                {
                    ServiceRegistration.Get <IWorkflowManager>().NavigatePop(1);

                    ServiceRegistration.Get <IWorkflowManager>().NavigatePush(
                        Consts.WF_STATE_ID_SLEEP_TIMER_DIALOG);
                }
                else
                {
                    stm.Stop();
                    UpdateShutdownItems();
                }
                return;
            }
        }
Exemplo n.º 6
0
 protected void DoClose(SystemStateAction action)
 {
   switch(action)
   {
     case SystemStateAction.SleepTimer:
       return;
     default:
       ServiceRegistration.Get<IScreenManager>().CloseTopmostDialog();
       return;
   }      
 }
Exemplo n.º 7
0
        protected void DoClose(SystemStateAction action)
        {
            switch (action)
            {
            case SystemStateAction.SleepTimer:
                return;

            default:
                ServiceRegistration.Get <IScreenManager>().CloseTopmostDialog();
                return;
            }
        }
Exemplo n.º 8
0
        protected void DoAction(SystemStateAction action)
        {
            switch (action)
            {
            case SystemStateAction.Suspend:
                ServiceRegistration.Get <ISystemStateService>().Suspend();
                return;

            case SystemStateAction.Hibernate:
                ServiceRegistration.Get <ISystemStateService>().Hibernate();
                return;

            case SystemStateAction.Shutdown:
                ServiceRegistration.Get <ISystemStateService>().Shutdown();
                return;

            case SystemStateAction.Restart:
                ServiceRegistration.Get <ISystemStateService>().Restart();
                return;

            case SystemStateAction.Logoff:
                ServiceRegistration.Get <ISystemStateService>().Logoff();
                return;

            case SystemStateAction.CloseMP:
                ServiceRegistration.Get <IScreenControl>().Shutdown();
                return;

            case SystemStateAction.RestartMP:
                ServiceRegistration.Get <IScreenControl>().Restart();
                return;

            case SystemStateAction.MinimizeMP:
                ServiceRegistration.Get <IScreenControl>().Minimize();
                return;

            case SystemStateAction.SleepTimer:
                SleepTimerModel stm = ServiceRegistration.Get <IWorkflowManager>().GetModel(Consts.WF_STATE_ID_SLEEP_TIMER_MODEL) as SleepTimerModel;
                if (stm == null || stm.IsSleepTimerActive == false)
                {
                    CloseMenu();
                    ServiceRegistration.Get <IWorkflowManager>().NavigatePush(Consts.WF_STATE_ID_SLEEP_TIMER_DIALOG);
                }
                else
                {
                    stm.Stop();
                }
                _needsUpdate = true;
                break;
            }
        }
Exemplo n.º 9
0
        public static void DoAction(SystemStateAction action)
        {
            switch (action)
            {
            case SystemStateAction.Suspend:
                ServiceRegistration.Get <ISystemStateService>().Suspend();
                return;

            case SystemStateAction.Hibernate:
                ServiceRegistration.Get <ISystemStateService>().Hibernate();
                return;

            case SystemStateAction.Shutdown:
                ServiceRegistration.Get <ISystemStateService>().Shutdown();
                return;
            }
        }
Exemplo n.º 10
0
    private bool TryGetAction(ListItem item, out SystemStateAction action)
    {
      action = SystemStateAction.Suspend;
      if (item == null)
        return false;

      object oIndex;
      if (item.AdditionalProperties.TryGetValue(Consts.KEY_INDEX, out oIndex))
      {
        int? i = oIndex as int?;
        if (i.HasValue)
        {
          action = ShutdownItemList[i.Value].Action;
          return true;
        }
      }
      return false;
    }
Exemplo n.º 11
0
        private void GetShutdownActionsFromSettings()
        {
            SystemStateDialogSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <SystemStateDialogSettings>();

            PosibleShutdownModes = new List <SystemStateAction>();
            List <SystemStateItem> lst = settings.ShutdownItemList;

            for (int i = 0; i < lst.Count; i++)
            {
                if (lst[i].Enabled == false)
                {
                    continue;
                }

                switch (lst[i].Action)
                {
                case SystemStateAction.Shutdown:
                case SystemStateAction.Suspend:
                case SystemStateAction.Hibernate:
                    PosibleShutdownModes.Add(lst[i].Action);
                    break;
                }
            }

            // at least, one element is needed
            if (PosibleShutdownModes.Count == 0)
            {
                PosibleShutdownModes.Add(SystemStateAction.Shutdown);
            }

            // read the max sleeptime
            if (settings.MaxSleepTimeout.HasValue)
            {
                _maxSleepTimeInMinutes = settings.MaxSleepTimeout.Value;
            }

            // read the last action
            if (settings.LastSleepTimerAction.HasValue)
            {
                _wantedSystemState = settings.LastSleepTimerAction.Value;
            }

            UpdateButtonEnabled();
        }
Exemplo n.º 12
0
        private bool TryGetAction(ListItem item, out SystemStateAction action)
        {
            action = SystemStateAction.Suspend;
            if (item == null)
            {
                return(false);
            }

            object oIndex;

            if (item.AdditionalProperties.TryGetValue(Consts.KEY_INDEX, out oIndex))
            {
                int?i = oIndex as int?;
                if (i.HasValue)
                {
                    action = ShutdownItemList[i.Value].Action;
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Provides a callable method for the skin to change the action of the sleeptimer.
        /// </summary>
        public void Select()
        {
            if (_actSystemState.HasValue)
            {
                return;
            }

            int index = 0;

            for (int i = 0; i < PosibleShutdownModes.Count; i++)
            {
                if (PosibleShutdownModes[i] == _wantedSystemState)
                {
                    index = i;
                    break;
                }
            }

            index = (index + 1) % PosibleShutdownModes.Count;
            _wantedSystemState = PosibleShutdownModes[index];
            SetLastSleepTimerAction(_wantedSystemState);
            // update Buttontext & Buttonstates
            UpdateButtonEnabled();
        }
Exemplo n.º 14
0
 public static string GetResourceIdentifierForMenuItem(SystemStateAction systemStateAction, bool timerActive = false)
 {
   switch (systemStateAction)
   {
     case SystemStateAction.Suspend:
       return RES_SYSTEM_SUSPEND_MENU_ITEM;
     case SystemStateAction.Hibernate:
       return RES_SYSTEM_HIBERNATE_MENU_ITEM;
     case SystemStateAction.Shutdown:
       return RES_SYSTEM_SHUTDOWN_MENU_ITEM;
     case SystemStateAction.Logoff:
       return RES_SYSTEM_LOGOFF_MENU_ITEM;
     case SystemStateAction.Restart:
       return RES_SYSTEM_RESTART_MENU_ITEM;
     case SystemStateAction.SleepTimer:
       return timerActive ? RES_SYSTEM_SLEEPTIMER_STOP_MENU_ITEM : RES_SYSTEM_SLEEPTIMER_CFG_MENU_ITEM;
     case SystemStateAction.CloseMP:
       return RES_MEDIAPORTAL_SHUTDOWN_MENU_ITEM;
     case SystemStateAction.MinimizeMP:
       return RES_MEDIAPORTAL_MINIMIZE_MENU_ITEM;
     default:
       return string.Empty;
   }
 }
Exemplo n.º 15
0
 internal SystemStateItem(SystemStateAction action, bool enabled)
 {
   Action = action;
   Enabled = enabled;
 }
Exemplo n.º 16
0
    /// <summary>
    /// Provides a callable method for the skin to change the action of the sleeptimer.
    /// </summary> 
    public void Select()
    {
      if (_actSystemState.HasValue)
        return;

      int index = 0;
      for (int i = 0; i < PosibleShutdownModes.Count; i++)
      {
        if (PosibleShutdownModes[i] == _wantedSystemState)
        {
          index = i;
          break;
        }
      }

      index = (index + 1) % PosibleShutdownModes.Count;
      _wantedSystemState = PosibleShutdownModes[index];
      SetLastSleepTimerAction(_wantedSystemState);
      // update Buttontext & Buttonstates
      UpdateButtonEnabled();
    }
Exemplo n.º 17
0
    public static void DoAction(SystemStateAction action)
    {
      switch (action)
      {
        case SystemStateAction.Suspend:
          ServiceRegistration.Get<ISystemStateService>().Suspend();
          return;

        case SystemStateAction.Hibernate:
          ServiceRegistration.Get<ISystemStateService>().Hibernate();
          return;

        case SystemStateAction.Shutdown:
          ServiceRegistration.Get<ISystemStateService>().Shutdown();
          return;
      }
    }
Exemplo n.º 18
0
    private void GetShutdownActionsFromSettings()
    {
      SystemStateDialogSettings settings = ServiceRegistration.Get<ISettingsManager>().Load<SystemStateDialogSettings>();
      PosibleShutdownModes = new List<SystemStateAction>();
      List<SystemStateItem> lst = settings.ShutdownItemList;
      for (int i = 0; i < lst.Count; i++)
      {
        if (lst[i].Enabled == false)
          continue;

        switch (lst[i].Action)
        {
          case SystemStateAction.Shutdown:
          case SystemStateAction.Suspend:
          case SystemStateAction.Hibernate:
            PosibleShutdownModes.Add(lst[i].Action);
            break;
        }
      }

      // at least, one element is needed
      if (PosibleShutdownModes.Count == 0)
        PosibleShutdownModes.Add(SystemStateAction.Shutdown);

      // read the max sleeptime
      if (settings.MaxSleepTimeout.HasValue)
        _maxSleepTimeInMinutes = settings.MaxSleepTimeout.Value;

      // read the last action
      if (settings.LastSleepTimerAction.HasValue)
        _wantedSystemState = settings.LastSleepTimerAction.Value;

      UpdateButtonEnabled();
    }
Exemplo n.º 19
0
    protected void DoAction(SystemStateAction action)
    {
      // I don't like this way, but I need it...
      DoClose(action);

      switch (action)
      {
        case SystemStateAction.Suspend:
          ServiceRegistration.Get<ISystemStateService>().Suspend();
          return;
        case SystemStateAction.Hibernate:
          ServiceRegistration.Get<ISystemStateService>().Hibernate();
          return;
        case SystemStateAction.Shutdown:
          ServiceRegistration.Get<ISystemStateService>().Shutdown();
          return;
        case SystemStateAction.Restart:
          ServiceRegistration.Get<ISystemStateService>().Restart();
          return;
        case SystemStateAction.Logoff:
          ServiceRegistration.Get<ISystemStateService>().Logoff();
          return;
        case SystemStateAction.CloseMP:
          ServiceRegistration.Get<IScreenControl>().Shutdown();
          return;
        case SystemStateAction.MinimizeMP:
          ServiceRegistration.Get<IScreenControl>().Minimize();
          return;
        case SystemStateAction.SleepTimer:
          Models.SleepTimerModel stm = ServiceRegistration.Get<IWorkflowManager>().GetModel(Consts.WF_STATE_ID_SLEEP_TIMER_MODEL) as Models.SleepTimerModel;
          if (stm == null || stm.IsSleepTimerActive == false)
          {
            ServiceRegistration.Get<IWorkflowManager>().NavigatePop(1);

            ServiceRegistration.Get<IWorkflowManager>().NavigatePush(
              Consts.WF_STATE_ID_SLEEP_TIMER_DIALOG);
          }
          else
          {
            stm.Stop();
            UpdateShutdownItems();
          }          
          return;
      }        
    }
Exemplo n.º 20
0
 internal SystemStateItem(SystemStateAction action, bool enabled)
 {
     Action  = action;
     Enabled = enabled;
 }
Exemplo n.º 21
0
 private void SetLastSleepTimerAction(SystemStateAction action)
 {
   ISettingsManager settingsManager = ServiceRegistration.Get<ISettingsManager>();
   SystemStateDialogSettings settings = settingsManager.Load<SystemStateDialogSettings>();
   settings.LastSleepTimerAction = action;
   settingsManager.Save(settings);
 }
Exemplo n.º 22
0
    public static void DoAction(SystemStateAction action)
    {
      switch (action)
      {
        case SystemStateAction.Suspend:
          ServiceRegistration.Get<ISystemStateService>().Suspend();
          return;

        case SystemStateAction.Hibernate:
          ServiceRegistration.Get<ISystemStateService>().Hibernate();
          return;

        case SystemStateAction.Shutdown:
          ServiceRegistration.Get<ISystemStateService>().Shutdown();
          return;

        case SystemStateAction.Restart:
          ServiceRegistration.Get<ISystemStateService>().Restart();
          return;

        case SystemStateAction.Logoff:
          ServiceRegistration.Get<ISystemStateService>().Logoff();
          return;


        case SystemStateAction.CloseMP:
          ServiceRegistration.Get<IScreenControl>().Shutdown();
          return;

        case SystemStateAction.MinimizeMP:
          ServiceRegistration.Get<IScreenControl>().Minimize();
          return;
      }
    }