public override void Save()
        {
            IScreenControl sc       = ServiceRegistration.Get <IScreenControl>();
            int            selected = Selected;

            sc.ApplicationSuspendLevel = selected > -1 && selected < _suspendLevels.Count ? _suspendLevels[selected] : SuspendLevel.None;
        }
        protected void CheckScreenSaver()
        {
            IWorkflowManager workflowManager = ServiceRegistration.Get <IWorkflowManager>();

            if (workflowManager.IsStateContainedInNavigationStack(Consts.WF_STATE_ID_PARTY_MUSIC_PLAYER))
            {
                if (DisableScreenSaver)
                {
                    if (_screenSaverController == null)
                    {
                        IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>();
                        _screenSaverController = screenControl.GetScreenSaverController();
                    }
                    if (_screenSaverController != null)
                    {
                        _screenSaverController.IsScreenSaverDisabled = true;
                    }
                }
            }
            else
            {
                if (_screenSaverController != null)
                {
                    _screenSaverController.Dispose();
                    _screenSaverController = null;
                }
            }
        }
Beispiel #3
0
        public override void Save()
        {
            IScreenControl sc = ServiceRegistration.Get <IScreenControl>();

            // The called methods will change the entry in the setting
            sc.SwitchMode(_yes ? ScreenMode.FullScreen : ScreenMode.NormalWindowed);
        }
        public bool StartListening()
        {
            IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>(false);

            _windowHandle = screenControl == null ? IntPtr.Zero : screenControl.MainWindowHandle;
            if (_windowHandle == IntPtr.Zero)
            {
                ServiceRegistration.Get <ILogger>().Warn("RemovableMediaTracker: No main window handle available, cannot start listening for removable media messages");
                return(false);
            }
            RemovableMediaTrackerSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <RemovableMediaTrackerSettings>();

            try
            {
                _deviceMonitor = new DeviceVolumeMonitor(_windowHandle);
                _deviceMonitor.MediaInserted += OnMediaInserted;
                _deviceMonitor.MediaRemoved  += OnMediaRemoved;
                _deviceMonitor.Enabled        = settings.TrackRemovableMedia;

                ServiceRegistration.Get <ILogger>().Info("RemovableMediaTracker: Monitoring system for removable media changes");
                return(true);
            }
            catch (DeviceVolumeMonitorException ex)
            {
                ServiceRegistration.Get <ILogger>().Error("RemovableMediaTracker: Error enabling RemovableMediaTracker service", ex);
            }
            return(false);
        }
Beispiel #5
0
        /// <summary>
        /// Adds the DVDNavigator filter to the graph and sets the input path.
        /// </summary>
        protected override void AddSourceFilter()
        {
            ServiceRegistration.Get <ILogger>().Debug("DvdPlayer.AddSourceFilter");
            _pendingCmd = true;

            _dvdbasefilter = (IBaseFilter) new DVDNavigator();

            if (_dvdbasefilter == null)
            {
                throw new Exception("Failed to add DVD Navigator!");
            }

            _graphBuilder.AddFilter(_dvdbasefilter, DVD_NAVIGATOR);

            _dvdInfo = _dvdbasefilter as IDvdInfo2;
            if (_dvdInfo == null)
            {
                throw new Exception("Failed to get IDvdInfo2 from DVDNavigator!");
            }

            _dvdCtrl = _dvdbasefilter as IDvdControl2;

            if (_dvdCtrl == null)
            {
                throw new Exception("Failed to get IDvdControl2 from DVDNavigator!");
            }

            if (!IsLocalFilesystemResource)
            {
                throw new IllegalCallException("The DVDPlayer can only play local file system resources");
            }
            using (((ILocalFsResourceAccessor)_resourceAccessor).EnsureLocalFileSystemAccess())
            {
                string path = ((ILocalFsResourceAccessor)_resourceAccessor).LocalFileSystemPath;

                // check if path is a drive root (like D:), otherwise append VIDEO_TS
                // MediaItem always contains the parent folder. Add the required VIDEO_TS subfolder.
                if (!String.IsNullOrEmpty(path) && !path.EndsWith(Path.VolumeSeparatorChar.ToString()))
                {
                    path = Path.Combine(path, "VIDEO_TS");
                }

                int hr = _dvdCtrl.SetDVDDirectory(path);
                if (hr != 0)
                {
                    throw new Exception("Failed to set DVD directory!");
                }
            }
            _dvdCtrl.SetOption(DvdOptionFlag.HMSFTimeCodeEvents, true); // use new HMSF timecode format
            _dvdCtrl.SetOption(DvdOptionFlag.ResetOnStop, false);

            _mediaEvt = _graphBuilder as IMediaEventEx;
            if (_mediaEvt != null)
            {
                IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>();
                _mediaEvt.SetNotifyWindow(screenControl.MainWindowHandle, WM_DVD_EVENT, _instancePtr);
            }

            SetDefaultLanguages();
        }
        public void Stop()
        {
            IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>();

            screenControl.VideoPlayerSynchronizationStrategy.SynchronizeToVideoPlayerFramerate -= SyncToPlayer;
            _isEnabled = false;
        }
