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;
using Stone.Class;
using System.Collections.Specialized;
using System.IO;
namespace Stone
{
    public partial class FrmSetting : Form
    {
        string StrPath ="";
        object[] ListSetting = new object[31];
        StringCollection SC = new StringCollection();

        string strSettingItem = "";



        public FrmSetting()
        {
            InitializeComponent();
        }

        public FrmSetting(string stritem)
        {
            InitializeComponent();
            strSettingItem = stritem;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {

            panelSoftware.Dock = DockStyle.None;
            panelCalender.Dock = DockStyle.None;
            panelTime.Dock = DockStyle.None;
            panelPlayer.Dock = DockStyle.None;
            panelInfo.Dock = DockStyle.Fill;

            panelInfo.Visible = true;
            panelSoftware.Visible = false;
            panelCalender.Visible = false;
            panelTime.Visible = false;
            panelPlayer.Visible = false;

            BtnInfo.Checked = true;
            BtnSoftware.Checked = false;
            BtnCalendar.Checked = false;
            BtnTime.Checked = false;
            BtnPlayer.Checked = false;


        }

        private void MnuPlayer_Click(object sender, EventArgs e)
        {
            panelSoftware.Dock = DockStyle.None;
            panelCalender.Dock = DockStyle.None;
            panelTime.Dock = DockStyle.None;
            panelPlayer.Dock = DockStyle.Fill;
            panelInfo.Dock = DockStyle.None;

            panelInfo.Visible = false;
            panelSoftware.Visible = false;
            panelCalender.Visible = false;
            panelTime.Visible = false;
            panelPlayer.Visible = true;

            BtnInfo.Checked = false;
            BtnSoftware.Checked = false;
            BtnCalendar.Checked = false;
            BtnTime.Checked = false;
            BtnPlayer.Checked = true;
        }

        private void MnuTime_Click(object sender, EventArgs e)
        {
            panelSoftware.Dock = DockStyle.None;
            panelCalender.Dock = DockStyle.None;
            panelTime.Dock = DockStyle.Fill;
            panelPlayer.Dock = DockStyle.None;
            panelInfo.Dock = DockStyle.None;

            panelInfo.Visible = false;
            panelSoftware.Visible = false;
            panelCalender.Visible = false;
            panelTime.Visible = true;
            panelPlayer.Visible = false;

            BtnInfo.Checked = false;
            BtnSoftware.Checked = false;
            BtnCalendar.Checked = false;
            BtnTime.Checked = true;
            BtnPlayer.Checked = false;
        }

        private void MnuCalendar_Click(object sender, EventArgs e)
        {
            panelSoftware.Dock = DockStyle.None;
            panelCalender.Dock = DockStyle.Fill;
            panelTime.Dock = DockStyle.None;
            panelPlayer.Dock = DockStyle.None;
            panelInfo.Dock = DockStyle.None;

            panelInfo.Visible = false;
            panelSoftware.Visible = false;
            panelCalender.Visible = true;
            panelTime.Visible = false;
            panelPlayer.Visible = false;

            BtnInfo.Checked = false;
            BtnSoftware.Checked = false;
            BtnCalendar.Checked = true;
            BtnTime.Checked = false;
            BtnPlayer.Checked = false;
        }

        private void MnuSoftware_Click(object sender, EventArgs e)
        {
            panelSoftware.Dock = DockStyle.Fill;
            panelCalender.Dock = DockStyle.None;
            panelTime.Dock = DockStyle.None;
            panelPlayer.Dock = DockStyle.None;
            panelInfo.Dock = DockStyle.None;

            panelInfo.Visible = false;
            panelSoftware.Visible = true;
            panelCalender.Visible = false;
            panelTime.Visible = false;
            panelPlayer.Visible = false;

            BtnInfo.Checked = false;
            BtnSoftware.Checked = true;
            BtnCalendar.Checked = false;
            BtnTime.Checked = false;
            BtnPlayer.Checked = false;
        
            
        }

        private void BtnOk_Click(object sender, EventArgs e)
        {
         if (tabControlSetting.SelectedTab.Name == "tabPage1")
            {
             
                this.Close();
                return;
            }



            SoftwareOk();
            CalendarOk();
            TimeOk();
            PlayerOk();
            Properties.Settings.Default.Save();
            MessageBox.Show("برای اعمال تغییرات در برنامه ، نرم افزار باید دوباره راه اندازی شود", "زمرد", MessageBoxButtons.OK, MessageBoxIcon.Information);
            
            Program.SettingCheck = true;
            Program.MF.Close();
        }

        private void FrmSetting_Load(object sender, EventArgs e)
        {

            SoftwareLoad();
            CalendarLoad();
            TimeLoad();
            PlayerLoad();
            Info();
            InformationShopLoad();
            MnuSoftware_Click(sender, e);

            if (strSettingItem == "Calendar")
            {

            tabControlSetting.SelectedIndex = 1;
            MnuCalendar_Click(sender,e);

            }

            if (strSettingItem == "SoftWare")
            {

                tabControlSetting.SelectedIndex = 1;
                MnuSoftware_Click(sender, e);

            }

            if (strSettingItem == "InfoSys")
            {

                tabControlSetting.SelectedIndex = 1;
                toolStripButton5_Click(sender, e);
            }

        
            if (strSettingItem == "Player")
            {

                tabControlSetting.SelectedIndex = 1;
                MnuPlayer_Click(sender, e);
            }
          
        }

        private void Info()
        {
            LblNameOS.Text = Hardware_info.windows_caption();
            LblVersion.Text = Hardware_info.windows_os_version();
            LblCreator.Text = Hardware_info.windows_vendor();
            LblSerial.Text = Hardware_info.windows_serial_number();

        }

        private void SoftwareLoad()
        {
           ListSetting[0] =  checkBoxBackground.Checked = Properties.Settings.Default.EnableBG;
           ListSetting[1] = comboBoxMode.SelectedIndex = Properties.Settings.Default.ImageMod;
           ListSetting[2] = Properties.Settings.Default.ImagePath;
           ListSetting[3] = comboBoxStartLoading.SelectedIndex = Properties.Settings.Default.FrmPosition;
           ListSetting[4] = comboBoxAfterLoading.SelectedIndex = Properties.Settings.Default.FrmStatus;

           ListSetting[5] = checkBoxMax.Checked = Properties.Settings.Default.FrmMax;
           ListSetting[6] = checkBoxMin.Checked = Properties.Settings.Default.FrmMin;
           ListSetting[30] = comboBoxLanguage.SelectedIndex = Properties.Settings.Default.KeyboardLan;

        }

        private void CalendarLoad()
        {
            
              ListSetting[7]  = checkBoxCalendar.Checked = Properties.Settings.Default.EnableCalendar;
              ListSetting[8] = PerCalendar.DaysBackColor = Properties.Settings.Default.DaysBGColor;
              ListSetting[9] = PerCalendar.DaysForeColor = Properties.Settings.Default.DaysColor;
              ListSetting[10] = PerCalendar.HolidayForeColor = Properties.Settings.Default.HolidayDaysColor;
              ListSetting[11] = PerCalendar.TodayBackColor = Properties.Settings.Default.TodayDateBGColor;
              ListSetting[12] = PerCalendar.TitleBackColor = Properties.Settings.Default.YearMonBGColor;
              ListSetting[13] = PerCalendar.TodayForeColor = Properties.Settings.Default.TodayDateColor;
              ListSetting[14] = PerCalendar.WeekDaysForeColor = Properties.Settings.Default.WeekColor;
              ListSetting[15] = PerCalendar.WeekDaysBackColor = Properties.Settings.Default.WeekBGColor;
              ListSetting[16] = PerCalendar.TrailingForeColor = Properties.Settings.Default.BeforeAfterMonDayColor;
              ListSetting[17] = PerCalendar.BorderColor = Properties.Settings.Default.BorderColor;

              ListSetting[18] = PerCalendar.DaysFont = Properties.Settings.Default.DaysFont;
              ListSetting[19] = PerCalendar.TodayFont = Properties.Settings.Default.TodayDateFont;
              ListSetting[20] = PerCalendar.ShowToday = Properties.Settings.Default.ShowTodayDate;
              ListSetting[21] = true;
              ListSetting[22] = PerCalendar.ShowTrailing = Properties.Settings.Default.ShowBeforeAfterMonDay;

              LblPerDate.Text = PerCalendar.GetTodayDateInPersianDateTime().ToString();
              LblDate.Text = PerCalendar.GetTodayDateInDateTime().ToString();

              checkBoxCalendar.Checked = Properties.Settings.Default.EnableCalendar;
        }

        private void TimeLoad()
        {

           (ListSetting[23]) = checkBoxClock.Checked = Properties.Settings.Default.EnableClock;
           (ListSetting[24]) = checkBoxShowSecond.Checked =  Properties.Settings.Default.EnableSecond;
           (ListSetting[25]) = checkBoxEffectSecond.Checked =  Properties.Settings.Default.EnableSecondEffect;
           (ListSetting[26]) = comboBoxStyleClock.SelectedIndex =  Properties.Settings.Default.ClockTheme;

        }

        private void PlayerLoad()
        {

            (ListSetting[27]) =checkBoxWMP.Checked = Properties.Settings.Default.EnablePlayer;
            (ListSetting[28]) =checkBoxMenuWMP.Checked =WMP.enableContextMenu =Properties.Settings.Default.EnableMenuPlayer;
            (ListSetting[29]) =checkBoxCtlMuteBalance.Checked =WMP.Ctlenabled =Properties.Settings.Default.CtlEnable;
            LblVersionWMP.Text = "نسخـــه پلیــر : " +  WMP.versionInfo;

        }

        private void InformationShopLoad()
        {
            if (Program.FC.DSFactor.Tables["Information"].Rows.Count == 0) return;
            txtName.Text = Program.FC.DSFactor.Tables["Information"].Rows[0]["Name"].ToString();
            txtMobile.Text = Program.FC.DSFactor.Tables["Information"].Rows[0]["Mobile"].ToString();
            txtTel.Text = Program.FC.DSFactor.Tables["Information"].Rows[0]["Tel"].ToString();
            txtAddress.Text = Program.FC.DSFactor.Tables["Information"].Rows[0]["Address"].ToString();

        }

        private void checkBoxBackground_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxBackground.Checked)
            {
                comboBoxMode.Enabled = true;
                textBoxPath.Enabled = true;
                btnBrowsePic.Enabled = true;
              

            }
            else
            {
                comboBoxMode.Enabled = false;
                textBoxPath.Enabled = false;
                btnBrowsePic.Enabled = false;
              

            }

