using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;

namespace ControlExplorer.Common
{
    public enum Device
    {
        Phone,
        Desktop
    }
    public class DeviceTrigger : StateTriggerBase
    {
        private Device device;

        public Device Device
        {
            get { return device; }
            set
            {
                device = value;
                UpdateTrigger();
            }
        }

        public DeviceTrigger()
        {
            Window.Current.SizeChanged += Current_SizeChanged;
        }

        private void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
        {
            UpdateTrigger();
        }

        private void UpdateTrigger()
        {
            switch (Device)
            {
                case Device.Phone:
                    if (PlatformUtils.IsWindowsPhoneDevice())
                    {
                        SetActive(true);
                    }
                    else
                    {
                        SetActive(false);
                    }
                    break;
                case Device.Desktop:
                    if (PlatformUtils.IsWindowsPhoneDevice())
                    {
                        SetActive(false);
                    }
                    else
                    {
                        SetActive(true);
                    }
                    break;
                default:
                    break;
            }
        }
    }

}
