Esempio n. 1
0
        private void OnClockServerRequest(ClockServerEventArgs e)
        {
            var handler = ClockServerRequestHandler;

            if (handler != null)
            {
                handler(this, e);
            }
            else
            {
                e.Mode = ClockServerMode.Nameplate;
            }
        }
Esempio n. 2
0
        private string CreateXml()
        {
            StringBuilder sb = new StringBuilder();

            var args = new ClockServerEventArgs();

            OnClockServerRequest(args);

            sb.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            sb.AppendLine("<root>");

            switch (args.Mode)
            {
            case ClockServerMode.Nameplate:
                sb.AppendLine(" <clock mode=\"Nameplate\" mins=\"0\" secs=\"0\" targetSecs=\"0\" />");
                break;

            case ClockServerMode.TimeOfDay:
                // in this mode mins and secs hold the total offset time into the day
                DateTime now = DateTime.Now;
                sb.AppendLine(
                    $" <clock mode=\"TimeOfDay\" mins=\"{(now.Hour * 60) + now.Minute}\" secs=\"{now.Second}\" targetSecs=\"0\" />");
                break;

            case ClockServerMode.Timer:
                sb.AppendLine(
                    $" <clock mode=\"Timer\" mins=\"{args.Mins}\" secs=\"{args.Secs}\" targetSecs=\"{args.TargetSecs}\" />");
                break;

            case ClockServerMode.TimerPause:
                sb.AppendLine(
                    $" <clock mode=\"TimerPause\" mins=\"{args.Mins}\" secs=\"{args.Secs}\" targetSecs=\"{args.TargetSecs}\" />");
                break;
            }

            sb.AppendLine("</root>");
            return(sb.ToString());
        }