Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DispatcherTimer"/> class.
 /// </summary>
 /// <param name="interval">The interval at which to tick.</param>
 /// <param name="priority">The priority to use.</param>
 /// <param name="dispatcher">The dispatcher to use.</param>
 /// <param name="callback">The event to call when the timer ticks.</param>
 public DispatcherTimer(TimeSpan interval, DispatcherPriority priority, EventHandler callback, Dispatcher dispatcher)
 {
     this.priority = priority;
     this.Dispatcher = dispatcher;
     this.Interval = interval;
     this.Tick += callback;
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DispatcherTimer"/> class.
 /// </summary>
 /// <param name="interval">The interval at which to tick.</param>
 /// <param name="priority">The priority to use.</param>
 /// <param name="dispatcher">The dispatcher to use.</param>
 /// <param name="callback">The event to call when the timer ticks.</param>
 public DispatcherTimer(TimeSpan interval, DispatcherPriority priority, EventHandler callback, Dispatcher dispatcher)
 {
     _priority = priority;
     Dispatcher = dispatcher;
     Interval = interval;
     Tick += callback;
 }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DispatcherTimer"/> class.
 /// </summary>
 /// <param name="priority">The priority to use.</param>
 /// <param name="dispatcher">The dispatcher to use.</param>
 public DispatcherTimer(DispatcherPriority priority, Dispatcher dispatcher)
 {
     this.priority = priority;
     this.Dispatcher = dispatcher;
 }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TopLevel"/> class.
        /// </summary>
        /// <param name="impl">The platform-specific window implementation.</param>
        /// <param name="dependencyResolver">
        /// The dependency resolver to use. If null the default dependency resolver will be used.
        /// </param>
        public TopLevel(ITopLevelImpl impl, IDependencyResolver dependencyResolver)
        {
            dependencyResolver = dependencyResolver ?? Locator.Current;

            IPlatformRenderInterface renderInterface = dependencyResolver.GetService<IPlatformRenderInterface>();

            this.PlatformImpl = impl;
            this.accessKeyHandler = dependencyResolver.GetService<IAccessKeyHandler>();
            this.inputManager = dependencyResolver.GetService<IInputManager>();
            this.keyboardNavigationHandler = dependencyResolver.GetService<IKeyboardNavigationHandler>();
            this.LayoutManager = dependencyResolver.GetService<ILayoutManager>();
            this.renderManager = dependencyResolver.GetService<IRenderManager>();

            if (renderInterface == null)
            {
                throw new InvalidOperationException(
                    "Could not create an interface to the rendering subsystem: maybe no rendering subsystem was initialized?");
            }

            if (this.PlatformImpl == null)
            {
                throw new InvalidOperationException(
                    "Could not create window implementation: maybe no windowing subsystem was initialized?");
            }

            if (this.inputManager == null)
            {
                throw new InvalidOperationException(
                    "Could not create input manager: maybe Application.RegisterServices() wasn't called?");
            }

            if (this.LayoutManager == null)
            {
                throw new InvalidOperationException(
                    "Could not create layout manager: maybe Application.RegisterServices() wasn't called?");
            }

            if (this.renderManager == null)
            {
                throw new InvalidOperationException(
                    "Could not create render manager: maybe Application.RegisterServices() wasn't called?");
            }

            if (this.accessKeyHandler != null)
            {
                this.accessKeyHandler.SetOwner(this);
            }

            if (this.keyboardNavigationHandler != null)
            {
                this.keyboardNavigationHandler.SetOwner(this);
            }

            this.PlatformImpl.SetOwner(this);
            this.PlatformImpl.Activated = this.HandleActivated;
            this.PlatformImpl.Deactivated = this.HandleDeactivated;
            this.PlatformImpl.Closed = this.HandleClosed;
            this.PlatformImpl.Input = this.HandleInput;
            this.PlatformImpl.Paint = this.HandlePaint;
            this.PlatformImpl.Resized = this.HandleResized;

            Size clientSize = this.ClientSize = this.PlatformImpl.ClientSize;

            this.dispatcher = Dispatcher.UIThread;
            this.renderer = renderInterface.CreateRenderer(this.PlatformImpl.Handle, clientSize.Width, clientSize.Height);

            this.LayoutManager.Root = this;
            this.LayoutManager.LayoutNeeded.Subscribe(_ => this.HandleLayoutNeeded());
            this.LayoutManager.LayoutCompleted.Subscribe(_ => this.HandleLayoutCompleted());
            this.renderManager.RenderNeeded.Subscribe(_ => this.HandleRenderNeeded());

            IStyler styler = dependencyResolver.GetService<IStyler>();
            styler.ApplyStyles(this);

            this.GetObservable(ClientSizeProperty).Skip(1).Subscribe(x => this.PlatformImpl.ClientSize = x);
        }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DispatcherTimer"/> class.
 /// </summary>
 /// <param name="priority">The priority to use.</param>
 /// <param name="dispatcher">The dispatcher to use.</param>
 public DispatcherTimer(DispatcherPriority priority, Dispatcher dispatcher)
 {
     _priority = priority;
     Dispatcher = dispatcher;
 }