Пример #1
0
    public override void OnAction(Action action)
    {
      _needToClearScreen = true;

      if (action.wID == Action.ActionType.ACTION_SHOW_VOLUME)
      {
        _volumeTimer = DateTime.Now;
        _isVolumeVisible = true;
        RenderVolume(_isVolumeVisible);
        //				if(_vmr9OSD!=null)
        //					_vmr9OSD.RenderVolumeOSD();
      }
      //ACTION_SHOW_CURRENT_TV_INFO
      if (action.wID == Action.ActionType.ACTION_SHOW_CURRENT_TV_INFO)
      {
        //if(_vmr9OSD!=null)
        //	_vmr9OSD.RenderCurrentShowInfo();
      }

      if (action.wID == Action.ActionType.ACTION_MOUSE_CLICK && action.MouseButton == MouseButtons.Right)
      {
        // switch back to the menu
        _isOsdVisible = false;
        //_msnWindowVisible = false;       // msn related can be removed
        GUIWindowManager.IsOsdVisible = false;
        GUIGraphicsContext.IsFullScreenVideo = false;
        GUIWindowManager.ShowPreviousWindow();
        return;
      }
      if (_isOsdVisible)
      {
        if (((action.wID == Action.ActionType.ACTION_SHOW_OSD) || (action.wID == Action.ActionType.ACTION_SHOW_GUI) ||
             (action.wID == Action.ActionType.ACTION_PREVIOUS_MENU)) && !_osdWindow.SubMenuVisible) // hide the OSD
        {
          lock (this)
          {
            HideMainOSD();
            return;
          }
        }
        else if (!_zapOsdVisible)
        {
          _osdTimeoutTimer = DateTime.Now;
          if (action.wID == Action.ActionType.ACTION_MOUSE_MOVE || action.wID == Action.ActionType.ACTION_MOUSE_CLICK)
          {
            int x = (int)action.fAmount1;
            int y = (int)action.fAmount2;
            if (!GUIGraphicsContext.MouseSupport)
            {
              _osdWindow.OnAction(action); // route keys to OSD window

              return;
            }
            else
            {
              if (_osdWindow.InWindow(x, y))
              {
                _osdWindow.OnAction(action); // route keys to OSD window

                HideZapOSD();

                return;
              }
              else
              {
                HideMainOSD();
                return;
              }
            }
          }
          Action newAction = new Action();
          if (action.wID != Action.ActionType.ACTION_KEY_PRESSED && action.wID != Action.ActionType.ACTION_PAUSE &&
              ActionTranslator.GetAction((int)Window.WINDOW_OSD, action.m_key, ref newAction))
          {
            _osdWindow.OnAction(newAction); // route keys to OSD window
          }
          else
          {
            // route unhandled actions to OSD window
            _osdWindow.OnAction(action);
          }
        }
        return;
      }
        //@
        /*
       * else if (_msnWindowVisible)       // msn related can be removed
      {
        if (((action.wID == Action.ActionType.ACTION_SHOW_OSD) || (action.wID == Action.ActionType.ACTION_SHOW_GUI))) // hide the OSD
        {
          lock (this)
          {
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT, _msnWindow.GetID, 0, 0, GetID, 0, null);
            _msnWindow.OnMessage(msg);	// Send a de-init msg to the OSD
            _msnWindowVisible = false;
            GUIWindowManager.IsOsdVisible = false;
          }
          return;
        }
        if (action.wID == Action.ActionType.ACTION_KEY_PRESSED)
        {
          _msnWindow.OnAction(action);

          return;
        }
      }*/

      else if (action.wID == Action.ActionType.ACTION_MOUSE_MOVE && GUIGraphicsContext.MouseSupport)
      {
        int y = (int)action.fAmount2;
        if (y > GUIGraphicsContext.Height - 100)
        {
          ShowMainOSD();
        }
      }
      else if (_zapOsdVisible)
      {
        if ((action.wID == Action.ActionType.ACTION_SHOW_GUI) || (action.wID == Action.ActionType.ACTION_SHOW_OSD) ||
            (action.wID == Action.ActionType.ACTION_PREVIOUS_MENU))
        {
          HideZapOSD();
        }
      }
      //Log.DebugFile(Log.LogType.Error, "action:{0}",action.wID);
      switch (action.wID)
      {
        case Action.ActionType.ACTION_MOUSE_DOUBLECLICK:
        case Action.ActionType.ACTION_SELECT_ITEM:
          {
            if (!g_Player.IsTVRecording)
            {
              if (_autoZapMode)
              {
                StopAutoZap();
              }
              else if (_zapOsdVisible)
              {
                TVHome.Navigator.ZapNow();
              }
              else
              {
                ShowMiniEpg();
                // LastChannel has been moved to "0"
                //if (!GUIWindowManager.IsRouted)
                //{
                //  GUITVHome.OnLastViewedChannel();
                //}
              }
            }
          }
          break;

        case Action.ActionType.ACTION_SHOW_INFO:
        case Action.ActionType.ACTION_SHOW_CURRENT_TV_INFO:
          {
            if (action.fAmount1 != 0)
            {
              _zapTimeOutTimer = DateTime.MaxValue;
              _zapTimeOutTimer = DateTime.Now;
            }
            else
            {
              _zapTimeOutTimer = DateTime.Now;
            }

            if (!_zapOsdVisible && !g_Player.IsTVRecording)
            {
              if (!_useVMR9Zap)
              {
                ShowZapOSD(_gotTvErrorMessage);
                _gotTvErrorMessage = null;
              }
            }
            else
            {
              _zapWindow.UpdateChannelInfo();
              _zapTimeOutTimer = DateTime.Now;
            }
          }
          break;

          // msn related can be removed
          //case Action.ActionType.ACTION_SHOW_MSN_OSD:
          //  if (_isMsnChatPopup)
          //  {
          //    Log.Debug("MSN CHAT:ON");

          //    _msnWindowVisible = true;
          //    GUIWindowManager.VisibleOsd = GUIWindow.Window.WINDOW_TVMSNOSD;
          //    ///@
          //    ///_msnWindow.DoModal(GetID, null);
          //    _msnWindowVisible = false;
          //    GUIWindowManager.IsOsdVisible = false;
          //  }
          //  break;

        case Action.ActionType.ACTION_AUTOCROP:
          {
            Log.Debug("ACTION_AUTOCROP");
            _statusVisible = true;
            _statusTimeOutTimer = DateTime.Now;

            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0, (int)Control.LABEL_ROW1,
                                            0, 0, null);
            IAutoCrop cropper = GUIGraphicsContext.autoCropper;
            if (cropper != null)
            {
              msg.Label = cropper.Crop();
              if (msg.Label == null)
              {
                msg.Label = "N/A";
              }
            }
            else
            {
              msg.Label = "N/A";
            }

            OnMessage(msg);
            break;
          }

        case Action.ActionType.ACTION_TOGGLE_AUTOCROP:
          {
            Log.Debug("ACTION_TOGGLE_AUTOCROP");
            _statusVisible = true;
            _statusTimeOutTimer = DateTime.Now;
            IAutoCrop cropper = GUIGraphicsContext.autoCropper;

            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0, (int)Control.LABEL_ROW1,
                                            0, 0, null);
            msg.Label = "N/A";

            if (cropper != null)
            {
              msg.Label = cropper.ToggleMode();
            }
            OnMessage(msg);
            break;
          }

        case Action.ActionType.ACTION_ASPECT_RATIO:
          {
            _statusVisible = true;
            _statusTimeOutTimer = DateTime.Now;
            string status = "";

            Geometry.Type arMode = GUIGraphicsContext.ARType;

            bool foundMode = false;
            for (int i = 0; i < _allowedArModes.Count; i++)
            {
              if (_allowedArModes[i] == arMode)
              {
                arMode = _allowedArModes[(i + 1) % _allowedArModes.Count]; // select next allowed mode
                foundMode = true;
                break;
              }
            }
            if (!foundMode && _allowedArModes.Count > 0)
            {
              arMode = _allowedArModes[0];
            }

            GUIGraphicsContext.ARType = arMode;
            status = Utils.GetAspectRatioLocalizedString(arMode);
            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0, (int)Control.LABEL_ROW1,
                                            0, 0, null);
            msg.Label = status;
            OnMessage(msg);
          }
          break;

        case Action.ActionType.ACTION_NEXT_SUBTITLE:
          if (g_Player.SubtitleStreams > 0 || g_Player.SupportsCC)
          {
            _statusVisible = true;
            _statusTimeOutTimer = DateTime.Now;

            GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0, (int)Control.LABEL_ROW1,
                                            0, 0, null);
            g_Player.SwitchToNextSubtitle();
            if (g_Player.EnableSubtitle)
            {
              if (g_Player.CurrentSubtitleStream == -1 && g_Player.SupportsCC)
              {
                msg.Label = "CC1";
              }
              else
              {
                msg.Label = string.Format("{0} ({1}/{2})", g_Player.SubtitleLanguage(g_Player.CurrentSubtitleStream),
                                          g_Player.CurrentSubtitleStream + 1, g_Player.SubtitleStreams);
              }
            }
            else
            {
              msg.Label = GUILocalizeStrings.Get(519); // Subtitles off
            }
            OnMessage(msg);
            Log.Info("MyTV toggle subtitle: switched subtitle to {0}", msg.Label);
          }
          else
          {
            Log.Info("MyTV toggle subtitle: no subtitle streams available!");
          }
          break;

        case Action.ActionType.ACTION_PAGE_UP:
          OnPageUp();
          break;

        case Action.ActionType.ACTION_PAGE_DOWN:
          OnPageDown();
          break;

        case Action.ActionType.ACTION_KEY_PRESSED:
          {
            // msn related can be removed
            //if ((action.m_key != null) && (!_msnWindowVisible))
            if (action.m_key != null)
            {
              OnKeyCode((char)action.m_key.KeyChar);
            }

            _messageBoxVisible = false;
          }
          break;

        case Action.ActionType.ACTION_REWIND:
          {
            if (g_Player.IsTimeShifting || g_Player.IsTVRecording)
            {
              _isPauseOsdVisible = false;
              GUIWindowManager.IsPauseOsdVisible = false;
              ScreenStateChanged();
              UpdateGUI();
            }
          }
          break;

        case Action.ActionType.ACTION_FORWARD:
          {
            if (g_Player.IsTimeShifting || g_Player.IsTVRecording)
            {
              _isPauseOsdVisible = false;
              GUIWindowManager.IsPauseOsdVisible = false;
              ScreenStateChanged();
              UpdateGUI();
            }
          }
          break;

        case Action.ActionType.ACTION_PREVIOUS_MENU:
        case Action.ActionType.ACTION_SHOW_GUI:
          Log.Debug("fullscreentv:show gui");
          //if(_vmr9OSD!=null)
          //	_vmr9OSD.HideBitmap();
          GUIWindowManager.ShowPreviousWindow();
          return;

        case Action.ActionType.ACTION_SHOW_OSD: // Show the OSD
          {
            Log.Debug("OSD:ON");
            ShowMainOSD();
          }
          break;

        case Action.ActionType.ACTION_MOVE_LEFT:
        case Action.ActionType.ACTION_STEP_BACK:
          {
            if (g_Player.IsTimeShifting || g_Player.IsTVRecording)
            {
              if (g_Player.Paused)
              {
                g_Player.Pause();
                _isPauseOsdVisible = false;
                GUIWindowManager.IsPauseOsdVisible = false;
                ScreenStateChanged();
                UpdateGUI();
              }
              _stepSeekVisible = true;
              _statusTimeOutTimer = DateTime.Now;
              g_Player.SeekStep(false);
              string strStatus = g_Player.GetStepDescription();
              GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0,
                                              (int)Control.LABEL_ROW1, 0, 0, null);
              msg.Label = strStatus;
              OnMessage(msg);
            }
          }
          break;

        case Action.ActionType.ACTION_MOVE_RIGHT:
        case Action.ActionType.ACTION_STEP_FORWARD:
          {
            if (g_Player.IsTimeShifting || g_Player.IsTVRecording)
            {
              if (g_Player.Paused)
              {
                g_Player.Pause();
                _isPauseOsdVisible = false;
                GUIWindowManager.IsPauseOsdVisible = false;
                ScreenStateChanged();
                UpdateGUI();
              }
              _stepSeekVisible = true;
              _statusTimeOutTimer = DateTime.Now;
              g_Player.SeekStep(true);
              string strStatus = g_Player.GetStepDescription();
              GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0,
                                              (int)Control.LABEL_ROW1, 0, 0, null);
              msg.Label = strStatus;
              OnMessage(msg);
            }
          }
          break;

        case Action.ActionType.ACTION_MOVE_DOWN:
        case Action.ActionType.ACTION_BIG_STEP_BACK:
          {
            if (g_Player.IsTimeShifting || g_Player.IsTVRecording)
            {
              if (g_Player.Paused)
              {
                g_Player.Pause();
                _isPauseOsdVisible = false;
                GUIWindowManager.IsPauseOsdVisible = false;
                ScreenStateChanged();
                UpdateGUI();
              }
              _statusVisible = true;
              _statusTimeOutTimer = DateTime.Now;
              GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0,
                                                (int)Control.LABEL_ROW1, 0, 0, null);
              msg.Label = "";
              OnMessage(msg);
              if (_immediateSeekIsRelative)
              {
                g_Player.SeekRelativePercentage(-_immediateSeekValue);
              }
              else
              {
                g_Player.SeekRelative(-_immediateSeekValue);
              }
            }
          }
          break;

        case Action.ActionType.ACTION_MOVE_UP:
        case Action.ActionType.ACTION_BIG_STEP_FORWARD:
          {
            if (g_Player.IsTimeShifting || g_Player.IsTVRecording)
            {
              if (g_Player.Paused)
              {
                g_Player.Pause();
                _isPauseOsdVisible = false;
                GUIWindowManager.IsPauseOsdVisible = false;
                ScreenStateChanged();
                UpdateGUI();
              }
              _statusVisible = true;
              _statusTimeOutTimer = DateTime.Now;
              GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0,
                                                (int)Control.LABEL_ROW1, 0, 0, null);
              msg.Label = "";
              OnMessage(msg);
              if (_immediateSeekIsRelative)
              {
                g_Player.SeekRelativePercentage(_immediateSeekValue);
              }
              else
              {
                g_Player.SeekRelative(_immediateSeekValue);
              }
            }
          }
          break;

        case Action.ActionType.ACTION_PAUSE:
          {
            ScreenStateChanged();
            UpdateGUI();
            if (g_Player.Paused)
            {
              if ((GUIGraphicsContext.Vmr9Active && VMR9Util.g_vmr9 != null))
              {
                VMR9Util.g_vmr9.SetRepaint();
                VMR9Util.g_vmr9.Repaint(); // repaint vmr9
              }
               _osdTimeoutTimer = DateTime.Now;
              GUIWindowManager.IsPauseOsdVisible = true;
            }
            else
            {
                GUIWindowManager.IsPauseOsdVisible = false;
            }
          }
          break;

        case Action.ActionType.ACTION_PLAY:
        case Action.ActionType.ACTION_MUSIC_PLAY:
              {
                  GUIWindowManager.IsPauseOsdVisible = false;
                  break;
              }


        case Action.ActionType.ACTION_CONTEXT_MENU:
          ShowContextMenu();
          break;

        case Action.ActionType.ACTION_AUTOZAP:
          StartAutoZap();
          break;

        case Action.ActionType.ACTION_AUDIO_NEXT_LANGUAGE:
        case Action.ActionType.ACTION_NEXT_AUDIO:
          {
            //IAudioStream[] streams = TVHome.Card.AvailableAudioStreams;

            if (g_Player.AudioStreams > 1)
            {
              int newIndex = 0;
              int oldIndex = 0;
              string audioLang = g_Player.AudioLanguage(oldIndex);
              oldIndex = g_Player.CurrentAudioStream;
              g_Player.SwitchToNextAudio();

              newIndex = g_Player.CurrentAudioStream;

              if (newIndex + 1 > g_Player.AudioStreams)
              {
                newIndex = 0;
              }

              Log.Debug("Switching from audio stream {0} to {1}", oldIndex, newIndex);

              // Show OSD Label
              _statusVisible = true;
              _statusTimeOutTimer = DateTime.Now;
              GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_LABEL_SET, GetID, 0,
                                              (int)Control.LABEL_ROW1, 0, 0, null);
              //msg.Label = string.Format("{0}:{1} ({2}/{3})", streams[newIndex].StreamType, streams[newIndex].Language, newIndex + 1, streams.Length);
              msg.Label = string.Format("{0}:{1} ({2}/{3})", g_Player.AudioType(newIndex),
                                        g_Player.AudioLanguage(newIndex), newIndex + 1, g_Player.AudioStreams);

              Log.Debug(msg.Label);
              OnMessage(msg);
            }
          }
          break;

        case Action.ActionType.ACTION_STOP:
          if (g_Player.IsTVRecording)
          {
            g_Player.Stop();
          }
          if (g_Player.IsTimeShifting)
          {
            Log.Debug("TVFullscreen: user request to stop");
            GUIDialogPlayStop dlgPlayStop =
              (GUIDialogPlayStop)GUIWindowManager.GetWindow((int)Window.WINDOW_DIALOG_PLAY_STOP);
            if (dlgPlayStop != null)
            {
              dlgPlayStop.SetHeading(GUILocalizeStrings.Get(605));
              dlgPlayStop.SetLine(1, GUILocalizeStrings.Get(2550));
              dlgPlayStop.SetLine(2, GUILocalizeStrings.Get(2551));
              dlgPlayStop.SetDefaultToStop(false);
              dlgPlayStop.DoModal(GetID);
              if (dlgPlayStop.IsStopConfirmed)
              {
                Log.Debug("TVFullscreen: stop confirmed");
                g_Player.Stop();
              }
            }
          }
          break;
      }

      base.OnAction(action);
    }