Beispiel #7
0
        public override void Save()
        {
            base.Save();
            IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>();

            screenControl.ConfigureScreenSaver(_yes, screenControl.ScreenSaverTimeoutMin); // The setting will be written by the screen control class
        }
Beispiel #8
0
        protected static void RegisterGlobalKeyBindings()
        {
            IInputManager inputManager = ServiceRegistration.Get <IInputManager>();

            inputManager.AddKeyBinding(Key.Escape, () =>
            {
                // Close dialog or switch to previous workflow state
                IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();
                if (screenManager.IsDialogVisible)
                {
                    screenManager.CloseTopmostDialog();
                }
                else
                {
                    ServiceRegistration.Get <IWorkflowManager>().NavigatePop(1);
                }
            });
            inputManager.AddKeyBinding(Key.Fullscreen, () =>
            {
                //switch to fullscreen
                IScreenControl sc  = ServiceRegistration.Get <IScreenControl>();
                int nextMode       = ((int)sc.CurrentScreenMode) + 1;
                int totalModes     = Enum.GetNames(typeof(ScreenMode)).Length;
                ScreenMode newMode = (ScreenMode)(nextMode % totalModes);
                ServiceRegistration.Get <ILogger>().Info("SkinEngine: Switching screen mode from current '{0}' to '{1}'", sc.CurrentScreenMode, newMode);
                sc.SwitchMode(newMode);
            });
        }
Beispiel #9
0
        protected override void Update()
        {
            IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>();
            IInputManager  inputManager  = ServiceRegistration.Get <IInputManager>();

            IsScreenSaverActive = screenControl.IsScreenSaverActive;
            IsMouseUsed         = inputManager.IsMouseUsed;
        }
        public override void Save()
        {
            base.Save();
            IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>();

            screenControl.ConfigureScreenSaver(screenControl.IsScreenSaverEnabled, _value);
            // The setting will be written by the screen control class
        }
        public override void Load()
        {
            _type       = NumberType.FloatingPoint;
            _step       = 0.5;
            _lowerLimit = 0.5;
            _upperLimit = 120;
            IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>();

            _value = screenControl.ScreenSaverTimeoutMin;
        }
Beispiel #12
0
 public SynchronizationStrategy(double targetFps, SynchronizationType synchronizationType)
 {
     _targetFps           = targetFps;
     _secondsPerFrame     = 1d / targetFps;
     _synchronizationType = synchronizationType;
     if (_synchronizationType == SynchronizationType.VSync)
     {
         IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>();
         screenControl.VideoPlayerSynchronizationStrategy.SynchronizeToVideoPlayerFramerate += SyncToPlayer;
     }
 }
Beispiel #13
0
        public void Stop()
        {
            if (_synchronizationType != SynchronizationType.VSync)
            {
                return;
            }

            IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>();

            screenControl.VideoPlayerSynchronizationStrategy.SynchronizeToVideoPlayerFramerate -= SyncToPlayer;
            ResetVSyncStrategy();
        }
Beispiel #14
0
        public void StartBackgroundPlayback()
        {
            if (!IsEnabled)
            {
                return;
            }

            IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>();
            IVideoPlayerSynchronizationStrategy current = screenControl.VideoPlayerSynchronizationStrategy;

            if (current != _backgroundPlayerStrategy)
            {
                // We replace the default strategy with our own to prefer the video background player.
                screenControl.VideoPlayerSynchronizationStrategy = _backgroundPlayerStrategy;
            }

            IPlayerManager playerManager = ServiceRegistration.Get <IPlayerManager>();

            if (_backgroundPsc == null)
            {
                _backgroundPsc = playerManager.OpenSlot();
            }

            if (_backgroundPsc == null)
            {
                return;
            }

            // If we already have a player active, don't start a new one.
            IPlayer currentPlayer = _backgroundPsc.CurrentPlayer;

            if (currentPlayer != null && currentPlayer.State == PlayerState.Active)
            {
                return;
            }

            try
            {
                _backgroundPsc.Play(_video, StartTime.AtOnce);
                BaseDXPlayer player = _backgroundPsc.CurrentPlayer as BaseDXPlayer;
                if (player != null)
                {
                    player.AutoRepeat = true;
                }

                VideoPlayer = player as ISharpDXVideoPlayer;
            }
            catch (Exception ex)
            {
                ServiceRegistration.Get <ILogger>().Error("VideoBackgroundModel: Error opening MediaItem {0} for background playback!", ex, _videoFilename);
            }
        }
        private void ActivateWhenReady(object sender, ElapsedEventArgs e)
        {
            IScreenControl screenControl = ServiceRegistration.Get <IScreenControl>(false);

            if (screenControl == null || screenControl.VideoPlayerSynchronizationStrategy == null)
            {
                return;
            }

            _timer.Close();
            _timer = null;

            screenControl.VideoPlayerSynchronizationStrategy.SynchronizeToVideoPlayerFramerate += SyncToPlayer;
            _isEnabled = true;
        }