            ListSetting[0] = checkBoxBackground.Checked;
        }

  

        private void btnBrowsePic_Click(object sender, EventArgs e)
        {
            OFDForImage.Filter = "Jpeg Files (*.jpg) |*.jpg|"
         + "PNG Files (*.png) |*.png|" + "Jpeg Files (*.jpeg) |*.jpeg|" + "Bmp Files(*.bmp) |*.bmp";
            OFDForImage.FilterIndex = 1;
            OFDForImage.Title = "زمرد";
            OFDForImage.FileName = "";
            if (OFDForImage.ShowDialog() == DialogResult.OK)
            {
                StrPath = OFDForImage.FileName;
                textBoxPath.Text = StrPath;
                ListSetting[2] = Path.GetFileName(StrPath);

            }
        }


        private string ExtractFileName(string strfilename)
        {
            string[] split = strfilename.Split(new Char[] { '\\', ' ' });

            return split[split.Length -1] ;
        }


        private void SoftwareOk()
        {
           
           
            if (StrPath != "")
            {
                try
                {
                    System.IO.File.Delete(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\ParsZSDB" + "\\ImagesBG\\" + Properties.Settings.Default.ImagePath);
                    System.IO.File.Copy(StrPath, System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\ParsZSDB" + "\\ImagesBG\\" + Path.GetFileName(StrPath), true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message +ex.TargetSite+ "مشکلی در انتقال عکس بوجود آمده است ", "زمرد", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }


            Properties.Settings.Default.FrmPosition = Int32.Parse(ListSetting[3].ToString());
            Properties.Settings.Default.FrmStatus = Int32.Parse(ListSetting[4].ToString());
            Properties.Settings.Default.FrmMax = (bool)(ListSetting[5]);
            Properties.Settings.Default.FrmMin = (bool)(ListSetting[6]);
            Properties.Settings.Default.KeyboardLan = Int32.Parse(ListSetting[30].ToString());
            Properties.Settings.Default.ImageMod = Int32.Parse(ListSetting[1].ToString());
            Properties.Settings.Default.ImagePath = ListSetting[2].ToString();
            Properties.Settings.Default.EnableBG = (bool)(ListSetting[0]);
        }

        private void CalendarOk()
        {

            Properties.Settings.Default.EnableCalendar = (bool)(ListSetting[7]);
            Properties.Settings.Default.DaysBGColor= (Color)(ListSetting[8]);
            Properties.Settings.Default.DaysColor = (Color)(ListSetting[9]);
            Properties.Settings.Default.HolidayDaysColor = (Color)(ListSetting[10]);
            Properties.Settings.Default.TodayDateBGColor = (Color)(ListSetting[11]);
            Properties.Settings.Default.YearMonBGColor = (Color)(ListSetting[12]);
            Properties.Settings.Default.TodayDateColor = (Color)(ListSetting[13]);
            Properties.Settings.Default.WeekColor = (Color)(ListSetting[14]);
            Properties.Settings.Default.WeekBGColor = (Color)(ListSetting[15]);
            Properties.Settings.Default.BeforeAfterMonDayColor = (Color)(ListSetting[16]);
            Properties.Settings.Default.BorderColor = (Color)(ListSetting[17]);
            Properties.Settings.Default.DaysFont = (Font)(ListSetting[18]);
            Properties.Settings.Default.TodayDateFont = (Font)(ListSetting[19]);
            Properties.Settings.Default.ShowTodayDate = (bool)(ListSetting[20]);
            Properties.Settings.Default.ShowWeek = (bool)(ListSetting[21]);
            Properties.Settings.Default.ShowBeforeAfterMonDay = (bool)(ListSetting[22]);



           
        }

        private void TimeOk()
        {

            Properties.Settings.Default.EnableClock = (bool)(ListSetting[23]);
            Properties.Settings.Default.EnableSecond = (bool)(ListSetting[24]);
            Properties.Settings.Default.EnableSecondEffect = (bool)(ListSetting[25]);
            Properties.Settings.Default.ClockTheme= (int)(ListSetting[26]);
          

        }

        private void PlayerOk()
        {
            Properties.Settings.Default.EnablePlayer = (bool)(ListSetting[27]);
            Properties.Settings.Default.EnableMenuPlayer = (bool)(ListSetting[28]);
            Properties.Settings.Default.CtlEnable = (bool)(ListSetting[29]);

        }

        private void checkBoxCalendar_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxCalendar.Checked == true)
            {

                comboBoxColor.Enabled = true;
                comboBoxFont.Enabled = true;
                comboBoxShowObjCalendar.Enabled = true;
                btnSelectFont.Enabled = true;
                pictureBoxColor.Enabled = true;
                radioButtonYes.Enabled = true;
                radioButtonNo.Enabled = true;
                PerCalendar.Enabled = true;

            }
            else
            {

                comboBoxColor.Enabled = false;
                comboBoxFont.Enabled = false;
                comboBoxShowObjCalendar.Enabled = false;
                btnSelectFont.Enabled = false;
                pictureBoxColor.Enabled = false;
                radioButtonYes.Enabled = false;
                radioButtonNo.Enabled = false;
                PerCalendar.Enabled = false;

            }

            ListSetting[7] = checkBoxCalendar.Checked;
        }

        private void comboBoxMode_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListSetting[1] = comboBoxMode.SelectedIndex;
        }

        private void comboBoxStartLoading_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListSetting[3] = comboBoxStartLoading.SelectedIndex;
        }