Пример #2
0
    private void ShowPrograms()
    {
      if (lblOnTvNow != null)
      {
        lblOnTvNow.EnableUpDown = false;
        lblOnTvNow.Clear();
      }
      if (lblOnTvNext != null)
      {
        lblOnTvNext.EnableUpDown = false;
        lblOnTvNext.Clear();
      }

      // Set recorder status
      if (imgRecIcon != null)
      {
        VirtualCard card;
        TvServer server = new TvServer();
        imgRecIcon.IsVisible = server.IsRecording(idChannel, out card);
      }

      if (lblCurrentChannel != null)
      {
        lblCurrentChannel.Label = channelName;
      }
      if (lblZapToCannelNo != null)
      {
        lblZapToCannelNo.Label = channelNr;
        lblZapToCannelNo.Visible = !string.IsNullOrEmpty(channelNr);
      }
      if (LastError != null)
      {
        if (LastError.Messages.Count > 0)
        {
          lblOnTvNow.Label = LastError.Messages[0]; // first line in "NOW"
          if (LastError.Messages.Count > 1)
          {
            lblOnTvNext.Label = String.Join(", ", LastError.Messages.ToArray(), 1, LastError.Messages.Count - 1);
            // 2nd and later in "NEXT"
          }
        }
        m_lastError = null; // reset member only, not the failing channel info in Navigator
      }
      else
      {
        Channel chan = TVHome.Navigator.GetChannel(idChannel, true);
        Program prog = chan.GetProgramAt(m_dateTime);
        if (prog != null)
        {
          string strTime = String.Format("{0}-{1}",
                                         prog.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                         prog.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

          if (lblCurrentTime != null)
          {
            lblCurrentTime.Label = strTime;
          }

          if (lblOnTvNow != null)
          {
            lblOnTvNow.Label = prog.Title;
          }
          if (lblStartTime != null)
          {
            strTime = String.Format("{0}", prog.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));
            lblStartTime.Label = strTime;
          }
          if (lblEndTime != null)
          {
            strTime = String.Format("{0} ", prog.EndTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));
            lblEndTime.Label = strTime;
          }

          // next program
          prog = chan.GetProgramAt(prog.EndTime.AddMinutes(1));
          //prog = TVHome.Navigator.GetChannel(channelName).GetProgramAt(prog.EndTime.AddMinutes(1));
          if (prog != null)
          {
            if (lblOnTvNext != null)
            {
              lblOnTvNext.Label = prog.Title;
            }
          }
        }
        else
        {
          lblOnTvNow.Label = GUILocalizeStrings.Get(736); // no epg for this channel

          if (lblStartTime != null)
          {
            lblStartTime.Label = String.Empty;
          }
          if (lblEndTime != null)
          {
            lblEndTime.Label = String.Empty;
          }
          if (lblCurrentTime != null)
          {
            lblCurrentTime.Label = String.Empty;
          }
        }
      }
      UpdateProgressBar();
    }