Пример #1
0
        ObservableCollection <EventChannel> CreateChannels(IEnumerable <XElement> channels)
        {
            EventChannel ech;
            ObservableCollection <EventChannel> eventChannels = new ObservableCollection <EventChannel>();
            int i = 0;

            foreach (XElement ch in channels)
            {
                ch.Attribute("ChannelNo").Value = channelNumbers[i].ToString();
                foreach (XElement evnt in ch.Elements())
                {
                    ech           = new EventChannel();
                    ech.ChannelNo = int.Parse(ch.Attribute("ChannelNo").Value);
                    ech.EventName = evnt.Attribute("Name").Value;
                    eventChannels.Add(ech);
                }
                i++;
            }
            return(eventChannels);
        }
Пример #2
0
        //string CreateProfile(){}

        void ParseProfile(string profile)
        {
            EventChannel ech;

            channelNumbers = new List <int>();

            _profile = profile;
            XElement root = XElement.Parse(profile);

            IEnumerable <XElement> channels = root.Elements("Mode")
                                              .Where(p => p.Attribute("Value").Value == Mode.ToString()).Elements();

            ChCount = 0;
            foreach (XElement ch in channels)
            {
                channelNumbers.Add(int.Parse(ch.Attribute("ChannelNo").Value));
                ChCount++;
            }

            int modeCount = root.Elements().Count();

            for (int i = 0; i < root.Elements().Count(); i++)
            {
                ModeList.Add(String.Format("Mode_{0}", i + 1));
            }

            if (Id == 0)
            {
                foreach (XElement ch in channels)
                {
                    foreach (XElement evnt in ch.Elements())
                    {
                        ech           = new EventChannel();
                        ech.ChannelNo = int.Parse(ch.Attribute("ChannelNo").Value);
                        ech.EventName = evnt.Attribute("Name").Value;
                        EventChannels.Add(ech);
                    }
                }
            }
        }