コード例 #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 lvRules_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lvRules.SelectedItems.Count == 0)
            {
                return;
            }
            Bell r = bells[lvRules.SelectedItems[0].Index];

            bells.RemoveAt(lvRules.SelectedItems[0].Index);
            lvRules.Items.RemoveAt(lvRules.SelectedItems[0].Index);
            SetFields(r);
        }
コード例 #3
0
 private void SetFields(Bell r)
 {
     ClearFields();
     selectedfile         = r.soundfile;
     chkMonday.Checked    = r.days.mo;
     chkTuesday.Checked   = r.days.tu;
     chkWednesday.Checked = r.days.we;
     chkThursday.Checked  = r.days.th;
     chkFriday.Checked    = r.days.fr;
     chkSaturday.Checked  = r.days.sa;
     chkSunday.Checked    = r.days.su;
     currentTimestamps    = r.timestamps;
 }
コード例 #4
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();
        }