using System.Linq;
using JetBrains.Annotations;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.Stylesheets;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Console;
using Robust.Shared.IoC;
using Robust.Shared.Localization;

namespace Robust.Client.UserInterface
{
    [GenerateTypedNameReferences]
    public sealed partial class DevWindow : Control
    {
        public DevWindow()
        {
            InitializeComponent();
        }

        private void InitializeComponent()
        {
            RobustXamlLoader.Load(this);

            TabContainer.SetTabTitle(DebugConsole, "Debug Console");
            TabContainer.SetTabTitle(UI, "User Interface");
            TabContainer.SetTabTitle(Perf, "Profiling");
            TabContainer.SetTabTitle(Textures, Loc.GetString("dev-window-tab-textures-title"));
            TabContainer.SetTabTitle(RenderTargets, Loc.GetString("dev-window-tab-render-targets-title"));

            Stylesheet =
                new DefaultStylesheet(IoCManager.Resolve<IResourceCache>(), IoCManager.Resolve<IUserInterfaceManager>()).Stylesheet;
        }
    }

    [UsedImplicitly]
    internal sealed class TestWindowCommand : LocalizedCommands
    {
        public override string Command => "devwindow";

        public override void Execute(IConsoleShell shell, string argStr, string[] args)
        {
            var window = new OSWindow
            {
                Title = "Robust Debug Window",
            };
            var control = new DevWindow();
            window.AddChild(control);

            window.Show();
        }
    }
}
