using Remontor.Connector;
using Remontor.Words;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace Remontor.Setting
{
  
    partial class SettingWordsControl : UserControl
    {

       
        public delegate void DUpdateTree();
        public DUpdateTree UpdateTree;
        public SettingWordsControl()
        {
            InitializeComponent();
            UpdateSetting();
        }

        public void UpdateSetting()
        {
            if (SGlobalSetting.settingWords != null)
            {
                path.Text = SGlobalSetting.settingWords.PathBase;
            }
        }

        private void bt_wordsBilder_Click(object sender, EventArgs e)
        {
            SConnector.FormMain.ShowOn = true;
            BilderWords bilderWords = new BilderWords();
            DialogResult result = bilderWords.ShowDialog();
            if (result == DialogResult.OK)
            {
                UpdateTree();
            }
            SConnector.FormMain.ShowOn = false;
        }

        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;
        }

        public bool edited()
        {
            return (SGlobalSetting.settingWords.PathBase != path.Text);

        }

        public void Save()
        {
            if(SGlobalSetting.settingWords.PathBase != path.Text)
            {
                SGlobalSetting.settingWords.PathBase = path.Text;
            }
            
        }
    }
}
