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

namespace HistoryWallEditTool.Controls.PreviewControl
{
    /// <summary>
    /// SavePreviewControl.xaml 的互動邏輯
    /// </summary>
    public partial class SavePreviewControl : UserControl
    {
        private HistoryWall rootParent = null;
        public SavePreviewControl(HistoryWall mw)
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(SavePreviewControl_Loaded);
            rootParent = mw;
        }

        private void SavePreviewControl_Loaded(object sender, RoutedEventArgs e)
        {
            LoadScreenViewer();
        }

        private void LoadScreenViewer()
        {
            uxContentGrid.Children.Clear();
            ScreenViewer viewer = new ScreenViewer();
            Utilities.UtilityClass.ScreenSet screenSet;
            switch (HistoryWall.MainBackCollect.ScreenSetting)
            {
                case 1:
                    screenSet = Utilities.UtilityClass.ScreenSet.Single;
                    uxContentGrid.Width = 1354.5;
                    uxContentGrid.Height = 761.5;
                    uxContentGrid.Margin = new Thickness(267, 120, 10, 0);
                    break;
                case 2:
                    screenSet = Utilities.UtilityClass.ScreenSet.Double;
                    uxContentGrid.Width = 1900;
                    uxContentGrid.Height = 535.5;
                    uxContentGrid.Margin = new Thickness(10, 120 + 34, 10, 0);
                    break;
                case 3:
                    uxContentGrid.Width = 1900;
                    uxContentGrid.Height = 358.5;
                    uxContentGrid.Margin = new Thickness(10, 120 + 128, 10, 0);
                    screenSet = Utilities.UtilityClass.ScreenSet.Triple;
                    break;
                default:
                    screenSet = Utilities.UtilityClass.ScreenSet.Complete;
                    uxContentGrid.Width = 1354.5;
                    uxContentGrid.Height = 761.5;
                    break;
            }

            viewer.ScreenCount = screenSet;
            uxContentGrid.Children.Add(viewer);
        }

        private void uxCancelBtn_Click(object sender, RoutedEventArgs e)
        {
            LoadScreenViewer();
        }

        private void uxSaveBtn_Click(object sender, RoutedEventArgs e)
        {
            rootParent.SaveConfig();
            rootParent.EndSetting();
        }
    }
}
