private void OnAdd(object sender)
 {
     AgeDeploy agedeploy = new AgeDeploy();
     agedeploy.Color = "#FFEFF8F8";
     List<AgeDeploy> collection = new List<AgeDeploy>();
     collection.AddRange(AgeDeployCollection);
     collection.Add(agedeploy);
     this.AgeDeployCollection = collection;
     this.AgeDeployGridView.SelectedItem = agedeploy;
     //设置保存、放弃修改按钮的可用性
     this.isChanged = true;
 }
        /// <summary>
        /// 将机龄配置XML转换成机龄配置对象的集合
        /// </summary>
        /// <returns></returns>
        private void CreatAgeDeployCollection()
        {
            List<AgeDeploy> collection = new List<AgeDeploy>();//将机龄配置XML转换成机龄配置对象的集合

            if (this.ViewXmlConfig.FirstOrDefault(p => p.ConfigType == "机龄配置") != null)
            {
                XElement xelement = this.ViewXmlConfig.FirstOrDefault(p => p.ConfigType == "机龄配置").XmlContent;

                XElement agecolor = null;
                XmlConfig colorconfig = this.ViewXmlConfig.FirstOrDefault(p => p.ConfigType == "颜色配置");
                if (colorconfig != null && colorconfig.XmlContent.Descendants("Type").Any(p => p.Attribute("TypeName").Value == "机龄"))
                {
                    agecolor = colorconfig.XmlContent.Descendants("Type").FirstOrDefault(p => p.Attribute("TypeName").Value == "机龄");
                }
                if (xelement != null)
                {
                    foreach (var item in xelement.Descendants("Item"))
                    {
                        AgeDeploy agedeploy = new AgeDeploy();
                        agedeploy.Name = item.Value;
                        agedeploy.StartYear = Convert.ToUInt32(item.Attribute("Start").Value);
                        agedeploy.EndYear = Convert.ToUInt32(item.Attribute("End").Value);
                        if (agecolor != null)
                        {
                            agedeploy.Color = agecolor.Descendants("Item")
                                .FirstOrDefault(p => p.Attribute("Name").Value == agedeploy.Name).Attribute("Color").Value;
                        }
                        collection.Add(agedeploy);
                    }
                }
            }
            AgeDeployCollection = collection;
        }