Пример #1
0
        protected virtual void SetMonth(GumpButton button, ScheduleMonths month)
        {
            if (Schedule == null)
            {
                Close();
                return;
            }

            switch (month)
            {
            case ScheduleMonths.None:
                Schedule.Info.Months = ScheduleMonths.None;
                break;

            case ScheduleMonths.All:
                Schedule.Info.Months = ScheduleMonths.All;
                break;

            default:
                Schedule.Info.Months ^= month;
                break;
            }

            Schedule.InvalidateNextTick();

            Refresh(true);
        }
Пример #2
0
        protected virtual void OnDeleteAll(GumpButton button)
        {
            if (UseConfirmDialog)
            {
                new ConfirmDialogGump(User, this)
                {
                    Title = "Delete All Times?",
                    Html  = "All times in the schedule will be deleted, erasing all data associated with them.\n" +
                            "This action can not be reversed.\n\nDo you want to continue?",
                    AcceptHandler = subButton =>
                    {
                        Schedule.Info.Times.Clear();
                        Schedule.InvalidateNextTick();

                        Refresh(true);
                    },
                    CancelHandler = Refresh
                }.Send();
            }
            else
            {
                Schedule.Info.Times.Clear();
                Schedule.InvalidateNextTick();

                Refresh(true);
            }
        }
Пример #3
0
        protected virtual void SetDay(GumpButton button, ScheduleDays day)
        {
            if (Schedule == null)
            {
                Close();
                return;
            }

            switch (day)
            {
            case ScheduleDays.None:
                Schedule.Info.Days = ScheduleDays.None;
                break;

            case ScheduleDays.All:
                Schedule.Info.Days = ScheduleDays.All;
                break;

            default:
                Schedule.Info.Days ^= day;
                break;
            }

            Schedule.InvalidateNextTick();

            Refresh(true);
        }
Пример #4
0
        protected virtual void OnAddTime(GumpButton button)
        {
            var nowTime = Schedule.Now.TimeOfDay;

            new InputDialogGump(User, this)
            {
                Title = "Add Schedule Time",
                Html  = "Enter the time of day " + String.Concat('(', nowTime.ToSimpleString("X"), ')') +
                        " to add to this schedule.\nFormat: HH:MM\nExample: " +
                        String.Format("{0:D2}:{1:D2}", nowTime.Hours, nowTime.Minutes) +
                        "\n\nYou can also load a preset list of times, but be aware that presets will " +
                        "overwrite any custom entries you have created.",
                Callback = (b, text) =>
                {
                    int hh, mm;

                    ParseTime(text, out hh, out mm);

                    if (hh == -1 || mm == -1)
                    {
                        OnAddTime(button);
                        return;
                    }

                    Schedule.Info.Times.Add(new TimeSpan(0, hh, mm, 0, 0));
                    Schedule.InvalidateNextTick();

                    OnAddTime(button);
                },
                CancelHandler = Refresh
            }.Send();
        }
Пример #5
0
        protected virtual void OnAddTime(GumpButton button)
        {
            TimeSpan nowTime = DateTime.UtcNow.TimeOfDay;

            Send(
                new InputDialogGump(
                    User,
                    this,
                    title: "Add Schedule Time",
                    html:
                    "Enter the time of day to add to this schedule.\nFormat: HH:MM\nExample: " +
                    String.Format("{0:D2}:{1:D2}", nowTime.Hours, nowTime.Minutes) +
                    "\n\nYou can also load a preset list of times, but be aware that presets will overwrite any custom entries you have created.",
                    callback: (b, text) =>
            {
                int hh, mm;
                ParseTime(text, out hh, out mm);

                if (hh == -1 || mm == -1)
                {
                    OnAddTime(button);
                    return;
                }

                Schedule.Info.Times.Add(new TimeSpan(0, hh, mm, 0, 0));
                Schedule.InvalidateNextTick(DateTime.UtcNow);
                OnAddTime(button);
            },
                    onCancel: b => Refresh(true)));
        }
Пример #6
0
 protected virtual void OnDeleteAll(GumpButton button)
 {
     if (UseConfirmDialog)
     {
         Send(
             new ConfirmDialogGump(
                 User,
                 this,
                 title: "Delete All Times?",
                 html:
                 "All times in the schedule will be deleted, erasing all data associated with them.\nThis action can not be reversed.\n\nDo you want to continue?",
                 onAccept: subButton =>
         {
             Schedule.Info.Times.Clear();
             Schedule.InvalidateNextTick(DateTime.UtcNow);
             Refresh(true);
         },
                 onCancel: b => Refresh(true)));
     }
     else
     {
         Schedule.Info.Times.Clear();
         Schedule.InvalidateNextTick(DateTime.UtcNow);
         Refresh(true);
     }
 }
Пример #7
0
 protected virtual void UsePreset(GumpButton button, ScheduleTimes times)
 {
     Schedule.Info.Times.Clear();
     Schedule.Info.Times.Add(times);
     Schedule.InvalidateNextTick(DateTime.UtcNow);
     Refresh(true);
 }
Пример #8
0
        protected virtual void OnConfirmDelete(GumpButton button)
        {
            if (Selected == null)
            {
                Close();
                return;
            }

            Schedule.Info.Times.Remove(Time);
            Schedule.InvalidateNextTick(DateTime.UtcNow);
            Close();
        }