using FasdDesktopUi.Basics;
using FasdDesktopUi.Pages.SettingsPage;
using FasdDesktopUi.Pages.SlimPage;
using System;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using static C4IT.Logging.cLogManager;

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

        #region MinimizeButton

        private void Minimize_Click(object sender)
        {
            if (sender is UIElement senderVisual)
                Window.GetWindow(senderVisual).WindowState = WindowState.Minimized;
        }

        private void MinimizeButton_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Minimize_Click(sender);
        }

        private void MinimizeButton_TouchDown(object sender, TouchEventArgs e)
        {
            Minimize_Click(sender);
        }

        #endregion

        #region WindowSizeButton

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

        private void WindowSizeButton_MouseUp(object sender, MouseButtonEventArgs e)
        {
            WindowSize_Click(sender);
        }

        private void WindowSizeButton_TouchDown(object sender, TouchEventArgs e)
        {
            WindowSize_Click(sender);
        }

        #endregion

        #region CloseButton

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

        private void CloseButton_MouseUp(object sender, MouseButtonEventArgs e)
        {
            CloseButton_Click(sender);
        }

        private void CloseButton_TouchDown(object sender, TouchEventArgs e)
        {
            CloseButton_Click(sender);
        }

        #endregion

        #region SlimPageButton

        private void SlimPageButton_Click()
        {
            App.HideAllSettingViews();
            Window.GetWindow(this).Hide();
            cSupportCaseDataProvider.slimPage?.Show();
        }
        private void SlimPageButton_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            SlimPageButton_Click();
        }

        private void SlimPageButton_TouchDown(object sender, TouchEventArgs e)
        {
            SlimPageButton_Click();
        }

        #endregion
    }
}
