context: /* Copyright (c) 2004, 2005 MySQL AB
     Use is subject to license terms
  
     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; version 2 of the License.
  
     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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA */
  
  using System;
  using System.Drawing;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Data;
  using System.Threading;
  
  namespace NDB_CPC
  {
  	/// <summary>
  	/// Summary description for Form1.
  	/// </summary>
  	public class CPC : System.Windows.Forms.Form
  	{
  		private System.Windows.Forms.TreeView tvComputerCluster;
  		private System.Windows.Forms.ContextMenu ctxTreeViewMenu;
  		private System.Windows.Forms.ColumnHeader chComputer;
  		private System.Windows.Forms.ColumnHeader chProcessName;
  		private System.Windows.Forms.ContextMenu ctxListViewMenu;
  		private System.Windows.Forms.MenuItem mainMenuItem;
  		private System.Windows.Forms.ColumnHeader chProcesses;
  		private System.Windows.Forms.MainMenu mainMenu;
  		private System.Windows.Forms.Panel panel1;
  		private System.Windows.Forms.MenuItem menuItem7;
  		private System.Windows.Forms.MenuItem menuItem10;
  		private System.Windows.Forms.MenuItem mainMenuFile;
  		private System.Windows.Forms.MenuItem mainMenuComputer;
  		private System.Windows.Forms.MenuItem subMenuComputerAdd;
  		private System.Windows.Forms.MenuItem subMenuComputerRemove;
  		private System.Windows.Forms.MenuItem subMenuComputerDisconnect;
  		private System.Windows.Forms.MenuItem subMenuComputerProperties;
  		private System.ComponentModel.IContainer components;
  		
  		private System.Windows.Forms.MenuItem menuItem3;
  		private System.Windows.Forms.MenuItem computerMenuAdd;
  		private System.Windows.Forms.MenuItem computerMenuRemove;
  		private System.Windows.Forms.MenuItem menuItem5;
  		private System.Windows.Forms.MenuItem computerMenuDisconnect;
  		private System.Windows.Forms.MenuItem computerMenuConnect;
  		private System.Windows.Forms.MenuItem computerMenuProperties;
  		private System.Windows.Forms.MenuItem menuItem11;
  		private System.Windows.Forms.MenuItem tvCtxMenuComputerAdd;
  		private System.Windows.Forms.MenuItem tvCtxMenuComputerRemove;
  		private System.Windows.Forms.MenuItem tvCtxMenuComputerConnect;
  		private System.Windows.Forms.MenuItem tvCtxMenuComputerDisconnect;
  		private System.Windows.Forms.MenuItem tvCtxMenuComputerDefine;
  		private System.Windows.Forms.MenuItem tvCtxMenuDatabaseNew;
  		private System.Windows.Forms.MenuItem menuItem1;
  		private System.Windows.Forms.MenuItem menuItem2;
  		private System.Windows.Forms.MenuItem mainMenuDatabase;
  		private System.Windows.Forms.MenuItem subMenuDatabaseCreate;
  		private System.Windows.Forms.MenuItem menuItem8;
  		private System.Windows.Forms.MenuItem tvCtxMenuProperties;
  		private System.Windows.Forms.ImageList imageTV;
  
  		private ComputerMgmt computerMgmt;
  		private System.Windows.Forms.MenuItem computerMenuRefresh;
  		private System.Windows.Forms.ListView listView;
  		private System.Windows.Forms.ColumnHeader chComputerIP;
  		private System.Windows.Forms.ColumnHeader chDatabase;
  		private System.Windows.Forms.ColumnHeader chName;
  		private System.Windows.Forms.ColumnHeader chOwner;
  		private System.Windows.Forms.ColumnHeader chStatus;
  		private System.Windows.Forms.Splitter splitter2;
  		private System.Windows.Forms.Splitter splitterVertical;
  		private System.Windows.Forms.Splitter splitterHorizont;
  		private Thread guiThread;
  		private float resizeWidthRatio;
  		private System.Windows.Forms.MenuItem menuItem6;
  		private System.Windows.Forms.MenuItem menuGetStatus;
  		private System.Windows.Forms.MenuItem menuStartProcess;
  		private System.Windows.Forms.MenuItem menuRestartProcess;
  		private System.Windows.Forms.MenuItem menuStopProcess;
  		private System.Windows.Forms.MenuItem menuRemoveProcess;
  		private System.Windows.Forms.MenuItem menuRefresh;
  		private System.Windows.Forms.OpenFileDialog openHostFileDialog;
  		private System.Windows.Forms.SaveFileDialog saveHostFileDialog;
  		private float resizeHeightRatio;
  		private System.Windows.Forms.TextBox mgmConsole;
  		int i;
  		public CPC()
  		{
  			//
  			// Required for Windows Form Designer support
  			//
  			InitializeComponent();
  		
  			// TODO: Add any constructor code after InitializeComponent call
  			//
  			computerMgmt = new ComputerMgmt();
  			guiThread = new Thread(new ThreadStart(updateGuiThread));
  			
  	//		guiThread.Start();
  		}
  
  		/// <summary>
  		/// Clean up any resources being used.
  		/// </summary>
  		protected override void Dispose( bool disposing )
  		{
  			if( disposing )
  			{
  				if (components != null) 
  				{
  					components.Dispose();
  				}
  			}
  			//guiThread.Abort();
  			base.Dispose( disposing );
  		}
  
  		#region Windows Form 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()
  		{
  			this.components = new System.ComponentModel.Container();
  			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(CPC));
  			this.tvComputerCluster = new System.Windows.Forms.TreeView();
  			this.ctxTreeViewMenu = new System.Windows.Forms.ContextMenu();
  			this.tvCtxMenuComputerAdd = new System.Windows.Forms.MenuItem();
  			this.tvCtxMenuComputerRemove = new System.Windows.Forms.MenuItem();
  			this.menuGetStatus = new System.Windows.Forms.MenuItem();
  			this.menuItem6 = new System.Windows.Forms.MenuItem();
  			this.tvCtxMenuComputerConnect = new System.Windows.Forms.MenuItem();
  			this.tvCtxMenuComputerDisconnect = new System.Windows.Forms.MenuItem();
  			this.tvCtxMenuDatabaseNew = new System.Windows.Forms.MenuItem();
  			this.tvCtxMenuComputerDefine = new System.Windows.Forms.MenuItem();
  			this.menuItem8 = new System.Windows.Forms.MenuItem();
  			this.tvCtxMenuProperties = new System.Windows.Forms.MenuItem();
  			this.imageTV = new System.Windows.Forms.ImageList(this.components);
  			this.ctxListViewMenu = new System.Windows.Forms.ContextMenu();
  			this.menuStartProcess = new System.Windows.Forms.MenuItem();
  			this.menuRestartProcess = new System.Windows.Forms.MenuItem();
  			this.menuStopProcess = new System.Windows.Forms.MenuItem();
  			this.menuRemoveProcess = new System.Windows.Forms.MenuItem();
  			this.menuRefresh = new System.Windows.Forms.MenuItem();
  			this.computerMenuAdd = new System.Windows.Forms.MenuItem();
  			this.menuItem3 = new System.Windows.Forms.MenuItem();
  			this.computerMenuRemove = new System.Windows.Forms.MenuItem();
  			this.menuItem5 = new System.Windows.Forms.MenuItem();
  			this.computerMenuDisconnect = new System.Windows.Forms.MenuItem();
  			this.computerMenuConnect = new System.Windows.Forms.MenuItem();
  			this.menuItem11 = new System.Windows.Forms.MenuItem();
  			this.computerMenuProperties = new System.Windows.Forms.MenuItem();
  			this.computerMenuRefresh = new System.Windows.Forms.MenuItem();
  			this.chComputer = new System.Windows.Forms.ColumnHeader();
  			this.chProcessName = new System.Windows.Forms.ColumnHeader();
  			this.mainMenuItem = new System.Windows.Forms.MenuItem();
  			this.chProcesses = new System.Windows.Forms.ColumnHeader();
  			this.mainMenu = new System.Windows.Forms.MainMenu();
  			this.mainMenuFile = new System.Windows.Forms.MenuItem();
  			this.menuItem2 = new System.Windows.Forms.MenuItem();
  			this.menuItem1 = new System.Windows.Forms.MenuItem();
  			this.mainMenuComputer = new System.Windows.Forms.MenuItem();
  			this.subMenuComputerAdd = new System.Windows.Forms.MenuItem();
  			this.menuItem7 = new System.Windows.Forms.MenuItem();
  			this.subMenuComputerDisconnect = new System.Windows.Forms.MenuItem();
  			this.subMenuComputerRemove = new System.Windows.Forms.MenuItem();
  			this.menuItem10 = new System.Windows.Forms.MenuItem();
  			this.subMenuComputerProperties = new System.Windows.Forms.MenuItem();
  			this.mainMenuDatabase = new System.Windows.Forms.MenuItem();
  			this.subMenuDatabaseCreate = new System.Windows.Forms.MenuItem();
  			this.panel1 = new System.Windows.Forms.Panel();
  			this.mgmConsole = new System.Windows.Forms.TextBox();
  			this.splitterHorizont = new System.Windows.Forms.Splitter();
  			this.splitter2 = new System.Windows.Forms.Splitter();
  			this.listView = new System.Windows.Forms.ListView();
  			this.chComputerIP = new System.Windows.Forms.ColumnHeader();
  			this.chStatus = new System.Windows.Forms.ColumnHeader();
  			this.chDatabase = new System.Windows.Forms.ColumnHeader();
  			this.chName = new System.Windows.Forms.ColumnHeader();
  			this.chOwner = new System.Windows.Forms.ColumnHeader();
  			this.splitterVertical = new System.Windows.Forms.Splitter();
  			this.openHostFileDialog = new System.Windows.Forms.OpenFileDialog();
  			this.saveHostFileDialog = new System.Windows.Forms.SaveFileDialog();
  			this.panel1.SuspendLayout();
  			this.SuspendLayout();
  			// 
  			// tvComputerCluster
  			// 
  			this.tvComputerCluster.CausesValidation = false;
  			this.tvComputerCluster.ContextMenu = this.ctxTreeViewMenu;
  			this.tvComputerCluster.Dock = System.Windows.Forms.DockStyle.Left;
  			this.tvComputerCluster.ImageList = this.imageTV;
  			this.tvComputerCluster.Name = "tvComputerCluster";
  			this.tvComputerCluster.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
  																						  new System.Windows.Forms.TreeNode("Computer", 0, 0),
  																						  new System.Windows.Forms.TreeNode("Database", 5, 5)});
  			this.tvComputerCluster.Size = new System.Drawing.Size(104, 333);
  			this.tvComputerCluster.TabIndex = 5;
  			this.tvComputerCluster.MouseDown += new System.Windows.Forms.MouseEventHandler(this.tvComputerCluster_MouseDown);
  			this.tvComputerCluster.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tvComputerCluster_AfterSelect);
  			this.tvComputerCluster.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(this.tvComputerCluster_BeforeCollapse);
  			this.tvComputerCluster.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.tvComputerCluster_BeforeExpand);
  			// 
  			// ctxTreeViewMenu
  			// 
  			this.ctxTreeViewMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  																							this.tvCtxMenuComputerAdd,
  																							this.tvCtxMenuComputerRemove,
  																							this.menuGetStatus,
  																							this.menuItem6,
  																							this.tvCtxMenuComputerConnect,
  																							this.tvCtxMenuComputerDisconnect,
  																							this.tvCtxMenuDatabaseNew,
  																							this.tvCtxMenuComputerDefine,
  																							this.menuItem8,
  																							this.tvCtxMenuProperties});
  			this.ctxTreeViewMenu.Popup += new System.EventHandler(this.ctxTreeViewMenu_Popup);
  			// 
  			// tvCtxMenuComputerAdd
  			// 
  			this.tvCtxMenuComputerAdd.Index = 0;
  			this.tvCtxMenuComputerAdd.Text = "Add computer";
  			this.tvCtxMenuComputerAdd.Click += new System.EventHandler(this.computerMenuAdd_Click);
  			// 
  			// tvCtxMenuComputerRemove
  			// 
  			this.tvCtxMenuComputerRemove.Index = 1;
  			this.tvCtxMenuComputerRemove.Text = "Remove computer";
  			this.tvCtxMenuComputerRemove.Click += new System.EventHandler(this.computerMenuRemove_Click);
  			// 
  			// menuGetStatus
  			// 
  			this.menuGetStatus.Index = 2;
  			this.menuGetStatus.Text = "Get Status";
  			this.menuGetStatus.Click += new System.EventHandler(this.menuGetStatus_Click);
  			// 
  			// menuItem6
  			// 
  			this.menuItem6.Index = 3;
  			this.menuItem6.Text = "-";
  			// 
  			// tvCtxMenuComputerConnect
  			// 
  			this.tvCtxMenuComputerConnect.Index = 4;
  			this.tvCtxMenuComputerConnect.Text = "Connect";
  			// 
  			// tvCtxMenuComputerDisconnect
  			// 
  			this.tvCtxMenuComputerDisconnect.Index = 5;
  			this.tvCtxMenuComputerDisconnect.Text = "Disconnect";
  			// 
  			// tvCtxMenuDatabaseNew
  			// 
  			this.tvCtxMenuDatabaseNew.Index = 6;
  			this.tvCtxMenuDatabaseNew.Text = "Create database...";
  			this.tvCtxMenuDatabaseNew.Click += new System.EventHandler(this.subMenuDatabaseCreate_Click);
  			// 
  			// tvCtxMenuComputerDefine
  			// 
  			this.tvCtxMenuComputerDefine.Index = 7;
  			this.tvCtxMenuComputerDefine.Text = "Define process...";
  			this.tvCtxMenuComputerDefine.Click += new System.EventHandler(this.tvCtxMenuComputerDefine_Click);
  			// 
  			// menuItem8
  			// 
  			this.menuItem8.Index = 8;
  			this.menuItem8.Text = "-";
  			// 
  			// tvCtxMenuProperties
  			// 
  			this.tvCtxMenuProperties.Index = 9;
  			this.tvCtxMenuProperties.Text = "Properties";
  			// 
  			// imageTV
  			// 
  			this.imageTV.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
  			this.imageTV.ImageSize = new System.Drawing.Size(16, 16);
  			this.imageTV.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageTV.ImageStream")));
  			this.imageTV.TransparentColor = System.Drawing.Color.Transparent;
  			// 
  			// ctxListViewMenu
  			// 
  			this.ctxListViewMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  																							this.menuStartProcess,
  																							this.menuRestartProcess,
  																							this.menuStopProcess,
  																							this.menuRemoveProcess,
  																							this.menuRefresh});
  			this.ctxListViewMenu.Popup += new System.EventHandler(this.ctxListViewMenu_Popup);
  			// 
  			// menuStartProcess
  			// 
  			this.menuStartProcess.Index = 0;
  			this.menuStartProcess.Text = "Start process";
  			this.menuStartProcess.Click += new System.EventHandler(this.startProcess);
  			// 
  			// menuRestartProcess
  			// 
  			this.menuRestartProcess.Index = 1;
  			this.menuRestartProcess.Text = "Restart process";
  			this.menuRestartProcess.Click += new System.EventHandler(this.restartProcess);
  			// 
  			// menuStopProcess
  			// 
  			this.menuStopProcess.Index = 2;
  			this.menuStopProcess.Text = "Stop process";
  			this.menuStopProcess.Click += new System.EventHandler(this.stopProcess);
  			// 
  			// menuRemoveProcess
  			// 
  			this.menuRemoveProcess.Index = 3;
  			this.menuRemoveProcess.Text = "Remove process";
  			this.menuRemoveProcess.Click += new System.EventHandler(this.removeProcess);
  			// 
  			// menuRefresh
  			// 
  			this.menuRefresh.Index = 4;
  			this.menuRefresh.Text = "Refresh";
  			this.menuRefresh.Click += new System.EventHandler(this.menuRefresh_Click);
  			// 
  			// computerMenuAdd
  			// 
  			this.computerMenuAdd.Index = -1;
  			this.computerMenuAdd.Text = "Add";
  			this.computerMenuAdd.Click += new System.EventHandler(this.computerMenuAdd_Click);
  			// 
  			// menuItem3
  			// 
  			this.menuItem3.Index = -1;
  			this.menuItem3.Text = "-";
  			// 
  			// computerMenuRemove
  			// 
  			this.computerMenuRemove.Index = -1;
  			this.computerMenuRemove.Text = "Remove";
  			this.computerMenuRemove.Click += new System.EventHandler(this.computerMenuRemove_Click);
  			// 
  			// menuItem5
  			// 
  			this.menuItem5.Index = -1;
  			this.menuItem5.Text = "-";
  			// 
  			// computerMenuDisconnect
  			// 
  			this.computerMenuDisconnect.Index = -1;
  			this.computerMenuDisconnect.Text = "Disconnect";
  			// 
  			// computerMenuConnect
  			// 
  			this.computerMenuConnect.Index = -1;
  			this.computerMenuConnect.Text = "Connect";
  			// 
  			// menuItem11
  			// 
  			this.menuItem11.Index = -1;
  			this.menuItem11.Text = "-";
  			// 
  			// computerMenuProperties
  			// 
  			this.computerMenuProperties.Index = -1;
  			this.computerMenuProperties.Text = "Properties";
  			// 
  			// computerMenuRefresh
  			// 
  			this.computerMenuRefresh.Index = -1;
  			this.computerMenuRefresh.Text = "Refresh";
  			this.computerMenuRefresh.Click += new System.EventHandler(this.computerMenuRefresh_Click);
  			// 
  			// chComputer
  			// 
  			this.chComputer.Text = "Computer";
  			// 
  			// chProcessName
  			// 
  			this.chProcessName.Text = "Name";
  			// 
  			// mainMenuItem
  			// 
  			this.mainMenuItem.Index = -1;
  			this.mainMenuItem.Text = "File";
  			// 
  			// chProcesses
  			// 
  			this.chProcesses.Text = "Id";
  			// 
  			// mainMenu
  			// 
  			this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  																					 this.mainMenuFile,
  																					 this.mainMenuComputer,
  																					 this.mainMenuDatabase});
  			// 
  			// mainMenuFile
  			// 
  			this.mainMenuFile.Index = 0;
  			this.mainMenuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  																						 this.menuItem2,
  																						 this.menuItem1});
  			this.mainMenuFile.Text = "&File";
  			// 
  			// menuItem2
  			// 
  			this.menuItem2.Index = 0;
  			this.menuItem2.Text = "&Import...";
  			this.menuItem2.Click += new System.EventHandler(this.importHostFile);
  			// 
  			// menuItem1
  			// 
  			this.menuItem1.Index = 1;
  			this.menuItem1.Text = "&Export...";
  			this.menuItem1.Click += new System.EventHandler(this.exportHostFile);
  			// 
  			// mainMenuComputer
  			// 
  			this.mainMenuComputer.Index = 1;
  			this.mainMenuComputer.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  																							 this.subMenuComputerAdd,
  																							 this.menuItem7,
  																							 this.subMenuComputerDisconnect,
  																							 this.subMenuComputerRemove,
  																							 this.menuItem10,
  																							 this.subMenuComputerProperties});
  			this.mainMenuComputer.Text = "&Computer";
  			// 
  			// subMenuComputerAdd
  			// 
  			this.subMenuComputerAdd.Index = 0;
  			this.subMenuComputerAdd.Text = "&Add Computer";
  			this.subMenuComputerAdd.Click += new System.EventHandler(this.computerMenuAdd_Click);
  			// 
  			// menuItem7
  			// 
  			this.menuItem7.Index = 1;
  			this.menuItem7.Text = "-";
  			// 
  			// subMenuComputerDisconnect
  			// 
  			this.subMenuComputerDisconnect.Index = 2;
  			this.subMenuComputerDisconnect.Text = "&Disconnect";
  			// 
  			// subMenuComputerRemove
  			// 
  			this.subMenuComputerRemove.Index = 3;
  			this.subMenuComputerRemove.Text = "&Remove Computer";
  			this.subMenuComputerRemove.Click += new System.EventHandler(this.computerMenuRemove_Click);
  			// 
  			// menuItem10
  			// 
  			this.menuItem10.Index = 4;
  			this.menuItem10.Text = "-";
  			// 
  			// subMenuComputerProperties
  			// 
  			this.subMenuComputerProperties.Index = 5;
  			this.subMenuComputerProperties.Text = "&Properties";
  			// 
  			// mainMenuDatabase
  			// 
  			this.mainMenuDatabase.Index = 2;
  			this.mainMenuDatabase.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
  																							 this.subMenuDatabaseCreate});
  			this.mainMenuDatabase.Text = "&Database";
  			this.mainMenuDatabase.Click += new System.EventHandler(this.subMenuDatabaseCreate_Click);
  			// 
  			// subMenuDatabaseCreate
  			// 
  			this.subMenuDatabaseCreate.Index = 0;
  			this.subMenuDatabaseCreate.Text = "&Create database...";
  			this.subMenuDatabaseCreate.Click += new System.EventHandler(this.subMenuDatabaseCreate_Click);
  			// 
  			// panel1
  			// 
  			this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
  																				 this.mgmConsole,
  																				 this.splitterHorizont,
  																				 this.splitter2,
  																				 this.listView});
  			this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
  			this.panel1.Location = new System.Drawing.Point(104, 0);
  			this.panel1.Name = "panel1";
  			this.panel1.Size = new System.Drawing.Size(384, 333);
  			this.panel1.TabIndex = 6;
  			// 
  			// mgmConsole
  			// 
  			this.mgmConsole.AccessibleRole = System.Windows.Forms.AccessibleRole.StaticText;
  			this.mgmConsole.Dock = System.Windows.Forms.DockStyle.Bottom;
  			this.mgmConsole.Location = new System.Drawing.Point(0, 231);
  			this.mgmConsole.Multiline = true;
  			this.mgmConsole.Name = "mgmConsole";
  			this.mgmConsole.Size = new System.Drawing.Size(384, 96);
  			this.mgmConsole.TabIndex = 5;
  			this.mgmConsole.Text = "textBox1";
  			this.mgmConsole.TextChanged += new System.EventHandler(this.mgmConsole_TextChanged);
  			this.mgmConsole.Enter += new System.EventHandler(this.mgmConsole_Enter);
  			// 
  			// splitterHorizont
  			// 
  			this.splitterHorizont.Dock = System.Windows.Forms.DockStyle.Bottom;
  			this.splitterHorizont.Location = new System.Drawing.Point(0, 327);
  			this.splitterHorizont.MinExtra = 100;
  			this.splitterHorizont.MinSize = 100;
  			this.splitterHorizont.Name = "splitterHorizont";
  			this.splitterHorizont.Size = new System.Drawing.Size(384, 3);
  			this.splitterHorizont.TabIndex = 4;
  			this.splitterHorizont.TabStop = false;
  			// 
  			// splitter2
  			// 
  			this.splitter2.Dock = System.Windows.Forms.DockStyle.Bottom;
  			this.splitter2.Location = new System.Drawing.Point(0, 330);
  			this.splitter2.Name = "splitter2";
  			this.splitter2.Size = new System.Drawing.Size(384, 3);
  			this.splitter2.TabIndex = 2;
  			this.splitter2.TabStop = false;
  			// 
  			// listView
  			// 
  			this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
  																					   this.chComputerIP,
  																					   this.chStatus,
  																					   this.chDatabase,
  																					   this.chName,
  																					   this.chOwner});
  			this.listView.ContextMenu = this.ctxListViewMenu;
  			this.listView.Dock = System.Windows.Forms.DockStyle.Fill;
  			this.listView.FullRowSelect = true;
  			this.listView.Name = "listView";
  			this.listView.Size = new System.Drawing.Size(384, 333);
  			this.listView.TabIndex = 0;
  			this.listView.View = System.Windows.Forms.View.Details;
  			this.listView.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.listView_ColumnClick_1);
  			this.listView.SelectedIndexChanged += new System.EventHandler(this.listView_SelectedIndexChanged);
  			// 
  			// chComputerIP
  			// 
  			this.chComputerIP.Text = "IP Adress";
  			// 
  			// chStatus
  			// 
  			this.chStatus.Text = "Status";
  			// 
  			// chDatabase
  			// 
  			this.chDatabase.Text = "Database";
  			// 
  			// chName
  			// 
  			this.chName.Text = "Name";
  			// 
  			// chOwner
  			// 
  			this.chOwner.Text = "Owner";
  			// 
  			// splitterVertical
  			// 
  			this.splitterVertical.Location = new System.Drawing.Point(104, 0);
  			this.splitterVertical.MinSize = 100;
  			this.splitterVertical.Name = "splitterVertical";
  			this.splitterVertical.Size = new System.Drawing.Size(3, 333);
  			this.splitterVertical.TabIndex = 7;
  			this.splitterVertical.TabStop = false;
  			this.splitterVertical.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.splitterVertical_SplitterMoved);
  			// 
  			// openHostFileDialog
  			// 
  			this.openHostFileDialog.DefaultExt = "cpc";
  			this.openHostFileDialog.Filter = "CPCd configuration files (*.cpc)|*.cpc| All Files (*.*)|*.*";
  			this.openHostFileDialog.Title = "Import a CPCd configuration file";
  			this.openHostFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.openHostFileDialog_FileOk);
  			// 
  			// saveHostFileDialog
  			// 
  			this.saveHostFileDialog.Filter = "CPCd configuration files (*.cpc)|*.cpc| All Files (*.*)|*.*";
  			this.saveHostFileDialog.Title = "Export a CPCd configuration file";
  			this.saveHostFileDialog.FileOk += new System.ComponentModel.CancelEventHandler(this.saveHostFileDialog_FileOk);
  			// 
  			// CPC
  			// 
  			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  			this.ClientSize = new System.Drawing.Size(488, 333);
  			this.Controls.AddRange(new System.Windows.Forms.Control[] {
  																		  this.splitterVertical,
  																		  this.panel1,
  																		  this.tvComputerCluster});
  			this.Menu = this.mainMenu;
  			this.Name = "CPC";
  			this.Text = "CPC";
  			this.Resize += new System.EventHandler(this.CPC_Resize);
  			this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CPC_MouseDown);
  			this.Closing += new System.ComponentModel.CancelEventHandler(this.CPC_Closing);
  			this.Load += new System.EventHandler(this.CPC_Load);
  			this.Activated += new System.EventHandler(this.CPC_Activated);
  			this.Paint += new System.Windows.Forms.PaintEventHandler(this.CPC_Paint);
  			this.panel1.ResumeLayout(false);
  			this.ResumeLayout(false);
  
  		}
  		#endregion
  
  		/// <summary>
  		/// The main entry point for the application.
  		/// </summary>
  		[STAThread]
  		static void Main() 
  		{
  			Application.Run(new CPC());
  
  		}
  
  		private void tvComputerCluster_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
  		{
  			if(e.Node.Text.ToString().Equals("Database")) 
  			{
  				updateListViews("Database");
  			
  				return;
  			}
  			if(e.Node.Text.ToString().Equals("Computer"))
  			{				
  				//updateListViews();
  				
  				updateListViews("Computer");
  				return;
  			}
  			if(e.Node.Parent.Text.ToString().Equals("Database"))
  			{
  				//updateListViews();
  				listView.Columns.Clear();
  				listView.Columns.Add(this.chName);
  				listView.Columns.Add(this.chDatabase);
  				listView.Columns.Add(this.chStatus);
  				listView.Columns.Add(this.chOwner);
  				updateDatabaseView(e.Node.Text.ToString());
  			}
  
  			if(e.Node.Parent.Text=="Computer")
  			{
  				//updateListViews();
  				
  				Computer c=computerMgmt.getComputer(e.Node.Text.ToString());
  				string [] processcols= new string[5];
  				ArrayList processes;
  				processes = c.getProcesses();
  				listView.Items.Clear();
  				listView.Columns.Clear();
  				listView.Columns.Add(this.chComputer);
  				listView.Columns.Add(this.chDatabase);
  				listView.Columns.Add(this.chName);
  				listView.Columns.Add(this.chStatus);
  				listView.Columns.Add(this.chOwner);
  				if(processes != null ) 
  				{
  					
  					listView.BeginUpdate();
  					foreach(Process p in processes) 
  					{
  						processcols[0]=p.getComputer().getName();
  						processcols[1]=p.getDatabase();
  						processcols[2]=p.getName();
  						processcols[3]=p.getStatusString();
  						processcols[4]=p.getOwner();
  						ListViewItem lvp= new ListViewItem(processcols);
  						listView.Items.Add(lvp);
  					}
  					
  					listView.EndUpdate();
  				}
  
  
  				listView.Show();
  			}
  		
  		}
  
  		
  
  		private void ctxTreeViewMenu_Popup(object sender, System.EventArgs e)
  		{
  				tvCtxMenuComputerAdd.Enabled=true;
  				tvCtxMenuComputerRemove.Enabled=true;
  				tvCtxMenuComputerConnect.Enabled=true;
  				tvCtxMenuComputerDisconnect.Enabled=true;
  				tvCtxMenuComputerDefine.Enabled=true;
  				menuGetStatus.Enabled=true;	
  				tvCtxMenuDatabaseNew.Enabled=true;
  				tvCtxMenuComputerAdd.Visible=true;
  				tvCtxMenuComputerRemove.Visible=true;
  				tvCtxMenuComputerConnect.Visible=true;
  				tvCtxMenuComputerDisconnect.Visible=true;
  				tvCtxMenuComputerDefine.Visible=true;
  				tvCtxMenuDatabaseNew.Visible=true;	
  				tvCtxMenuProperties.Visible=true;
  				menuGetStatus.Visible=true;
  
  				if(tvComputerCluster.SelectedNode.Text.Equals("Computer"))
  				{
  					tvCtxMenuComputerAdd.Enabled=true;
  					tvCtxMenuComputerRemove.Enabled=false;
  					tvCtxMenuComputerConnect.Enabled=false;
  					tvCtxMenuComputerDisconnect.Enabled=false;
  					tvCtxMenuComputerDefine.Enabled=false;
  					tvCtxMenuDatabaseNew.Visible=false;
  					menuGetStatus.Visible=false;
  					return;
  				}
  				
  				if(tvComputerCluster.SelectedNode.Text.Equals("Database"))
  				{
  				//	ctxTreeViewMenu.MenuItems.Add(menuDatabaseItem1);
  					tvCtxMenuComputerAdd.Visible=false;
  					tvCtxMenuComputerRemove.Visible=false;
  					tvCtxMenuComputerConnect.Visible=false;
  					tvCtxMenuComputerDisconnect.Visible=false;
  					tvCtxMenuComputerDefine.Visible=false;
  					tvCtxMenuDatabaseNew.Visible=true;
  					tvCtxMenuDatabaseNew.Enabled=true;
  					menuGetStatus.Visible=false;
  					menuItem6.Visible=false;
  					return;
  				}
  				if(tvComputerCluster.SelectedNode.Parent.Text.Equals("Computer"))
  				{
  				
  					Computer c= computerMgmt.getComputer(tvComputerCluster.SelectedNode.Text.ToString());
  					if(c.getStatus().Equals(Computer.Status.Disconnected)) 
  					{
  						tvCtxMenuComputerConnect.Enabled=true;
  						tvCtxMenuComputerDisconnect.Enabled=false;
  					}
  					else 
  					{
  						tvCtxMenuComputerDisconnect.Enabled=true;
  						tvCtxMenuComputerConnect.Enabled=false;
  					}
  					
  					tvCtxMenuComputerAdd.Enabled=false;
  					tvCtxMenuComputerRemove.Enabled=true;
  					menuGetStatus.Visible=false;
  
  					tvCtxMenuComputerDefine.Enabled=true;	
  					tvCtxMenuDatabaseNew.Visible=false;
  					return;
  				}
  					
  				if(tvComputerCluster.SelectedNode.Parent.Text.Equals("Database"))
  				{
  					tvCtxMenuComputerAdd.Enabled=true;
  					tvCtxMenuComputerRemove.Enabled=false;
  					tvCtxMenuComputerConnect.Enabled=false;
  					tvCtxMenuComputerDisconnect.Enabled=false;
  					tvCtxMenuComputerDefine.Enabled=false;
  					tvCtxMenuDatabaseNew.Visible=true;
  					menuGetStatus.Visible=true;
  					return;
  				}
  
  			
  		}
  
  
  		private void listView_SelectedIndexChanged(object sender, System.EventArgs e)
  		{
  			//MessageBox.Show(listView.SelectedItems[0].Text);
  		}
  
  	
  		private void tvComputerCluster_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
  		{ /*
  			TreeNode node = tvComputerCluster.GetNodeAt(e.X,e.Y);
  			if(node==null)
  			{
  				return;
  			}
  			tvComputerCluster.SelectedNode=node;
  //			updateListViews();
  			tvComputerCluster.SelectedNode.Expand();
  			*/
  		}
  
  
  		private void subMenuComputerRemove_Click(object sender, System.EventArgs e)
  		{
  			//ComputerRemoveDialog crd=new ComputerRemoveDialog(computerMgmt);
  			//crd.Show();
  			//updateListViews();
  /*			string computer =  tvComputerCluster.SelectedNode.Text.ToString();
  			if(MessageBox.Show(this,"Are you sure you want to remove: " +computer+ "?","Remove computer",MessageBoxButtons.YesNo)==DialogResult.Yes)
  			{
  				computerMgmt.RemoveComputer(computer);	
  			}
  */
  		}
  
  		private void subMenuComputerAdd_Click(object sender, System.EventArgs e)
  		{
  			ComputerAddDialog cad=new ComputerAddDialog(computerMgmt);
  			cad.ShowDialog();
  			cad.Dispose();
  ///			updateListViews(tvComputerCluster.SelectedNode.Text.ToString());
  		}
  
  		
  
  		private void updateListViews(string node)
  		{
  			if(node.Equals("Computer"))
  			{
  				listView.Columns.Clear();
  				listView.Items.Clear();
  				ArrayList list= computerMgmt.getComputerCollection();
  
gt: 				string [] computercols= new string[2];