/// <summary> /// 读取用户配置 /// </summary> private void ReadUserConfig() { //读取模式配置 ModeList = new List <ModeConfig>(); XmlDocument ModeDoc = new XmlDocument(); XmlReaderSettings ModeSetting = new XmlReaderSettings { IgnoreComments = true }; XmlReader ModeReader = XmlReader.Create(Application.StartupPath + "\\Config\\ReadingRoomTwo\\ModeConfig.xml", ModeSetting); ModeDoc.Load(ModeReader); XmlNode ModeRootNode = ModeDoc.SelectSingleNode("Modes"); XmlNodeList ModeRootChilds = ModeRootNode.ChildNodes; foreach (XmlNode Node in ModeRootChilds) { ModeConfig Mode = new ModeConfig(); XmlElement Element = (XmlElement)Node; XmlNodeList Childs = Element.ChildNodes; Mode.ModeName = Childs.Item(0).InnerText; Mode.Relays = Childs.Item(1).InnerText; ModeList.Add(Mode); } ModeReader.Close(); //读取灯光配置 LightList = new List <LightConfig>(); XmlDocument LightDoc = new XmlDocument(); XmlReaderSettings LightSetting = new XmlReaderSettings { IgnoreComments = true }; XmlReader LightReader = XmlReader.Create(Application.StartupPath + "\\Config\\ReadingRoomTwo\\LightConfig.xml", LightSetting); LightDoc.Load(LightReader); XmlNode LightRootNode = LightDoc.SelectSingleNode("Lights"); XmlNodeList LightRootChilds = LightRootNode.ChildNodes; foreach (XmlNode Node in LightRootChilds) { LightConfig Light = new LightConfig(); XmlElement Element = (XmlElement)Node; XmlNodeList Childs = Element.ChildNodes; Light.LightName = Childs.Item(0).InnerText; Light.RelayNumber = Childs.Item(1).InnerText; LightList.Add(Light); } LightReader.Close(); //读取窗帘配置 WindowsList = new List <WindowsConfig>(); XmlDocument WindowsDoc = new XmlDocument(); XmlReaderSettings WindowsSetting = new XmlReaderSettings { IgnoreComments = true }; XmlReader WindowsReader = XmlReader.Create(Application.StartupPath + "\\Config\\ReadingRoomTwo\\WindowsConfig.xml", WindowsSetting); WindowsDoc.Load(WindowsReader); XmlNode WindowsRootNode = WindowsDoc.SelectSingleNode("Windows"); XmlNodeList WindowsRootChilds = WindowsRootNode.ChildNodes; foreach (XmlNode Node in WindowsRootChilds) { WindowsConfig Windows = new WindowsConfig(); XmlElement Element = (XmlElement)Node; XmlNodeList Childs = Element.ChildNodes; Windows.WindowsName = Childs.Item(0).InnerText; Windows.RelayNumber = Childs.Item(1).InnerText; WindowsList.Add(Windows); } WindowsReader.Close(); }
/// <summary> /// 读取用户配置 /// </summary> private void ReadUserConfig() { //读取模式配置 ModeList = new List <ModeConfig>(); XmlDocument ModeDoc = new XmlDocument(); XmlReaderSettings ModeSetting = new XmlReaderSettings { IgnoreComments = true }; XmlReader ModeReader = XmlReader.Create(Application.StartupPath + "\\Config\\ConsultationRoomTwo\\ModeConfig.xml", ModeSetting); ModeDoc.Load(ModeReader); XmlNode ModeRootNode = ModeDoc.SelectSingleNode("Modes"); XmlNodeList ModeRootChilds = ModeRootNode.ChildNodes; foreach (XmlNode Node in ModeRootChilds) { ModeConfig Mode = new ModeConfig(); XmlElement Element = (XmlElement)Node; XmlNodeList Childs = Element.ChildNodes; Mode.ModeName = Childs.Item(0).InnerText; Mode.Relays = Childs.Item(1).InnerText; Mode.ProjectorOne = Childs.Item(2).InnerText; Mode.ProjectorTwo = Childs.Item(3).InnerText; Mode.Matrix = Childs.Item(4).InnerText; Mode.Camera = Childs.Item(5).InnerText; ModeList.Add(Mode); } ModeReader.Close(); //读取灯光配置 LightList = new List <LightConfig>(); XmlDocument LightDoc = new XmlDocument(); XmlReaderSettings LightSetting = new XmlReaderSettings { IgnoreComments = true }; XmlReader LightReader = XmlReader.Create(Application.StartupPath + "\\Config\\ConsultationRoomTwo\\LightConfig.xml", LightSetting); LightDoc.Load(LightReader); XmlNode LightRootNode = LightDoc.SelectSingleNode("Lights"); XmlNodeList LightRootChilds = LightRootNode.ChildNodes; foreach (XmlNode Node in LightRootChilds) { LightConfig Light = new LightConfig(); XmlElement Element = (XmlElement)Node; XmlNodeList Childs = Element.ChildNodes; Light.LightName = Childs.Item(0).InnerText; Light.RelayNumber = Childs.Item(1).InnerText; LightList.Add(Light); } LightReader.Close(); //读取窗帘配置 WindowsList = new List <WindowsConfig>(); XmlDocument WindowsDoc = new XmlDocument(); XmlReaderSettings WindowsSetting = new XmlReaderSettings { IgnoreComments = true }; XmlReader WindowsReader = XmlReader.Create(Application.StartupPath + "\\Config\\ConsultationRoomTwo\\WindowsConfig.xml", WindowsSetting); WindowsDoc.Load(WindowsReader); XmlNode WindowsRootNode = WindowsDoc.SelectSingleNode("Windows"); XmlNodeList WindowsRootChilds = WindowsRootNode.ChildNodes; foreach (XmlNode Node in WindowsRootChilds) { WindowsConfig Windows = new WindowsConfig(); XmlElement Element = (XmlElement)Node; XmlNodeList Childs = Element.ChildNodes; Windows.WindowsName = Childs.Item(0).InnerText; Windows.RelayNumber = Childs.Item(1).InnerText; WindowsList.Add(Windows); } WindowsReader.Close(); //读取幕布配置 FilmList = new List <FilmConfig>(); XmlDocument FilmDoc = new XmlDocument(); XmlReaderSettings FilmSetting = new XmlReaderSettings { IgnoreComments = true }; XmlReader FilmReader = XmlReader.Create(Application.StartupPath + "\\Config\\ConsultationRoomTwo\\FilmConfig.xml", FilmSetting); FilmDoc.Load(FilmReader); XmlNode FilmRootNode = FilmDoc.SelectSingleNode("Films"); XmlNodeList FilmRootChilds = FilmRootNode.ChildNodes; foreach (XmlNode Node in FilmRootChilds) { FilmConfig Film = new FilmConfig(); XmlElement Element = (XmlElement)Node; XmlNodeList Childs = Element.ChildNodes; Film.FilmName = Childs.Item(0).InnerText; Film.RelayNumber = Childs.Item(1).InnerText; FilmList.Add(Film); } FilmReader.Close(); }