Beispiel #1
0
        public virtual string ToHtmlString(bool big = true)
        {
            DateTime now  = DateTime.UtcNow;
            var      html = new StringBuilder();

            html.AppendFormat("Current Date: {0}\n", Schedules.FormatDate(now));
            html.AppendFormat("Current Time: {0}\n", Schedules.FormatTime(now.TimeOfDay, true));

            html.AppendLine("\nSchedule Overview:\n");

            if (!_Enabled)
            {
                html.AppendLine("Schedule is currently disabled.".WrapUOHtmlColor(Color.OrangeRed));
                return(html.ToString());
            }

            bool   print = false;
            string months = _Info.Months.ToString(), days = String.Empty, times = String.Empty;

            if (months == "All")
            {
                months = String.Join(" ", Enum.GetNames(typeof(ScheduleMonths)));
                months = months.Replace("All", String.Empty).Replace("None", String.Empty).Trim().Replace(" ", ", ");
            }

            if (months == "None")
            {
                html.AppendLine("Schedule requires at least one Month to be set.".WrapUOHtmlColor(Color.OrangeRed));
            }
            else
            {
                days = _Info.Days.ToString();

                if (days == "All")
                {
                    days = String.Join(" ", Enum.GetNames(typeof(ScheduleDays)));
                    days = days.Replace("All", String.Empty).Replace("None", String.Empty).Trim().Replace(" ", ", ");
                }

                if (days == "None")
                {
                    html.AppendLine("Schedule requires at least one Day to be set.".WrapUOHtmlColor(Color.OrangeRed));
                }
                else
                {
                    times = _Info.Times.ToString();

                    if (String.IsNullOrWhiteSpace(times))
                    {
                        html.AppendLine("Schedule requires at least one Time to be set.".WrapUOHtmlColor(Color.OrangeRed));
                    }
                    else
                    {
                        int    cc   = 0;
                        string wrap = String.Empty;

                        foreach (char t in times)
                        {
                            if (t == ',')
                            {
                                cc++;
                                wrap += ',';

                                if (cc % 6 == 0)
                                {
                                    wrap += '\n';
                                }
                                else
                                {
                                    wrap += ' ';
                                }
                            }
                            else if (t != ' ')
                            {
                                wrap += t;
                            }
                        }

                        times = wrap;
                        print = true;
                    }
                }
            }

            if (print)
            {
                html.AppendFormat("<BASEFONT COLOR=#{0:X6}>", Color.Cyan.ToArgb());
                html.AppendLine("Schedule is set to perform an action:");
                html.AppendLine("\n<B>In...</B>");
                html.AppendLine(months);
                html.AppendLine("\n<B>On...</B>");
                html.AppendLine(days);
                html.AppendLine("\n<B>At...</B>");
                html.AppendLine(times);

                if (NextGlobalTick != null)
                {
                    bool today = (NextGlobalTick.Value.Day == DateTime.UtcNow.Day);

                    html.AppendLine(
                        String.Format(
                            "\n\nThe next tick will be at {0} {1}.",
                            NextGlobalTick.Value.TimeOfDay.ToSimpleString("h:m:s"),
                            today ? "today." : "on " + NextGlobalTick.Value.ToSimpleString("D, M d")));
                }
            }

            return((big ? String.Format("<big>{0}</big>", html) : html.ToString()).WrapUOHtmlColor(
                       SuperGump.DefaultHtmlColor, false));
        }