        private void comboBoxAfterLoading_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListSetting[4] = comboBoxAfterLoading.SelectedIndex;
        }

        private void checkBoxMax_CheckedChanged(object sender, EventArgs e)
        {
            ListSetting[5] = checkBoxMax.Checked;
        }

        private void checkBoxMin_CheckedChanged(object sender, EventArgs e)
        {
            ListSetting[6] = checkBoxMin.Checked;
        }

        private void comboBoxLanguage_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListSetting[30] = comboBoxLanguage.SelectedIndex;
        }

        private void comboBoxColor_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (comboBoxColor.SelectedIndex == 0)
            {
                pictureBoxColor.BackColor = (Color)(ListSetting[8]);
            }

            if (comboBoxColor.SelectedIndex == 1)
            {
                pictureBoxColor.BackColor = (Color)(ListSetting[9]);
            }

            if (comboBoxColor.SelectedIndex == 2)
            {
                pictureBoxColor.BackColor = (Color)(ListSetting[10]);
            }

            if (comboBoxColor.SelectedIndex == 3)
            {
                pictureBoxColor.BackColor = (Color)(ListSetting[11]);
            }

            if (comboBoxColor.SelectedIndex == 4)
            {
                pictureBoxColor.BackColor = (Color)(ListSetting[12]);
            }

            if (comboBoxColor.SelectedIndex == 5)
            {
                pictureBoxColor.BackColor = (Color)(ListSetting[13]);
            }

            if (comboBoxColor.SelectedIndex == 6)
            {
                pictureBoxColor.BackColor = (Color)(ListSetting[14]);
            }

            if (comboBoxColor.SelectedIndex == 7)
            {
                pictureBoxColor.BackColor = (Color)(ListSetting[15]);
            }

            if (comboBoxColor.SelectedIndex == 8)
            {
                pictureBoxColor.BackColor = (Color)(ListSetting[16]);
            }

            if (comboBoxColor.SelectedIndex == 9)
            {
                pictureBoxColor.BackColor = (Color)(ListSetting[17]);
            }
        }

        private void pictureBoxColor_Click(object sender, EventArgs e)
        {
            colorDialogSetting.ShowDialog();
            if (comboBoxColor.SelectedIndex == 0)
            {
                ListSetting[8] = colorDialogSetting.Color;
                PerCalendar.DaysBackColor = colorDialogSetting.Color;
            }

            if (comboBoxColor.SelectedIndex == 1)
            {
                ListSetting[9] = colorDialogSetting.Color;
                PerCalendar.DaysForeColor = colorDialogSetting.Color;
            }

            if (comboBoxColor.SelectedIndex == 2)
            {
                ListSetting[10] = colorDialogSetting.Color;
                PerCalendar.HolidayForeColor = colorDialogSetting.Color;
            }

            if (comboBoxColor.SelectedIndex == 3)
            {
                ListSetting[11] = colorDialogSetting.Color;
                PerCalendar.TodayBackColor= colorDialogSetting.Color;
            }

            if (comboBoxColor.SelectedIndex == 4)
            {
                ListSetting[12] = colorDialogSetting.Color;
                PerCalendar.TitleBackColor = colorDialogSetting.Color;
            }

            if (comboBoxColor.SelectedIndex == 5)
            {
                ListSetting[13] = colorDialogSetting.Color;
                PerCalendar.TodayForeColor = colorDialogSetting.Color;
            }

            if (comboBoxColor.SelectedIndex == 6)
            {
                ListSetting[14] = colorDialogSetting.Color;
                PerCalendar.WeekDaysForeColor = colorDialogSetting.Color;
            }

            if (comboBoxColor.SelectedIndex == 7)
            {
                ListSetting[15] = colorDialogSetting.Color;
                PerCalendar.WeekDaysBackColor = colorDialogSetting.Color;
            }

            if (comboBoxColor.SelectedIndex == 8)
            {
                ListSetting[16] = colorDialogSetting.Color;
                PerCalendar.TrailingForeColor = colorDialogSetting.Color;
            }

            if (comboBoxColor.SelectedIndex == 9)
            {
                ListSetting[17] = colorDialogSetting.Color;
                PerCalendar.BorderColor = colorDialogSetting.Color;
            }

            pictureBoxColor.BackColor = colorDialogSetting.Color;
        }

        private void comboBoxFont_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (comboBoxFont.SelectedIndex == 0)
            {
                PerCalendar.DaysFont = (Font)(ListSetting[18]);
            }
            if (comboBoxFont.SelectedIndex == 1)
            {
                PerCalendar.TodayFont = (Font)(ListSetting[19]);
            }

        }

        private void comboBoxShowObjCalendar_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (comboBoxShowObjCalendar.SelectedIndex == 0)
            {

                if ((bool)(ListSetting[20]))
                {
                    radioButtonYes.Checked = true;
                }
                else
                {
                    radioButtonNo.Checked = true;
                }
             
            }

            if (comboBoxShowObjCalendar.SelectedIndex == 1)
            {
                if ((bool)(ListSetting[22]))
                {
                    radioButtonYes.Checked = true;
                }
                else
                {
                    radioButtonNo.Checked = true;
                }
            
            }
        }

        private void checkBoxClock_CheckedChanged(object sender, EventArgs e)
        {

            if (checkBoxClock.Checked)
            {

                checkBoxShowSecond.Enabled = true;
                checkBoxEffectSecond.Enabled = true;
                btnSettingWinTime.Enabled = true;
                comboBoxStyleClock.Enabled = true;



            }
            else{

                checkBoxShowSecond.Enabled = false;
                checkBoxEffectSecond.Enabled = false;
                btnSettingWinTime.Enabled = false;
                comboBoxStyleClock.Enabled = false;
            }




            ListSetting[23] = checkBoxClock.Checked;


        }

        private void checkBoxShowSecond_CheckedChanged(object sender, EventArgs e)
        {
            ListSetting[24] = checkBoxShowSecond.Checked;
            vistaClockDemo.ShowSecond = checkBoxShowSecond.Checked;
        }

        private void checkBoxEffectSecond_CheckedChanged(object sender, EventArgs e)
        {
            ListSetting[25] = checkBoxEffectSecond.Checked;
            vistaClockDemo.SecondSpring = checkBoxEffectSecond.Checked;
        }

        private void comboBoxStyleClock_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListSetting[26] = comboBoxStyleClock.SelectedIndex;

            if (comboBoxStyleClock.SelectedIndex == 0)
            {
                vistaClockDemo.Style = VistaClockPersian.Controls.VistaClock.VistaClockStyle.Black;
            }

            if (comboBoxStyleClock.SelectedIndex == 1)
            {
                vistaClockDemo.Style = VistaClockPersian.Controls.VistaClock.VistaClockStyle.Silver;
            }

            if (comboBoxStyleClock.SelectedIndex == 2)
            {
                vistaClockDemo.Style = VistaClockPersian.Controls.VistaClock.VistaClockStyle.Red;
            }

            if (comboBoxStyleClock.SelectedIndex == 3)
            {
                vistaClockDemo.Style = VistaClockPersian.Controls.VistaClock.VistaClockStyle.Flower;
            }
        }

        private void checkBoxWMP_CheckedChanged(object sender, EventArgs e)
        {

            if (checkBoxWMP.Checked)
            {
                checkBoxMenuWMP.Enabled = true;
                checkBoxCtlMuteBalance.Enabled = true;
                
            }
            else
            {
                checkBoxMenuWMP.Enabled = false;
                checkBoxCtlMuteBalance.Enabled = false;
            }


            ListSetting[27] = checkBoxWMP.Checked;
           
        }

        private void checkBoxMenuWMP_CheckedChanged(object sender, EventArgs e)
        {
            ListSetting[28] = checkBoxMenuWMP.Checked;
            WMP.enableContextMenu = checkBoxMenuWMP.Checked;
        }

        private void listBoxWMP_SelectedIndexChanged(object sender, EventArgs e)
        {


        }
        private void btnSelectFont_Click(object sender, EventArgs e)
        {
            FontDialogSetting.ShowDialog();
            if (comboBoxFont.SelectedIndex == 0)
            {
                ListSetting[18] = FontDialogSetting.Font;
                PerCalendar.DaysFont = FontDialogSetting.Font;
            }

            if (comboBoxFont.SelectedIndex == 1)
            {
                ListSetting[19] = FontDialogSetting.Font;
                PerCalendar.TodayFont = FontDialogSetting.Font;
            }
        }

        private void radioButtonYes_CheckedChanged(object sender, EventArgs e)
        {
            if (comboBoxShowObjCalendar.SelectedIndex == 0)
            {
                if (radioButtonYes.Checked)
                {

                    ListSetting[20] = radioButtonYes.Checked;
                    PerCalendar.ShowToday = true;

                }
             
            }

            if (comboBoxShowObjCalendar.SelectedIndex == 1)
            {
                if (radioButtonYes.Checked)
                {
                    ListSetting[22] = radioButtonYes.Checked;
                    PerCalendar.ShowTrailing = true;
                }
            
            }

        }

        private void checkBoxCtlMuteBalance_CheckedChanged(object sender, EventArgs e)
        {
            ListSetting[29] = checkBoxCtlMuteBalance.Checked;

            WMP.Ctlenabled = checkBoxCtlMuteBalance.Checked;
        }

        private void btnSettingWinTime_Click(object sender, EventArgs e)
        {
           System.Diagnostics.Process.Start("timedate.cpl");
        }

        private void radioButtonNo_CheckedChanged(object sender, EventArgs e)
        {
            if (comboBoxShowObjCalendar.SelectedIndex == 0)
            {
                if (radioButtonNo.Checked)
                {

                    ListSetting[20] = false;
                    PerCalendar.ShowToday = false;

                }

            }

            if (comboBoxShowObjCalendar.SelectedIndex == 1)
            {
                if (radioButtonNo.Checked)
                {
                    ListSetting[22] = false;
                    PerCalendar.ShowTrailing = false;
                }

            }
        }

        private void FrmSetting_Shown(object sender, EventArgs e)
        {
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
            checkBoxCalendar.Checked = Properties.Settings.Default.EnableCalendar;
        }

       

        private void FrmSetting_Activated(object sender, EventArgs e)
        {
           
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            
        }

        private void groupBox2_Enter(object sender, EventArgs e)
        {

        }

        private void checkBoxBackup_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxBackup.Checked)
            {
                btnBrowseBackup.Enabled = true;
                btnBackup.Enabled = true;
                txtBackup.Enabled = true;
                progressBarBackup.Enabled = true;
            }
            else
            {
                btnBrowseBackup.Enabled = false;
                btnBackup.Enabled = false;
                txtBackup.Enabled = false;
                progressBarBackup.Enabled = false;
            }
        }

        private void checkBoxRestore_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxRestore.Checked)
            {
                btnBrowseRestore.Enabled = true;
                btnRestore.Enabled = true;
                txtRestore.Enabled = true;
                progressBarRestore.Enabled = true;
            }
            else
            {
                btnBrowseRestore.Enabled = false;
                btnRestore.Enabled = false;
                txtRestore.Enabled = false;
                progressBarRestore.Enabled = false;
            }
        }

        private void btnApplyToDB_Click(object sender, EventArgs e)
        {
            try
            {
                string XmlDataFileName = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "\\ParsZSDB" + "\\Information.xml";
                if (Program.FC.DSFactor.Tables["Information"].Rows.Count == 0)
                {
                    DataRow Rows = Program.FC.DSFactor.Tables["Information"].NewRow();
                    Rows["Name"] = txtName.Text;
                    Rows["Mobile"] = txtMobile.Text;
                    Rows["Tel"] = txtTel.Text;
                    Rows["Address"] = txtAddress.Text;
                    Program.FC.DSFactor.Tables["Information"].Rows.Add(Rows);
                    Program.FC.DSFactor.Tables["Information"].WriteXml(XmlDataFileName);
                    MessageBox.Show("داده ها با موفقیت ثبت شدند", "زمرد", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                Program.FC.DSFactor.Tables["Information"].Rows[0]["Name"] = txtName.Text;
                Program.FC.DSFactor.Tables["Information"].Rows[0]["Mobile"] = txtMobile.Text;
                Program.FC.DSFactor.Tables["Information"].Rows[0]["Tel"] = txtTel.Text;
                Program.FC.DSFactor.Tables["Information"].Rows[0]["Address"] = txtAddress.Text;
                Program.FC.DSFactor.Tables["Information"].WriteXml(XmlDataFileName);
                MessageBox.Show("داده ها با موفقیت ثبت شدند", "زمرد", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            catch (Exception ex)
            {
                MessageBox.Show("مشکلی در انتقال داده ها به بانک اطلاعاتی بوجود آمده است", "زمرد", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }

        private void btnBrowseBackup_Click(object sender, EventArgs e)
        {
            saveFileDialogSetting.Filter = "Zip-Archive (*.zip)|*.zip";
            saveFileDialogSetting.RestoreDirectory = true;

            if (saveFileDialogSetting.ShowDialog() == DialogResult.OK)
            {
                txtBackup.Text = saveFileDialogSetting.FileName;
            }
           

        }

        private void btnBackup_Click(object sender, EventArgs e)
        {

            if (txtBackup.Text == "")
            {

                MessageBox.Show("لطفاً مسیری را انتخاب کنید", "زمرد", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            progressBarBackup.Style = ProgressBarStyle.Marquee;
            if (DBFilesCompress.DBCompress(txtBackup.Text))
            {
                MessageBox.Show("پشتیبان گیری اطلاعات با موفقیت انجام شد", "زمرد", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("مشکلی در پشتیبان گیری بوجود آمده است", "زمرد", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            progressBarBackup.Style = ProgressBarStyle.Blocks;


        }

        private void btnRestore_Click(object sender, EventArgs e)
        {
            if (txtRestore.Text == "")
            {

                MessageBox.Show("لطفاً مسیری را انتخاب کنید", "زمرد", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            progressBarRestore.Style = ProgressBarStyle.Marquee;
            if (DBFilesCompress.DECompressDataBase(txtRestore.Text))
            {
                MessageBox.Show("بازیابی اطلاعات با موفقیت انجام شد", "زمرد", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("مشکلی در بازیابی اطلاعات بوجود آمده است", "زمرد", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            progressBarRestore.Style = ProgressBarStyle.Blocks;
        }

        private void btnBrowseRestore_Click(object sender, EventArgs e)
        {

            OFDForImage.Filter = "Zip-Archive (*.zip)|*.zip";

            if (OFDForImage.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {

                txtRestore.Text = OFDForImage.FileName;

            }



        }

        private void txtTel_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtName_TextChanged(object sender, EventArgs e)
        {

        }


        


    }
}
