Exemplo n.º 1
0
 public TriggerActionTimer(VesselTriggers vesselTriggers) : base(vesselTriggers)
 {
     _type        = TriggerActionType.Timer;
     _timer       = null;
     _name        = "";
     _timerAction = TimerActionType.Start;
 }
Exemplo n.º 2
0
 public TriggerActionTimer(TriggerActionTimer other) : base(other)
 {
     _type  = TriggerActionType.Timer;
     _timer = null;
     // Automatic call of Name_set
     Name         = other.Name;
     _timerAction = other._timerAction;
     _modified    = false;
     UpdatePersistentData();
 }
Exemplo n.º 3
0
 public static DatabaseTimer FindTimer(int id, TimerActionType actionType, ulong userId, DatabaseContextBuilder database)
 {
     using (var db = database.CreateContext())
         return(db.Timers.FirstOrDefault(xt => xt.Id == id && xt.ActionType == actionType && xt.UserId == (long)userId));
 }
Exemplo n.º 4
0
 public static DatabaseTimer FindNearestTimer(TimerActionType actionType, ulong userId, ulong channelId, ulong guildId, DatabaseContextBuilder database)
 {
     using (var db = database.CreateContext())
         return(db.Timers.FirstOrDefault(xt => xt.ActionType == actionType && xt.UserId == (long)userId && xt.ChannelId == (long)channelId && xt.GuildId == (long)guildId));
 }
Exemplo n.º 5
0
        /// <summary>
        /// Manages the timer buttons.
        /// </summary>
        /// <param name="timerType">Type of the timer.</param>
        /// <param name="timerActionType">Type of the timer action.</param>
        /// <exception cref="Exception">
        /// Invalid TimerType
        /// or
        /// Invalid TimerType
        /// or
        /// Invalid TimerType
        /// or
        /// Invalid timerType
        /// </exception>
        public void ManageTimerButtons(TimerType timerType, TimerActionType timerActionType)
        {
            try
            {
                switch (timerActionType)
                {
                case TimerActionType.Start:

                    switch (timerType)
                    {
                    case TimerType.Timer:
                        ToogleTimerActivity(timerType, true);
                        ToogleTimerButtonActivity(false, timerType);
                        break;

                    case TimerType.TimerBeforePlaySound:
                        ToogleTimerActivity(timerType, true);
                        ToogleTimerButtonActivity(false, timerType);
                        break;

                    default:
                        throw new Exception("Invalid TimerType");
                    }

                    break;

                case TimerActionType.Stop:

                    switch (timerType)
                    {
                    case TimerType.Timer:
                        ToogleTimerActivity(timerType, false);
                        ToogleTimerButtonActivity(true, timerType);
                        break;

                    case TimerType.TimerBeforePlaySound:
                        ToogleTimerActivity(timerType, false);
                        ToogleTimerButtonActivity(true, timerType);
                        break;

                    default:
                        throw new Exception("Invalid TimerType");
                    }

                    break;

                case TimerActionType.Reset:

                    switch (timerType)
                    {
                    case TimerType.Timer:
                        ToogleTimerButtonActivity(false, timerType, true);
                        _timerLabel.Text = "00:00";
                        ToogleTimerButtonActivity(true, timerType, true);
                        break;

                    case TimerType.TimerBeforePlaySound:
                        ToogleTimerButtonActivity(false, timerType, true);
                        _timerElapsedLabel.Text =
                            $"{(TimePeriod < 10 || TimePeriod == 0 ? $"0{TimePeriod}" : TimePeriod.ToString())}:00";
                        ToogleTimerButtonActivity(true, timerType, true);
                        break;

                    default:
                        throw new Exception("Invalid TimerType");
                    }

                    break;

                default:
                    throw new Exception("Invalid timerType");
                }
            }
            catch (Exception e)
            {
                ShowError(e.Message);
            }
        }
Exemplo n.º 6
0
 public override void UpdatePersistentData()
 {
     _timerNamePers   = _name;
     _timerActionPers = _timerAction;
 }
Exemplo n.º 7
0
 public override void LoadPersistentData()
 {
     Name         = _timerNamePers;
     _timerAction = _timerActionPers;
 }