using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using Telerik.Windows.Controls;
using XplorePlane.ViewModels;

namespace XplorePlane.Views
{
    /// <summary>
    /// MainWindowB.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindowB : RadRibbonWindow
    {
        private static readonly Brush ActiveBg = new SolidColorBrush(Color.FromRgb(0xF0, 0xA0, 0x30));

        public MainWindowB(MainViewModel viewModel)
        {
            InitializeComponent();
            DataContext = viewModel;
        }

        private void OnMotionTabClick(object sender, RoutedEventArgs e)
        {
            ShowPanel(motion: true);
        }

        private void OnDetectorTabClick(object sender, RoutedEventArgs e)
        {
            ShowPanel(detector: true);
        }

        private void OnImageTabClick(object sender, RoutedEventArgs e)
        {
            ShowPanel(image: true);
        }

        private void ShowPanel(bool motion = false, bool detector = false, bool image = false)
        {
            MotionPanel.Visibility = motion ? Visibility.Visible : Visibility.Collapsed;
            DetectorPanel.Visibility = detector ? Visibility.Visible : Visibility.Collapsed;
            ImagePanel.Visibility = image ? Visibility.Visible : Visibility.Collapsed;

            BtnMotion.IsChecked = motion;
            BtnMotion.Background = motion ? ActiveBg : Brushes.Transparent;

            BtnDetector.IsChecked = detector;
            BtnDetector.Background = detector ? ActiveBg : Brushes.Transparent;

            BtnImage.IsChecked = image;
            BtnImage.Background = image ? ActiveBg : Brushes.Transparent;
        }
    }
}
