Example #1
0
 public TestServices With(
     IAssetLoader assetLoader                      = null,
     IFocusManager focusManager                    = null,
     IInputManager inputManager                    = null,
     Func <IKeyboardDevice> keyboardDevice         = null,
     IKeyboardNavigationHandler keyboardNavigation = null,
     Func <IMouseDevice> mouseDevice               = null,
     IRuntimePlatform platform                     = null,
     IPlatformRenderInterface renderInterface      = null,
     IRenderTimer renderLoop = null,
     IScheduler scheduler    = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler      = null,
     Func <Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null)
 {
     return(new TestServices(
                assetLoader: assetLoader ?? AssetLoader,
                focusManager: focusManager ?? FocusManager,
                inputManager: inputManager ?? InputManager,
                keyboardDevice: keyboardDevice ?? KeyboardDevice,
                keyboardNavigation: keyboardNavigation ?? KeyboardNavigation,
                mouseDevice: mouseDevice ?? MouseDevice,
                platform: platform ?? Platform,
                renderInterface: renderInterface ?? RenderInterface,
                scheduler: scheduler ?? Scheduler,
                standardCursorFactory: standardCursorFactory ?? StandardCursorFactory,
                styler: styler ?? Styler,
                theme: theme ?? Theme,
                threadingInterface: threadingInterface ?? ThreadingInterface,
                windowingPlatform: windowingPlatform ?? WindowingPlatform,
                windowImpl: windowImpl ?? WindowImpl));
 }
Example #2
0
 public TestServices(
     IAssetLoader assetLoader                     = null,
     IFocusManager focusManager                   = null,
     IInputManager inputManager                   = null,
     Func <IKeyboardDevice> keyboardDevice        = null,
     ILayoutManager layoutManager                 = null,
     IRuntimePlatform platform                    = null,
     IPlatformRenderInterface renderInterface     = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler      = null,
     Func <Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null)
 {
     AssetLoader           = assetLoader;
     FocusManager          = focusManager;
     InputManager          = inputManager;
     KeyboardDevice        = keyboardDevice;
     LayoutManager         = layoutManager;
     Platform              = platform;
     RenderInterface       = renderInterface;
     StandardCursorFactory = standardCursorFactory;
     Styler             = styler;
     Theme              = theme;
     ThreadingInterface = threadingInterface;
     WindowImpl         = windowImpl;
     WindowingPlatform  = windowingPlatform;
 }
Example #3
0
 public TestServices(
     IAssetLoader assetLoader                     = null,
     IInputManager inputManager                   = null,
     ILayoutManager layoutManager                 = null,
     IPclPlatformWrapper platformWrapper          = null,
     IPlatformRenderInterface renderInterface     = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler      = null,
     Func <Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null)
 {
     AssetLoader           = assetLoader;
     InputManager          = inputManager;
     LayoutManager         = layoutManager;
     PlatformWrapper       = platformWrapper;
     RenderInterface       = renderInterface;
     StandardCursorFactory = standardCursorFactory;
     Styler             = styler;
     Theme              = theme;
     ThreadingInterface = threadingInterface;
     WindowImpl         = windowImpl;
     WindowingPlatform  = windowingPlatform;
 }
Example #4
0
 public TestServices(
     IAssetLoader assetLoader = null,
     IFocusManager focusManager = null,
     IInputManager inputManager = null,
     Func<IKeyboardDevice> keyboardDevice = null,
     ILayoutManager layoutManager = null,
     IPclPlatformWrapper platformWrapper = null,
     IPlatformRenderInterface renderInterface = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler = null,
     Func<Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null)
 {
     AssetLoader = assetLoader;
     FocusManager = focusManager;
     InputManager = inputManager;
     KeyboardDevice = keyboardDevice;
     LayoutManager = layoutManager;
     PlatformWrapper = platformWrapper;
     RenderInterface = renderInterface;
     StandardCursorFactory = standardCursorFactory;
     Styler = styler;
     Theme = theme;
     ThreadingInterface = threadingInterface;
     WindowImpl = windowImpl;
     WindowingPlatform = windowingPlatform;
 }
