using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

using FasdDesktopUi.Basics.UiActions;

namespace FasdDesktopUi.Pages.DetailsPage.UserControls
{
    public partial class DetailsPageWindowStateBar : UserControl
    {
        public DetailsPageWindowStateBar()
        {
            InitializeComponent();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            if (cFasdCockpitConfig.Instance?.ShowRawHealthcardValues == true)
                RawValuesButton.Visibility = Visibility.Visible;
            else
                RawValuesButton.Visibility = Visibility.Collapsed;
        }

        private void MinimizeButton_Click(object sender, InputEventArgs e)
        {
            if (sender is UIElement senderVisual)
                Window.GetWindow(senderVisual).WindowState = WindowState.Minimized;
        }

        private void WindowSizeButton_Click(object sender, InputEventArgs e)
        {
            if (sender is UIElement senderVisual)
                Window.GetWindow(senderVisual).WindowState = Window.GetWindow(senderVisual).WindowState == WindowState.Maximized ? WindowState.Normal : WindowState.Maximized;
        }

        private void CloseButton_Click(object sender, InputEventArgs e)
        {
            if (sender is UIElement senderVisual)
                Window.GetWindow(senderVisual).Close();
        }

        private void RawValuesButton_Click(object sender, InputEventArgs e)
        {
            cUiActionBase.RaiseEvent(new UiShowRawHealthcardValues(), this, this);
        }

    }
}
