Пример #1
0
        private void LoadRings(string filename)
        {
            bells.Clear();
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(filename);
            foreach (XmlNode node in xmlDoc.DocumentElement.ChildNodes)
            {
                Bell   bell      = new Bell();
                string soundfile = node.ChildNodes[0].InnerText;
                Days   days      = new Days();
                days.mo = Convert.ToBoolean(int.Parse(node.ChildNodes[1].Attributes[0].Value));
                days.tu = Convert.ToBoolean(int.Parse(node.ChildNodes[1].Attributes[1].Value));
                days.we = Convert.ToBoolean(int.Parse(node.ChildNodes[1].Attributes[2].Value));
                days.th = Convert.ToBoolean(int.Parse(node.ChildNodes[1].Attributes[3].Value));
                days.fr = Convert.ToBoolean(int.Parse(node.ChildNodes[1].Attributes[4].Value));
                days.sa = Convert.ToBoolean(int.Parse(node.ChildNodes[1].Attributes[5].Value));
                days.su = Convert.ToBoolean(int.Parse(node.ChildNodes[1].Attributes[6].Value));
                List <Timestamp> timestamps = new List <Timestamp>();
                for (int i = 2; i < node.ChildNodes.Count; i++)
                {
                    Timestamp timestamp = new Timestamp();
                    timestamp.hour   = int.Parse(node.ChildNodes[i].Attributes[0].Value);
                    timestamp.minute = int.Parse(node.ChildNodes[i].Attributes[1].Value);
                    timestamp.second = int.Parse(node.ChildNodes[i].Attributes[2].Value);
                    timestamps.Add(timestamp);
                }
                bell.soundfile  = soundfile;
                bell.days       = days;
                bell.timestamps = timestamps;
                bells.Add(bell);
                lvRules.Items.Add(bell.ToString());
            }
        }
Пример #2
0
        private void bNewRule_Click(object sender, EventArgs e)
        {
            Bell   r         = new Bell();
            string soundfile = selectedfile;
            Days   days      = new Days();

            days.mo      = chkMonday.Checked;
            days.tu      = chkTuesday.Checked;
            days.we      = chkWednesday.Checked;
            days.th      = chkThursday.Checked;
            days.fr      = chkFriday.Checked;
            days.sa      = chkSaturday.Checked;
            days.su      = chkSunday.Checked;
            r.soundfile  = soundfile;
            r.days       = days;
            r.timestamps = currentTimestamps;
            bells.Add(r);
            lvRules.Items.Add(r.ToString());
            ClearFields();
        }