Exemple #1
0
        private void SetState(bool on)
        {
            if (on == false)
            {
                for (int i = 0; i < 7; i++)
                {
                    for (int j = 0; j < 2; j++)
                    {
                        m_block.SetEmissiveParts(string.Format("Em_H{0}{1}", j, i), COLOROFF, INTENSITYOFF);
                        m_block.SetEmissiveParts(string.Format("Em_M{0}{1}", j, i), COLOROFF, INTENSITYOFF);
                    }
                }

                m_block.SetEmissiveParts("Em_Red", COLOROFF, INTENSITYOFF);
                m_block.SetEmissiveParts("Em_Local", COLOROFF, INTENSITYOFF);
                m_block.SetEmissiveParts("Em_UTC", COLOROFF, INTENSITYOFF);
            }
            else
            {
                hour   = showRealTime ? DateTime.Now.Hour : DateTime.UtcNow.Hour;
                minute = showRealTime ? DateTime.Now.Minute : DateTime.UtcNow.Minute;

                // padding with zeros so hour and minute is always 2 digits long i.e. 01:06
                string m = minute.ToString("D2");
                string h = hour.ToString("D2");

                for (int i = 0; i < 7; i++)
                {
                    for (int j = 0; j < 2; j++)
                    {
                        bool b = GetDigitSegmentState(i, h.Substring(j, 1));
                        m_block.SetEmissiveParts(string.Format("Em_H{0}{1}", j, i), b ? COLORON : COLOROFF, b ? INTENSITYON : INTENSITYOFF);

                        b = GetDigitSegmentState(i, m.Substring(j, 1));
                        m_block.SetEmissiveParts(string.Format("Em_M{0}{1}", j, i), b ? COLORON : COLOROFF, b ? INTENSITYON : INTENSITYOFF);
                    }
                }

                m_block.SetEmissiveParts("Em_Red", COLORON, INTENSITYON);
                m_block.SetEmissiveParts("Em_Local", showRealTime ? COLORON : COLOROFF, showRealTime ? INTENSITYON : INTENSITYOFF);
                m_block.SetEmissiveParts("Em_UTC", showRealTime ? COLOROFF : COLORON, showRealTime ? INTENSITYOFF : INTENSITYON);
            }
        }