Example #5
0
 public TestServices(
     IAssetLoader assetLoader                            = null,
     IFocusManager focusManager                          = null,
     IInputManager inputManager                          = null,
     Func <IKeyboardDevice> keyboardDevice               = null,
     IKeyboardNavigationHandler keyboardNavigation       = null,
     ILayoutManager layoutManager                        = null,
     IRuntimePlatform platform                           = null,
     Func <IRenderRoot, IRenderLoop, IRenderer> renderer = null,
     IPlatformRenderInterface renderInterface            = null,
     IRenderLoop renderLoop = null,
     IScheduler scheduler   = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler      = null,
     Func <Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowingPlatform windowingPlatform           = null)
 {
     AssetLoader           = assetLoader;
     FocusManager          = focusManager;
     InputManager          = inputManager;
     KeyboardDevice        = keyboardDevice;
     KeyboardNavigation    = keyboardNavigation;
     LayoutManager         = layoutManager;
     Platform              = platform;
     Renderer              = renderer;
     RenderInterface       = renderInterface;
     RenderLoop            = renderLoop;
     Scheduler             = scheduler;
     StandardCursorFactory = standardCursorFactory;
     Styler             = styler;
     Theme              = theme;
     ThreadingInterface = threadingInterface;
     WindowingPlatform  = windowingPlatform;
 }
Example #6
0
 public void Start()
 {
     if (!this.IsEnabled)
     {
         IPlatformThreadingInterface threading = Locator.Current.GetService <IPlatformThreadingInterface>();
         this.timer = threading.StartTimer(this.Interval, this.InternalTick);
     }
 }
Example #7
0
 /// <summary>
 /// Starts the timer.
 /// </summary>
 public void Start()
 {
     if (!IsEnabled)
     {
         IPlatformThreadingInterface threading = PerspexLocator.Current.GetService <IPlatformThreadingInterface>();
         _timer = threading.StartTimer(Interval, InternalTick);
     }
 }
        /// <summary>
        /// Provides the implementation of starting the timer.
        /// </summary>
        /// <param name="tick">The method to call on each tick.</param>
        /// <remarks>
        /// This can be overridden by platform implementations to use a specialized timer
        /// implementation.
        /// </remarks>
        protected virtual IDisposable StartCore(Action tick)
        {
            if (_threading == null)
            {
                _threading = AvaloniaLocator.Current.GetService <IPlatformThreadingInterface>();
            }

            return(_threading.StartTimer(TimeSpan.FromSeconds(1.0 / FramesPerSecond), tick));
        }
        /// <summary>
        /// Provides the implementation of starting the timer.
        /// </summary>
        /// <param name="tick">The method to call on each tick.</param>
        /// <remarks>
        /// This can be overridden by platform implementations to use a specialized timer
        /// implementation.
        /// </remarks>
        protected virtual IDisposable StartCore(Action tick)
        {
            if (_threading == null)
            {
                _threading = AvaloniaLocator.Current.GetService<IPlatformThreadingInterface>();
            }

            return _threading.StartTimer(TimeSpan.FromSeconds(1.0 / FramesPerSecond), tick);
        }
Example #10
0
 public void Stop()
 {
     if (this.IsEnabled)
     {
         IPlatformThreadingInterface threading = Locator.Current.GetService <IPlatformThreadingInterface>();
         threading.KillTimer(this.timerHandle);
         this.timerHandle = null;
     }
 }
Example #11
0
 public Dispatcher(IPlatformThreadingInterface platform)
 {
     _platform = platform;
     if(_platform == null)
         //TODO: Unit test mode, fix that somehow
         return;
     _jobRunner = new JobRunner(platform);
     _platform.Signaled += _jobRunner.RunJobs;
 }
Example #12
0
 /// <summary>
 /// Stops the timer.
 /// </summary>
 public void Stop()
 {
     if (IsEnabled)
     {
         IPlatformThreadingInterface threading = PerspexLocator.Current.GetService <IPlatformThreadingInterface>();
         _timer.Dispose();
         _timer = null;
     }
 }
Example #13
0
        /// <summary>
        /// Starts the timer.
        /// </summary>
        public void Start()
        {
            if (!IsEnabled)
            {
                IPlatformThreadingInterface threading = AvaloniaLocator.Current.GetService <IPlatformThreadingInterface>();

                if (threading == null)
                {
                    throw new Exception("Could not start timer: IPlatformThreadingInterface is not registered.");
                }

                _timer = threading.StartTimer(Interval, InternalTick);
            }
        }
