using System.Diagnostics;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using OpenSEMI.ClientBase;
using OpenSEMI.Ctrlib.Controls;
using CyberX8_Core;

namespace CyberX8_Themes.UserControls
{
    /// <summary>
    /// FOUPFrontView.xaml 的交互逻辑
    /// </summary>
    public partial class FOUPFrontView : UserControl
    {
        public FOUPFrontView()
        {
            InitializeComponent();
        }
        #region UnitData (DependencyProperty)
        public ModuleInfo UnitData
        {
            get { return (ModuleInfo)GetValue(UnitDataProperty); }
            set { SetValue(UnitDataProperty, value); }
        }
        public static readonly DependencyProperty UnitDataProperty =
            DependencyProperty.Register("UnitData", typeof(ModuleInfo), typeof(FOUPFrontView), new UIPropertyMetadata(null));

        public bool ShowTitle
        {
            get { return (bool)GetValue(ShowTitleProperty); }
            set { SetValue(ShowTitleProperty, value); }
        }
        public static readonly DependencyProperty ShowTitleProperty =
            DependencyProperty.Register("ShowTitle", typeof(bool), typeof(FOUPFrontView), new UIPropertyMetadata(true));

        public int SlotWidth
        {
            get { return (int)GetValue(SlotWidthProperty); }
            set { SetValue(SlotWidthProperty, value); }
        }
        public static readonly DependencyProperty SlotWidthProperty =
            DependencyProperty.Register("SlotWidth", typeof(int), typeof(FOUPFrontView), new PropertyMetadata(90));
        
        public bool IsCassettePlaced
        {
            get { return (bool)GetValue(IsCassettePlacedProperty); }
            set { SetValue(IsCassettePlacedProperty, value); }
        }
        public static readonly DependencyProperty IsCassettePlacedProperty =
            DependencyProperty.Register("IsCassettePlaced", typeof(bool), typeof(FOUPFrontView), new UIPropertyMetadata(false));
        #endregion

        private void Slot_SlotMouseButtonDown(object sender, MouseButtonEventArgs e)
        {
            GlobalEvents.OnSlotRightClickChanged(sender as Slot);
        }

        private void Slot_WaferTransferStarted(object sender, DragDropEventArgs e)
        {
            try
            {
                GlobalEvents.OnSlotWaferTransfer(e);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
            }
        }
    }
}