Exemplo n.º 1
0
        /// <summary>
        /// Initializes an instance of <see cref="Player"/>.
        /// </summary>
        /// <param name="widget">The widget to be played.</param>
        /// <param name="autoplay">Play on mount.</param>
        private void MountWidget(ITWidget widget, bool autoplay = true)
        {
            if (null != _widget)
            {
                this.UnmountWidget();
            }

            _widget = widget;

            // Set Events
            _widget.StateChanged += OnStateChanged;

            // Save initial position for Fixed widgets
            if (Position.Fixed == _widget.Position)
            {
                InputEngine.Instance.SaveSystemCursor();
            }

            // Launch Mount Event
            _widget.Mount();

            if (autoplay)
            {
                this.PlayWidget();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Unmounts the mounted <see cref="ITWidget"/>.
        /// </summary>
        private void UnmountWidget()
        {
            // Unset Events
            _widget.StateChanged -= OnStateChanged;

            _widget.UnMount();
            _widget = null;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Displays the <see cref="ITWidget"/> in the system <see cref="Console"/>.
        /// </summary>
        /// <param name="widget">The widget to be displayed.</param>
        private void DrawBasicWidget(ITWidget widget)
        {
            // New graphics
            var g = this.GetNewGraphics();

            // Draw widget
            widget.Draw(g);

            // Display on Console
            this.Display(g);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Mounts a <see cref="ITWidget"/> in the player.
 /// </summary>
 /// <param name="widget"></param>
 public static void Mount(ITWidget widget)
 {
     Instance.MountWidget(widget);
 }