using Remontor.Connector;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Remontor.Setting
{
    public partial class settingAppControl : UserControl
    {
        public settingAppControl()
        {
            InitializeComponent();
            UpdateSetting();
           
        }
        public void UpdateSetting()
        {
            if (SGlobalSetting.settingApp != null)
            {
                path.Text = SGlobalSetting.settingApp.pathApp;
                nb_ItemHistorySize.Value = SGlobalSetting.settingApp.sizeHistoryItem;
                TbUrl.Text = SGlobalSetting.settingApp.urlPhoto;
                NbItemSizePhoto.Value= SGlobalSetting.settingApp.sizePhotoItem;
                NbX.Value = SGlobalSetting.settingApp.xPosDoble;
                NbY.Value = SGlobalSetting.settingApp.yPosDoble;
                NbWidth.Value = SGlobalSetting.settingApp.WidthDoble;
                NbHeight.Value = SGlobalSetting.settingApp.HeightDoble;
            }
        }


        public void Save()
        {
            SGlobalSetting.settingApp.pathApp = path.Text;
            SGlobalSetting.settingApp.sizeHistoryItem = (int)nb_ItemHistorySize.Value;
            SGlobalSetting.settingApp.urlPhoto = TbUrl.Text;
            SGlobalSetting.settingApp.sizePhotoItem = (int)NbItemSizePhoto.Value;
            SGlobalSetting.settingApp.xPosDoble = (int)NbX.Value;
            SGlobalSetting.settingApp.yPosDoble = (int)NbY.Value;
            SGlobalSetting.settingApp.WidthDoble = (int)NbWidth.Value;
            SGlobalSetting.settingApp.HeightDoble = (int)NbHeight.Value;
        }

        public bool edited()
        {
            return (SGlobalSetting.settingApp.pathApp != path.Text ||
                SGlobalSetting.settingApp.sizeHistoryItem  != (int)nb_ItemHistorySize.Value ||
                SGlobalSetting.settingApp.urlPhoto != TbUrl.Text ||
                SGlobalSetting.settingApp.sizePhotoItem != (int)NbItemSizePhoto.Value ||
                SGlobalSetting.settingApp.xPosDoble != (int)NbX.Value ||
                SGlobalSetting.settingApp.yPosDoble != (int)NbY.Value ||
                SGlobalSetting.settingApp.WidthDoble != (int)NbWidth.Value ||
                SGlobalSetting.settingApp.HeightDoble != (int)NbHeight.Value
                );

        }

        private void bt_path_open_Click(object sender, EventArgs e)
        {
            SConnector.FormMain.ShowOn = true;
            DialogResult result = openFileDialog1.ShowDialog();
            if (result == DialogResult.OK)
            {
                path.Text = openFileDialog1.FileName;
            }
            SConnector.FormMain.ShowOn = false;
        }

        private void numericUpDown3_ValueChanged(object sender, EventArgs e)
        {

        }
    }
}
