// ctrlCnn.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 GUIControlLogic.Error;
using ZANZI.ctrl;

namespace ZANZIClient
{
    /// <summary>
    /// Summary description for ctrlDiscovery.
    /// </summary>
    public class ctrlCnn : UserControl, Ictrl
    {
        private readonly clsCnn m_cls;
        private ContextMenu cmnuCnn;
        private ColumnHeader columnHeader1;
        private ColumnHeader columnHeader2;
        private ColumnHeader columnHeader3;
        private ColumnHeader columnHeader4;
        private ColumnHeader columnHeader5;


        private ColumnHeader columnHeader6;
        private ColumnHeader columnHeader7;
        private ColumnHeader columnHeader8;

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

        public ListView lstCnn;
        private MenuItem menuItem1;
        private MenuItem mnuHostConnect;

        //zzoi localized the hardcoded tabheader string
        //private string tabHeader;
        private ComponentResourceManager resources;
                                         // = new System.ComponentModel.ComponentResourceManager(typeof(ctrlDiscovery));


        public ctrlCnn(clsCnn cls, Container components)
        {
            m_cls = cls;
            this.components = components;
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();
            // TODO: Add any initialization after the InitializeComponent call
        }

        public ctrlCnn(clsCnn cls)
        {
            m_cls = cls;
           
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();
            // TODO: Add any initialization after the InitializeComponent call
        }

        #region Ictrl Members

        public override string Text
        {
            //zzoi localized the hardcoded tabheader string
            get { return resources.GetString("tabHeader.Text"); }
            //get{ return  "Neighbours";}
            //set{ m_CharValue = value;}
        }

        public  bool StaticControl
        {

            get { return true; }

        }

        /// <summary>
        /// Function for restCulture event raised when language is changed
        /// </summary>
        public void ResetCulture()
        {
            try
            {
                //zzoi 6 June 2008 impliment string replacements for text
                //zzoi 6 June 2008 added mnuitems for reset to other language
                Text = resources.GetString("tabHeader.Text");

                lstCnn.Columns[0].Text = resources.GetString("columnHeader1.Text");
                lstCnn.Columns[1].Text = resources.GetString("columnHeader2.Text");
                lstCnn.Columns[2].Text = resources.GetString("columnHeader3.Text");
                lstCnn.Columns[3].Text = resources.GetString("columnHeader4.Text");
                lstCnn.Columns[4].Text = resources.GetString("columnHeader5.Text");
                lstCnn.Columns[5].Text = resources.GetString("columnHeader6.Text");
                lstCnn.Columns[6].Text = resources.GetString("columnHeader7.Text");
                lstCnn.Columns[7].Text = resources.GetString("columnHeader8.Text");


                lstCnn.Refresh();
            }
            catch (Exception ex)
            {
                 new clsExeption(ex);
                //ErrByte = 1;
            }
        }

        #endregion

        private void MessageBox(string p)
        {
            throw new Exception("The method or operation is not implemented.");
        }


        /// <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 mnuHostConnect_Click(object sender, EventArgs e)
        {
            m_cls.Disconnect();
        }

        #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()
        {
            //zzoi this creates a error
            //System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ctrlCnn));

            //zzoi this is the correct line of code
            resources = new System.ComponentModel.ComponentResourceManager(typeof (ctrlCnn));
            this.lstCnn = new System.Windows.Forms.ListView();
            this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader8 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader7 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader4 = new System.Windows.Forms.ColumnHeader();
            this.columnHeader5 = new System.Windows.Forms.ColumnHeader();
            this.cmnuCnn = new System.Windows.Forms.ContextMenu();
            this.mnuHostConnect = new System.Windows.Forms.MenuItem();
            this.menuItem1 = new System.Windows.Forms.MenuItem();
            this.SuspendLayout();
            // 
            // lstCnn
            // 
            this.lstCnn.AllowColumnReorder = true;
            this.lstCnn.Columns.AddRange(new System.Windows.Forms.ColumnHeader[]
                                             {
                                                 this.columnHeader1,
                                                 this.columnHeader8,
                                                 this.columnHeader3,
                                                 this.columnHeader6,
                                                 this.columnHeader7,
                                                 this.columnHeader2,
                                                 this.columnHeader4,
                                                 this.columnHeader5
                                             });
            resources.ApplyResources(this.lstCnn, "lstCnn");
            this.lstCnn.FullRowSelect = true;
            this.lstCnn.HideSelection = false;
            this.lstCnn.MultiSelect = false;
            this.lstCnn.Name = "lstCnn";
            this.lstCnn.Sorting = System.Windows.Forms.SortOrder.Ascending;
            this.lstCnn.UseCompatibleStateImageBehavior = false;
            this.lstCnn.View = System.Windows.Forms.View.Details;
            // 
            // columnHeader1
            // 
            resources.ApplyResources(this.columnHeader1, "columnHeader1");
            // 
            // columnHeader8
            // 
            resources.ApplyResources(this.columnHeader8, "columnHeader8");
            // 
            // columnHeader3
            // 
            resources.ApplyResources(this.columnHeader3, "columnHeader3");
            // 
            // columnHeader6
            // 
            resources.ApplyResources(this.columnHeader6, "columnHeader6");
            // 
            // columnHeader7
            // 
            resources.ApplyResources(this.columnHeader7, "columnHeader7");
            // 
            // columnHeader2
            // 
            resources.ApplyResources(this.columnHeader2, "columnHeader2");
            // 
            // columnHeader4
            // 
            resources.ApplyResources(this.columnHeader4, "columnHeader4");
            // 
            // columnHeader5
            // 
            resources.ApplyResources(this.columnHeader5, "columnHeader5");
            // 
            // cmnuCnn
            // 
            this.cmnuCnn.MenuItems.AddRange(new System.Windows.Forms.MenuItem[]
                                                {
                                                    this.mnuHostConnect,
                                                    this.menuItem1
                                                });
            // 
            // mnuHostConnect
            // 
            this.mnuHostConnect.Index = 0;
            resources.ApplyResources(this.mnuHostConnect, "mnuHostConnect");
            this.mnuHostConnect.Click += new System.EventHandler(this.mnuHostConnect_Click);
            // 
            // menuItem1
            // 
            this.menuItem1.Index = 1;
            resources.ApplyResources(this.menuItem1, "menuItem1");
            // 
            // ctrlCnn
            // 
            this.ContextMenu = this.cmnuCnn;
            this.Controls.Add(this.lstCnn);
            this.Name = "ctrlCnn";
            resources.ApplyResources(this, "$this");
            this.ResumeLayout(false);
        }

        #endregion
    }
}