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

namespace iTripLog.Upload
{
    public partial class Setting : XTransMobile.XTForm
    {
        private const string cecameraDefaultInitialDirectory = null;
        private const string cecameraDefaultPictureFileName = "picture1";
        private const string cecameraDefaultPictureExtension = ".jpg";
        private const string cecameraDefaultVideoFileName = "movie1";
        private const string cecameraDefaultTitle = "Title";
        private const string cecameraDefaultResolutionWidth = "100";
        private const string cecameraDefaultResolutionHeight = "100";
        private const string cecameraDefaultVideoTimeLimit = "25";

        public Setting()
        {
            InitializeComponent();
            this.ResetOptions();
        }

        public static string getFileLocation()
        {
            return cecameraDefaultInitialDirectory;
        }

        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
        }

        private void checkInitialDirectory_CheckStateChanged(object sender, System.EventArgs e)
        {
            this.textInitialDirectory.Enabled = this.checkInitialDirectory.Checked;
        }

        private void checkDefaultFileName_CheckStateChanged(object sender, System.EventArgs e)
        {
            this.textDefaultFileName.Enabled = this.checkDefaultFileName.Checked;
        }

        private void checkResolution_CheckStateChanged(object sender, System.EventArgs e)
        {
            this.textResolutionWidth.Enabled = this.checkResolution.Checked;
            this.textResolutionHeight.Enabled = this.checkResolution.Checked;
        }

        private void checkVideoTimeLimit_CheckStateChanged(object sender, EventArgs e)
        {
            this.textVideoTimeLimit.Enabled = this.checkVideoTimeLimit.Checked;
        }

        private void ResetOptions()
        {
            // Uncheck all checkboxs to specify the options using the default value
            this.checkInitialDirectory.Checked = false;
            this.checkDefaultFileName.Checked = false;
            this.checkResolution.Checked = false;
            this.checkVideoTimeLimit.Checked = false;
            this.checkVideoTimeLimit.Enabled = false;

            // Set the default value for the options
            this.textInitialDirectory.Text = cecameraDefaultInitialDirectory;
            this.textDefaultFileName.Text = cecameraDefaultPictureFileName;
            this.textResolutionWidth.Text = cecameraDefaultResolutionWidth;
            this.textResolutionHeight.Text = cecameraDefaultResolutionHeight;
            this.textVideoTimeLimit.Text = cecameraDefaultVideoTimeLimit;

            // Disable the edit controls since specify using default settings
            this.textInitialDirectory.Enabled = false;
            this.textDefaultFileName.Enabled = false;
            this.textResolutionWidth.Enabled = false;
            this.textResolutionHeight.Enabled = false;
            this.textVideoTimeLimit.Enabled = false;

        }

        private static bool ConvertStringToInt(string value, ref int result)
        {
            try
            {
                result = Convert.ToInt32(value, NumberFormatInfo.CurrentInfo);
            }
            catch (FormatException)
            {
                return false;
            }
            catch (OverflowException)
            {
                return false;
            }

            return true;
        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btn_Confirm_Click(object sender, EventArgs e)
        {

        }


    }
}