Exemplo n.º 1
0
 public WOL2TimerDay(WOL2TimerDay t)
 {
     WakeHour   = t.WakeHour;
     WakeMinute = t.WakeMinute;
     WakeSecond = t.WakeSecond;
     IsEnabled  = t.IsEnabled;
 }
Exemplo n.º 2
0
        // Event Handlers -----------------------------------------------------------

        void LbDaysSelectedIndexChanged(object sender, EventArgs e)
        {
            int          iDay = lbDays.SelectedIndex;
            WOL2TimerDay dt   = m_theTimer.GetTimeForDay(iDay);

            if (dt != null)
            {
                txtHour.Text       = dt.WakeHour.ToString();
                txtMinute.Text     = dt.WakeMinute.ToString();
                txtSecond.Text     = dt.WakeSecond.ToString();
                chkEnabled.Checked = dt.IsEnabled;
            }
        }
Exemplo n.º 3
0
        // Functions ----------------------------------------------------------------

        /// <summary>
        /// Returns true if this timer fires now.
        /// </summary>
        public bool Check(DateTime check)
        {
            int iDay = -1;

            switch (check.DayOfWeek)
            {
            case DayOfWeek.Monday:
                iDay = 0;
                break;

            case DayOfWeek.Tuesday:
                iDay = 1;
                break;

            case DayOfWeek.Wednesday:
                iDay = 2;
                break;

            case DayOfWeek.Thursday:
                iDay = 3;
                break;

            case DayOfWeek.Friday:
                iDay = 4;
                break;

            case DayOfWeek.Saturday:
                iDay = 5;
                break;

            case DayOfWeek.Sunday:
                iDay = 6;
                break;

            default: break;
            }

            if (iDay > -1 && this.m_bIsEnabled)
            {
                WOL2TimerDay tmr = m_Days[iDay] as WOL2TimerDay;
                if (tmr != null)
                {
                    if (tmr.IsEnabled)
                    {
                        return(((WOL2TimerDay)m_Days[iDay]).Check(check));
                    }
                }
            }
            return(false);
        }
Exemplo n.º 4
0
 void LinkLabel1Click(object sender, EventArgs e)
 {
     foreach (int i in lbDays.CheckedIndices)
     {
         WOL2TimerDay dt = m_theTimer.GetTimeForDay(i);
         if (dt != null)
         {
             dt.WakeHour   = Convert.ToInt32(txtHour.Text);
             dt.WakeMinute = Convert.ToInt32(txtMinute.Text);
             dt.WakeSecond = Convert.ToInt32(txtSecond.Text);
             dt.IsEnabled  = chkEnabled.Checked;
         }
     }
     UpdateDescription();
 }
Exemplo n.º 5
0
        /// <summary>
        /// Returns the XML representation of the timer.
        /// </summary>
        /// <param name="doc">The XML document used to create the XmlNode.</param>
        public XmlNode SerializeXml(XmlDocument doc, String nodeName)
        {
            // Create new host tag
            XmlNode xmlTimer = doc.CreateElement(nodeName);

            XmlNode tmp = doc.CreateElement("TimerEnabled");

            tmp.InnerText = IsEnabled() ? "1" : "0";
            xmlTimer.AppendChild(tmp);

            for (int i = 1; i <= 7; i++)
            {
                WOL2TimerDay d = (WOL2TimerDay)m_Days[i - 1];

                XmlNode n = doc.CreateElement("Day_" + i.ToString());
                d.SerializeXml(n, doc);

                xmlTimer.AppendChild(n);
            }

            return(xmlTimer);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Recreates a timer from an XML node.
        /// </summary>
        /// <param name="n">The XML node to recreate this timer from.</param>
        public bool DeserializeXML(XmlNode n)
        {
            while (n != null)
            {
                if (n.Name == "TimerEnabled")
                {
                    this.m_bIsEnabled = (n.InnerText == "1" ? true : false);
                }
                else if (n.Name.Length == 5)
                {
                    string sDay = n.Name.Substring(4);
                    int    iDay = Convert.ToInt32(sDay) - 1;

                    WOL2TimerDay d = (WOL2TimerDay)m_Days[iDay];
                    d.DeserializeXML(n.FirstChild);
                }

                // Next please
                n = n.NextSibling;
            }
            return(true);
        }
Exemplo n.º 7
0
 public WOL2TimerDay( WOL2TimerDay t )
 {
     WakeHour = t.WakeHour;
     WakeMinute = t.WakeMinute;
     WakeSecond = t.WakeSecond;
     IsEnabled = t.IsEnabled;
 }