private void cbo_Mode_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            switch (cbo_Mode.SelectedIndex)
            {
            case (int)Mode.Normal:
                agentStatus = "Normal";
                break;

            case (int)Mode.Down:
                agentStatus = "Down";
                break;

            case (int)Mode.Drain:
                agentStatus = "Drain";
                break;

            default:
                break;
            }

            string    configFilePath = this.GetConfigurationFilePath();
            Xmlconfig myXmlcfg       = new Xmlconfig(configFilePath, false);

            myXmlcfg.Settings["AgentStatus"].Value = agentStatus;
            myXmlcfg.Save(configFilePath);
            myXmlcfg.Dispose();
        }
        private void WriteConfiguration(string configFilePath)
        {
            // Backup config file
            try
            {
                File.Move(configFilePath, configFilePath + ".bak");
            }
            catch { }

            Xmlconfig myXmlcfg = new Xmlconfig(configFilePath, true);

            myXmlcfg.Settings["Cpu"]["ImportanceFactor"].floatValue = cpuImportance;
            myXmlcfg.Settings["Cpu"]["ThresholdValue"].intValue     = cpuThresholdValue;
            myXmlcfg.Settings["Ram"]["ImportanceFactor"].floatValue = ramImportance;
            myXmlcfg.Settings["Ram"]["ThresholdValue"].floatValue   = ramThresholdValue;

            if (myTCPServices.Count == 0)
            {
                // Demo TCPService
                TCPService myTCPService = new TCPService();
                myXmlcfg.Settings["TCPService"]["Name"].Value                  = myTCPService.serviceName;
                myXmlcfg.Settings["TCPService"]["IPAddress"].Value             = myTCPService.serviceIPAddress;
                myXmlcfg.Settings["TCPService"]["Port"].intValue               = myTCPService.servicePort;
                myXmlcfg.Settings["TCPService"]["MaxConnections"].intValue     = myTCPService.serviceMaxConnections;
                myXmlcfg.Settings["TCPService"]["ImportanceFactor"].floatValue = myTCPService.serviceImportance;
            }
            else
            {
                foreach (TCPService myTCPService in myTCPServices)
                {
                    myXmlcfg.Settings["TCPService"]["Name"].Value                  = myTCPService.serviceName;
                    myXmlcfg.Settings["TCPService"]["IPAddress"].Value             = myTCPService.serviceIPAddress;
                    myXmlcfg.Settings["TCPService"]["Port"].intValue               = myTCPService.servicePort;
                    myXmlcfg.Settings["TCPService"]["MaxConnections"].intValue     = myTCPService.serviceMaxConnections;
                    myXmlcfg.Settings["TCPService"]["ImportanceFactor"].floatValue = myTCPService.serviceImportance;
                }
            }

            myXmlcfg.Settings["ReadAgentStatusFromConfig"].boolValue        = readAgentStatusFromConfig;
            myXmlcfg.Settings["ReadAgentStatusFromConfigInterval"].intValue = readAgentStatusFromConfigInterval;
            myXmlcfg.Settings["AgentStatus"].Value = agentStatus;

            myXmlcfg.Settings["Interval"].intValue = interval;

            myXmlcfg.Save(configFilePath);
            myXmlcfg.Dispose();
        }