/// <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(); } }
/// <summary> /// Unmounts the mounted <see cref="ITWidget"/>. /// </summary> private void UnmountWidget() { // Unset Events _widget.StateChanged -= OnStateChanged; _widget.UnMount(); _widget = null; }
/// <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); }
/// <summary> /// Mounts a <see cref="ITWidget"/> in the player. /// </summary> /// <param name="widget"></param> public static void Mount(ITWidget widget) { Instance.MountWidget(widget); }