using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace IControls_FireManager
{
    public partial class Form_System_Config : Form
    {
        public Form_System_Config()
        {
            InitializeComponent();

            ///
            /// 이벤트
            /// 
            
            // 폼닫기 이벤트를 등록 (이벤트 핸들러 해제용)
            this.FormClosing += new FormClosingEventHandler(CreateForm_FormClosing);

            // 윈도우 스타일 변경 이벤트 핸들러 등록
            _Event.WindowStyleSet_SendMessage_Event += new _Event.WindowStyleSet_SendMessage_Handler(_Event_WindowStyleSet_SendMessage_Event);

            ///
            /// 스타일 변경
            /// 

            UI_Style_Initialize();

            ///
            /// UI
            ///

            this.editBox_ProjectPath.Text = _Data.Project_Path;

            // cyim 2016.04.01 : 6자리 혹은 4자리로 맵아이디와 그룹아이디 지정할수 있도록함	
            if (_Data.Project_MapGroupIDTypeNumber == "6")
            {
                this.radioButton_6.Checked = true;
                this.radioButton_4.Checked = false;
            }
            else
            {
                this.radioButton_6.Checked = false;
                this.radioButton_4.Checked = true; 
            }
        }
         
        // 폼닫기 이벤트를 등록 (이벤트 핸들러 해제용)
        public void CreateForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // 윈도우 스타일 변경 이벤트 핸들러 해제
            _Event.WindowStyleSet_SendMessage_Event -= new _Event.WindowStyleSet_SendMessage_Handler(_Event_WindowStyleSet_SendMessage_Event);
        }

        // 윈도우 스타일 변경 이벤트
        public void _Event_WindowStyleSet_SendMessage_Event()
        {
            UI_Style_Initialize();
        }

        // 스타일 초기화 함수
        private void UI_Style_Initialize()
        {

        }

        // 폴더 패스 지정
        private void uiButton_ProjectPath_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                this.editBox_ProjectPath.Text = folderBrowserDialog.SelectedPath;
            }
        }

        // 확인
        private void UiButton_Apply_Click(object sender, EventArgs e)
        {
            _Data.Project_Path = this.editBox_ProjectPath.Text;

            // cyim 2016.04.01 : 6자리 혹은 4자리로 맵아이디와 그룹아이디 지정할수 있도록함	
            if (this.radioButton_6.Checked == true)
                _Data.Project_MapGroupIDTypeNumber = "6";
            else
                _Data.Project_MapGroupIDTypeNumber = "4";

            // 시스템 환경 옵션에 따른 Program_Configuration.xml 쓰기

            // 프로젝트 경로만 변경했더라도 xml 파일은 만들어진다. 
            // 또한 이렇게 저장한 프로젝트는 최근 프로젝트명으로 xml 에 등록되어 
            // 프로그램 시작시에 제일먼저 프로젝트 명 및 그에 따른 경로를 가져오게 된다

            _File.Write_ProgramConfiguration();

            this.Close();
        }
    }
}