Exemplo n.º 1
0
/*
 *              private static void ProcessTransaction<T>(string methodName)
 *              {
 *                      var client = new PlayerCommandResultClient();
 *
 *                      using (var scope = new TransactionScope(TransactionScopeOption.Required))
 *                      {
 *                              var result = InvokeFunction<T>(methodName);
 *
 *                              client.SendResult(result);
 *
 *                              scope.Complete();
 *                      }
 *              }
 */

        private static void InvokeAction(string methodName, DispatcherPriority priority = DispatcherPriority.Normal)
        {
            try
            {
                App.WriteLog($"Request received: {methodName}");

                var facility = PlayerServiceManager.GetActiveFacility();

                if (!(facility is IPlayerCommandProcessor))
                {
                    return;
                }

                var method = typeof(IPlayerCommandProcessor).GetMethod(methodName);

                if (method == null)
                {
                    return;
                }

                facility.WindowDispatcher?.BeginInvoke(new Action(((IPlayerCommandProcessor)facility).ShowRoot));

                var action = (Action)Delegate.CreateDelegate(typeof(Action), facility, method);

                facility.WindowDispatcher?.Invoke(action, priority);
            }
            catch (Exception ex)
            {
                App.WriteLog(ex);
            }
        }
Exemplo n.º 2
0
        public void Suspend()
        {
            var window = PlayerServiceManager.GetActiveFacility();

            if (window is IPlayerCommandProcessor)
            {
                window.WindowDispatcher.Invoke(((IPlayerCommandProcessor)window).Suspend);
            }
        }
Exemplo n.º 3
0
        void IRemoteVideoPlayerService.SelectMovie()
        {
            var window = PlayerServiceManager.GetActiveFacility();

            if (window is IListBoxWindow)
            {
                return;
            }

            InvokeAction(nameof(IPlayerCommandProcessor.SelectMovie));
        }
Exemplo n.º 4
0
        void IRemoteVideoPlayerService.CloseApp()
        {
            try
            {
                var window = PlayerServiceManager.GetActiveFacility();

                window.WindowDispatcher.Invoke(((Window)window).Close);
            }
            catch (Exception ex)
            {
                App.WriteLog(ex);
            }
        }
Exemplo n.º 5
0
        public void LevelUp()
        {
            var window = PlayerServiceManager.GetActiveFacility();

            if (window is IListBoxWindow)
            {
                window.WindowDispatcher.Invoke(((IListBoxWindow)window).LevelUp);
            }

            if (window is IPlayerCommandProcessor)
            {
                InvokeAction(nameof(IPlayerCommandProcessor.SelectMovie));
            }
        }
Exemplo n.º 6
0
        public void PageUp()
        {
            try
            {
                var window = PlayerServiceManager.GetActiveFacility();

                if (window is IListBoxWindow)
                {
                    window.WindowDispatcher.Invoke(((IListBoxWindow)window).PageUp);
                }

                App.WriteLog($"{nameof(IRemoteVideoPlayerService.PageUp)}: done");
            }
            catch (Exception ex)
            {
                App.WriteLog(ex);
            }
        }
Exemplo n.º 7
0
        void IRemoteVideoPlayerService.Previous()
        {
            try
            {
                var window = PlayerServiceManager.GetActiveFacility();

                if (window is IPlayerCommandProcessor)
                {
                    InvokeAction(nameof(IPlayerCommandProcessor.Previous));
                    return;
                }

                if (window is IListBoxWindow)
                {
                    window.WindowDispatcher.Invoke(((IListBoxWindow)window).Previous);
                }

                App.WriteLog($"{nameof(IRemoteVideoPlayerService.Previous)}: done");
            }
            catch (Exception ex)
            {
                App.WriteLog(ex);
            }
        }