Example #14
0
        ///// <summary>
        ///// Allows unit tests to change the platform threading interface.
        ///// </summary>
        internal void UpdateServices()
        {
            if (_platform != null)
            {
                _platform.Signaled -= _jobRunner.RunJobs;
            }

            _platform = AvaloniaGlobals.PlatformThreadingInterface;
            _jobRunner.UpdateServices();

            if (_platform != null)
            {
                _platform.Signaled += _jobRunner.RunJobs;
            }
        }
 public TestServices(
     IAssetLoader assetLoader                      = null,
     IFocusManager focusManager                    = null,
     IInputManager inputManager                    = null,
     Func <IKeyboardDevice> keyboardDevice         = null,
     IKeyboardNavigationHandler keyboardNavigation = null,
     ILayoutManager layoutManager                  = null,
     Func <IMouseDevice> mouseDevice               = null,
     IRuntimePlatform platform                     = null,
     IPlatformRenderInterface renderInterface      = null,
     IRenderLoop renderLoop = null,
     IScheduler scheduler   = null,
     ICursorFactory standardCursorFactory = null,
     IStyler styler      = null,
     Func <Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null,
     PlatformHotkeyConfiguration platformHotkeyConfiguration = null,
     IFontManagerImpl fontManagerImpl     = null,
     IFormattedTextImpl formattedTextImpl = null)
 {
     AssetLoader           = assetLoader;
     FocusManager          = focusManager;
     InputManager          = inputManager;
     KeyboardDevice        = keyboardDevice;
     KeyboardNavigation    = keyboardNavigation;
     LayoutManager         = layoutManager;
     MouseDevice           = mouseDevice;
     Platform              = platform;
     RenderInterface       = renderInterface;
     Scheduler             = scheduler;
     StandardCursorFactory = standardCursorFactory;
     Styler                      = styler;
     Theme                       = theme;
     ThreadingInterface          = threadingInterface;
     WindowImpl                  = windowImpl;
     WindowingPlatform           = windowingPlatform;
     PlatformHotkeyConfiguration = platformHotkeyConfiguration;
     FontManagerImpl             = fontManagerImpl;
     FormattedTextImpl           = formattedTextImpl;
 }
Example #16
0
 /// <summary>
 /// Initializes static members of the <see cref="MainLoop"/> class.
 /// </summary>
 static MainLoop()
 {
     s_platform = Locator.Current.GetService<IPlatformThreadingInterface>();
 }
Example #17
0
 public JobRunner(IPlatformThreadingInterface platform)
 {
     _platform = platform;
 }
Example #18
0
 /// <summary>
 /// Initializes static members of the <see cref="MainLoop"/> class.
 /// </summary>
 static MainLoop()
 {
     s_platform = Locator.Current.GetService <IPlatformThreadingInterface>();
 }
Example #19
0
 public TestServices With(
     IAssetLoader assetLoader = null,
     IFocusManager focusManager = null,
     IInputManager inputManager = null,
     Func<IKeyboardDevice> keyboardDevice = null,
     ILayoutManager layoutManager = null,
     IPclPlatformWrapper platformWrapper = null,
     IPlatformRenderInterface renderInterface = null,
     IStandardCursorFactory standardCursorFactory = null,
     IStyler styler = null,
     Func<Styles> theme = null,
     IPlatformThreadingInterface threadingInterface = null,
     IWindowImpl windowImpl = null,
     IWindowingPlatform windowingPlatform = null)
 {
     return new TestServices(
         assetLoader: assetLoader ?? AssetLoader,
         focusManager: focusManager ?? FocusManager,
         inputManager: inputManager ?? InputManager,
         keyboardDevice: keyboardDevice ?? KeyboardDevice,
         layoutManager: layoutManager ?? LayoutManager,
         platformWrapper: platformWrapper ?? PlatformWrapper,
         renderInterface: renderInterface ?? RenderInterface,
         standardCursorFactory: standardCursorFactory ?? StandardCursorFactory,
         styler: styler ?? Styler,
         theme: theme ?? Theme,
         threadingInterface: threadingInterface ?? ThreadingInterface,
         windowImpl: windowImpl ?? WindowImpl,
         windowingPlatform: windowingPlatform ?? WindowingPlatform);
 }
Example #20
0
 internal void UpdateServices()
 {
     _platform = AvaloniaGlobals.PlatformThreadingInterface;
 }
Example #21
0
 public JobRunner(IPlatformThreadingInterface platform)
 {
     _platform = platform;
 }
Example #22
0
 /// <summary>
 /// Allows unit tests to change the platform threading interface.
 /// </summary>
 internal void UpdateServices()
 {
     _platform = AvaloniaLocator.Current.GetService <IPlatformThreadingInterface>();
 }