Beispiel #16
0
        private static void ThreadProc()
        {
            while (_screenControl == null)
            {
                try
                {
                    if (ServiceRegistration.IsRegistered <IScreenControl>())
                    {
                        _screenControl = ServiceRegistration.Get <IScreenControl>();

                        _rawInput = new RawInputHandler(_screenControl.MainWindowHandle, CAPTURE_ONLY_IN_FOREGROUND);
                        _rawInput.AddMessageFilter(); // Adding a message filter will cause keypresses to be handled
                        _rawInput.KeyPressed += OnKeyPressed;
                    }
                }
                catch
                {
                    // ignored
                }
                Thread.Sleep(500);
            }
        }
Beispiel #17
0
        protected static void RegisterGlobalKeyBindings()
        {
            IInputManager inputManager = ServiceRegistration.Get <IInputManager>();

            inputManager.AddKeyBinding(Key.Escape, () =>
            {
                // Close dialog or switch to previous workflow state
                IScreenManager screenManager = ServiceRegistration.Get <IScreenManager>();
                if (screenManager.IsDialogVisible)
                {
                    screenManager.CloseTopmostDialog();
                }
                else
                {
                    ServiceRegistration.Get <IWorkflowManager>().NavigatePop(1);
                }
            });
            inputManager.AddKeyBinding(Key.Fullscreen, () =>
            {
                //switch to fullscreen
                IScreenControl sc = ServiceRegistration.Get <IScreenControl>();
                sc.SwitchMode(sc.IsFullScreen ? ScreenMode.NormalWindowed : ScreenMode.FullScreen);
            });
        }
Beispiel #18
0
 /// <summary>
 /// プロパティグリッドに表示するプロパティを設定する
 /// </summary>
 /// <param name="control"></param>
 public void SetProperty(IScreenControl control)
 {
     m_activeControl = control;
     typePropetyGrid.SelectedObject = m_activeControl.GetPropertyParam();
 }
Beispiel #19
0
        private void monitorScreensaverState()
        {
            Log.Debug("Started monitoring screensaver state");

            Boolean        LEDsDisabledByScreensaver = false;
            IScreenControl screenControl             = ServiceRegistration.Get <IScreenControl>();

            while (settings.MonitorScreensaverState)
            {
                try
                {
                    Boolean IsScreenSaverActive = screenControl.IsScreenSaverActive;

                    // Check for screensaver window
                    if (IsScreenSaverActive)
                    {
                        ContentEffect currenContentEffect = coreObject.GetCurrentEffect();

                        if (currenContentEffect == ContentEffect.MediaPortalLiveMode ||
                            currenContentEffect == ContentEffect.ExternalLiveMode || currenContentEffect == ContentEffect.Undefined)
                        {
                            coreObject.ChangeEffect(ContentEffect.LEDsDisabled);
                            LEDsDisabledByScreensaver = true;
                            Log.Debug("LEDs should be deactivated. (Screensaver detected)");
                        }
                    }
                    // Restore last known effect when coming back from screensaver
                    else if (LEDsDisabledByScreensaver)
                    {
                        LEDsDisabledByScreensaver = false;

                        ContentEffect effect;
                        if (ServiceRegistration.Get <IPlayerContextManager>().IsVideoContextActive)
                        {
                            effect = settings.VideoEffect;
                        }
                        else if (ServiceRegistration.Get <IPlayerContextManager>().IsAudioContextActive)
                        {
                            effect = settings.AudioEffect;
                        }
                        else
                        {
                            effect = settings.MenuEffect;
                        }

                        coreObject.ChangeEffect(effect);
                        CalculateDelay();

                        Log.Debug("LEDs should be activated again. (Screensaver no longer active)");
                    }

                    // Sleep for 5 seconds
                    int sleepTime = (int)TimeSpan.FromSeconds(5).TotalMilliseconds;
                    Thread.Sleep(sleepTime);
                }
                catch (Exception ex)
                {
                    // No logging as it could spam the logs

                    //Log.Error("Error in AtmolightPlugin_monitorScreensaverState.");
                    //Log.Error("Exception: {0}", ex.Message);

                    // Sleep for 5 seconds
                    int sleepTime = (int)TimeSpan.FromSeconds(5).TotalMilliseconds;
                    Thread.Sleep(sleepTime);
                }
            }
        }
        protected void SetScreenMode(ScreenMode mode)
        {
            IScreenControl sc = ServiceRegistration.Get <IScreenControl>();

            sc.SwitchMode(mode);
        }