// ctrlOptionTransfer.cs
// Copyright (C) 2008 Karel Jordaan karel_jordaan@yahoo.com.au
// 
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

using System;
using System.ComponentModel;
using System.Windows.Forms;
using FileScope;

namespace ZANZIClient
{
    /// <summary>
    /// Summary description for ctrlOptionTransfer.
    /// </summary>
    public class ctrlOptionTransfer : UserControl
    {
        private Button bntBrowseTemp;
        private Button btnBrowseDownload;
        public CheckBox chkAutoClearDownloads;
        public CheckBox chkAutoClearUploads;

        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private Container components;

        private FolderBrowserDialog folderBrowserDialog1;
        private GroupBox groupBox1;
        private GroupBox groupBox2;
        private Label label1;
        private Label label2;
        private Label label3;
        public TextBox txtDownloadDir;
        public TextBox txtTempDir;
        public NumericUpDown udMaxUploads;

        public ctrlOptionTransfer()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // TODO: Add any initialization after the InitializeComponent call
        }

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }

        private void btnBrowseDownload_Click(object sender, EventArgs e)
        {
            txtDownloadDir.Text = GetFolder();
            //zzoi 28 Feb 2009
            //add this dir to the lstShares
            //update the engen sharelist
            Stats.settings.dlDirectory = txtDownloadDir.Text;
            Stats.shareList.Add((object)txtDownloadDir.Text);
            Stats.LoadSave.UpdateShares();
        }

        private string GetFolder()
        {
            folderBrowserDialog1.ShowDialog();
            return folderBrowserDialog1.SelectedPath;
        }

        private void bntBrowseTemp_Click(object sender, EventArgs e)
        {
            txtTempDir.Text = GetFolder();

            Stats.settings.dlDirectory = txtDownloadDir.Text;
            Stats.shareList.Add((object)txtDownloadDir.Text);
            Stats.LoadSave.UpdateShares();
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ctrlOptionTransfer));
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.chkAutoClearDownloads = new System.Windows.Forms.CheckBox();
            this.bntBrowseTemp = new System.Windows.Forms.Button();
            this.label3 = new System.Windows.Forms.Label();
            this.txtTempDir = new System.Windows.Forms.TextBox();
            this.btnBrowseDownload = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.txtDownloadDir = new System.Windows.Forms.TextBox();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.udMaxUploads = new System.Windows.Forms.NumericUpDown();
            this.label2 = new System.Windows.Forms.Label();
            this.chkAutoClearUploads = new System.Windows.Forms.CheckBox();
            this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.udMaxUploads)).BeginInit();
            this.SuspendLayout();
            // 
            // groupBox1
            // 
            this.groupBox1.AccessibleDescription = null;
            this.groupBox1.AccessibleName = null;
            resources.ApplyResources(this.groupBox1, "groupBox1");
            this.groupBox1.BackgroundImage = null;
            this.groupBox1.Controls.Add(this.chkAutoClearDownloads);
            this.groupBox1.Controls.Add(this.bntBrowseTemp);
            this.groupBox1.Controls.Add(this.label3);
            this.groupBox1.Controls.Add(this.txtTempDir);
            this.groupBox1.Controls.Add(this.btnBrowseDownload);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Controls.Add(this.txtDownloadDir);
            this.groupBox1.Font = null;
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.TabStop = false;
            // 
            // chkAutoClearDownloads
            // 
            this.chkAutoClearDownloads.AccessibleDescription = null;
            this.chkAutoClearDownloads.AccessibleName = null;
            resources.ApplyResources(this.chkAutoClearDownloads, "chkAutoClearDownloads");
            this.chkAutoClearDownloads.BackgroundImage = null;
            this.chkAutoClearDownloads.Font = null;
            this.chkAutoClearDownloads.Name = "chkAutoClearDownloads";
            // 
            // bntBrowseTemp
            // 
            this.bntBrowseTemp.AccessibleDescription = null;
            this.bntBrowseTemp.AccessibleName = null;
            resources.ApplyResources(this.bntBrowseTemp, "bntBrowseTemp");
            this.bntBrowseTemp.BackgroundImage = null;
            this.bntBrowseTemp.Font = null;
            this.bntBrowseTemp.Name = "bntBrowseTemp";
            this.bntBrowseTemp.Click += new System.EventHandler(this.bntBrowseTemp_Click);
            // 
            // label3
            // 
            this.label3.AccessibleDescription = null;
            this.label3.AccessibleName = null;
            resources.ApplyResources(this.label3, "label3");
            this.label3.Font = null;
            this.label3.Name = "label3";
            // 
            // txtTempDir
            // 
            this.txtTempDir.AccessibleDescription = null;
            this.txtTempDir.AccessibleName = null;
            resources.ApplyResources(this.txtTempDir, "txtTempDir");
            this.txtTempDir.BackgroundImage = null;
            this.txtTempDir.Font = null;
            this.txtTempDir.Name = "txtTempDir";
            // 
            // btnBrowseDownload
            // 
            this.btnBrowseDownload.AccessibleDescription = null;
            this.btnBrowseDownload.AccessibleName = null;
            resources.ApplyResources(this.btnBrowseDownload, "btnBrowseDownload");
            this.btnBrowseDownload.BackgroundImage = null;
            this.btnBrowseDownload.Font = null;
            this.btnBrowseDownload.Name = "btnBrowseDownload";
            this.btnBrowseDownload.Click += new System.EventHandler(this.btnBrowseDownload_Click);
            // 
            // label1
            // 
            this.label1.AccessibleDescription = null;
            this.label1.AccessibleName = null;
            resources.ApplyResources(this.label1, "label1");
            this.label1.Font = null;
            this.label1.Name = "label1";
            // 
            // txtDownloadDir
            // 
            this.txtDownloadDir.AccessibleDescription = null;
            this.txtDownloadDir.AccessibleName = null;
            resources.ApplyResources(this.txtDownloadDir, "txtDownloadDir");
            this.txtDownloadDir.BackgroundImage = null;
            this.txtDownloadDir.Font = null;
            this.txtDownloadDir.Name = "txtDownloadDir";
            this.txtDownloadDir.TextChanged += new System.EventHandler(this.txtDownloadDir_TextChanged);
            this.txtDownloadDir.Leave += new System.EventHandler(this.txtDownloadDir_Leave);
            // 
            // groupBox2
            // 
            this.groupBox2.AccessibleDescription = null;
            this.groupBox2.AccessibleName = null;
            resources.ApplyResources(this.groupBox2, "groupBox2");
            this.groupBox2.BackgroundImage = null;
            this.groupBox2.Controls.Add(this.udMaxUploads);
            this.groupBox2.Controls.Add(this.label2);
            this.groupBox2.Controls.Add(this.chkAutoClearUploads);
            this.groupBox2.Font = null;
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.TabStop = false;
            // 
            // udMaxUploads
            // 
            this.udMaxUploads.AccessibleDescription = null;
            this.udMaxUploads.AccessibleName = null;
            resources.ApplyResources(this.udMaxUploads, "udMaxUploads");
            this.udMaxUploads.Font = null;
            this.udMaxUploads.Name = "udMaxUploads";
            // 
            // label2
            // 
            this.label2.AccessibleDescription = null;
            this.label2.AccessibleName = null;
            resources.ApplyResources(this.label2, "label2");
            this.label2.Font = null;
            this.label2.Name = "label2";
            // 
            // chkAutoClearUploads
            // 
            this.chkAutoClearUploads.AccessibleDescription = null;
            this.chkAutoClearUploads.AccessibleName = null;
            resources.ApplyResources(this.chkAutoClearUploads, "chkAutoClearUploads");
            this.chkAutoClearUploads.BackgroundImage = null;
            this.chkAutoClearUploads.Font = null;
            this.chkAutoClearUploads.Name = "chkAutoClearUploads";
            // 
            // folderBrowserDialog1
            // 
            resources.ApplyResources(this.folderBrowserDialog1, "folderBrowserDialog1");
            // 
            // ctrlOptionTransfer
            // 
            this.AccessibleDescription = null;
            this.AccessibleName = null;
            resources.ApplyResources(this, "$this");
            this.BackgroundImage = null;
            this.Controls.Add(this.groupBox2);
            this.Controls.Add(this.groupBox1);
            this.Font = null;
            this.Name = "ctrlOptionTransfer";
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.groupBox2.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.udMaxUploads)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private void txtDownloadDir_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtDownloadDir_Leave(object sender, EventArgs e)
        {
            
            //zzoi 13mrt 2009
            //add this dir to the lstShares
            //update the engen sharelist
            if (txtDownloadDir.Text != null)
            {
                Stats.settings.dlDirectory = txtDownloadDir.Text;
                Stats.shareList.Add((object)txtDownloadDir.Text);
                Stats.LoadSave.UpdateShares();
            }
        }
    }
}