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 System.IO;
using Microsoft.Win32;

namespace Advantage_Final
{
    public partial class FilePaths : Form
    {
        public FilePaths()
        {
            InitializeComponent();
            textReportOutput.Text = (string)Dicks.GetValue("ReportOutput", "");  
            textBox1.Text = (string)Dicks.GetValue("ReportFolder", "");
        }

        public RegistryKey Dicks = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\PanaceanTech\\ReportRunner", true);

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


       



        private void button1_Click(object sender, EventArgs e)
        {

            //
            // This event handler was created by double-clicking the window in the designer.
            // It runs on the program's startup routine.
            //
            DialogResult result = reportFolder.ShowDialog();
            if (result == DialogResult.OK)
            {
                Dicks.SetValue("ReportFolder", reportFolder.SelectedPath);
                textBox1.Text = (string)Dicks.GetValue("ReportFolder");

            }
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void textBox1_Leave(object sender, EventArgs e)
        {
            if (System.IO.Directory.Exists(textBox1.Text))
            {
                Dicks.SetValue("ReportFolder", textBox1.Text.TrimEnd ('\\'));
                textBox1.Text = (string)Dicks.GetValue("ReportFolder");
            }
            else
            {
                MessageBox.Show("Enter a valid path.  Quit trying to break shit");
                textBox1.Text = "";

            }
        }

        private void btnOutPath_Click(object sender, EventArgs e)
        {
            DialogResult result = reportOutput.ShowDialog();
            if (result == DialogResult.OK)
            {
                Dicks.SetValue("ReportOutput", reportOutput.SelectedPath);
                textReportOutput.Text = (string)Dicks.GetValue("ReportOutput");

            }
        }

        private void textReportOutput_Leave(object sender, EventArgs e)
        {
            if (System.IO.Directory.Exists(textReportOutput.Text))
            {
                Dicks.SetValue("ReportOutput", textReportOutput.Text.TrimEnd('\\'));
                textReportOutput.Text = (string)Dicks.GetValue("ReportOutput");
            }
            else
            {
                MessageBox.Show("Enter a valid path.  Quit trying to break shit");
                textBox1.Text = "";

            }
        }

        private void textReportOutput_TextChanged(object sender, EventArgs e)
        {

        }



    }
}