Exemplo n.º 1
0
        public TimerDefaultSettingsForm(WurmTimer wurmTimer, [NotNull] ISoundManager soundManager)
        {
            if (soundManager == null)
            {
                throw new ArgumentNullException("soundManager");
            }
            parentTimer       = wurmTimer;
            this.soundManager = soundManager;
            InitializeComponent();
            if (wurmTimer.MoreOptionsAvailable)
            {
                buttonMoreOptions.Visible = true;
            }
            this.Text = wurmTimer.Name;
            //set all options values
            this.checkBoxPopup.Checked             = parentTimer.PopupNotify;
            this.checkBoxSound.Checked             = parentTimer.SoundNotify;
            this.checkBoxPopupPersistent.Checked   = parentTimer.PersistentPopup;
            this.textBoxSoundName.Text             = soundManager.GetSoundById(parentTimer.SoundId).Name;
            this.checkBoxOnAssistantLaunch.Checked = parentTimer.PopupOnWaLaunch;
            int popupDurationMillis = parentTimer.PopupDurationMillis;

            this.numericUpDownPopupDuration.Value =
                (popupDurationMillis / 1000).ConstrainToRange((int)numericUpDownPopupDuration.Minimum,
                                                              (int)numericUpDownPopupDuration.Maximum);
            isInited = true;
        }
Exemplo n.º 2
0
 public void UnloadAndDeleteTimer([NotNull] WurmTimer timer)
 {
     if (timer == null)
     {
         throw new ArgumentNullException("timer");
     }
     persistentObjectResolver.UnloadAndDeleteData(timer);
 }
Exemplo n.º 3
0
        public WurmTimer AddNewTimer(TimerDefinition definition)
        {
            WurmTimer newTimer = timerInstances.CreateTimer(definition.Id);

            newTimer.Initialize(this, CharacterName, definition);
            activeTimerDefinitions.Add(new ActiveTimer()
            {
                DefinitionId = definition.Id,
                TimerId      = newTimer.Id
            });
            layoutControl.RegisterNewTimerDisplay(newTimer.View);
            timers.Add(newTimer);
            FlagAsChanged();
            return(newTimer);
        }
Exemplo n.º 4
0
        internal void RemoveTimer(WurmTimer timer)
        {
            timerInstances.UnloadAndDeleteTimer(timer);
            timers.Remove(timer);

            var toRemove =
                activeTimerDefinitions.Where(activeTimer => activeTimer.DefinitionId == timer.TimerDefinition.Id).ToArray();

            foreach (var activeTimer in toRemove)
            {
                activeTimerDefinitions.Remove(activeTimer);
            }

            FlagAsChanged();

            timer.Stop();
        }
Exemplo n.º 5
0
        private async void PerformAsyncInits()
        {
            try
            {
                await AttemptToEstablishCurrentServer(TimeSpan.FromDays(120));

                if (currentServerOnTheGroup == null)
                {
                    await AttemptToEstablishCurrentServer(TimeSpan.FromDays(365));
                }

                foreach (var activeTimer in activeTimerDefinitions)
                {
                    try
                    {
                        var       definition = timerDefinitions.GetById(activeTimer.DefinitionId);
                        WurmTimer timer      = timerInstances.GetTimer(activeTimer.DefinitionId, activeTimer.TimerId);
                        timer.Initialize(this, CharacterName, definition);
                        layoutControl.RegisterNewTimerDisplay(timer.View);
                        timers.Add(timer);
                        FlagAsChanged();
                    }
                    catch (Exception exception)
                    {
                        logger.Error(exception, "Error at InitTimers for timer " + activeTimer);
                        FlagAsChanged();
                    }
                }

                layoutControl.EnableAddingTimers();
            }
            catch (Exception _e)
            {
                logger.Error(_e, "problem updating current server group");
                if (layoutControl != null)
                {
                    layoutControl.SetInitializationError();
                }
            }
        }
Exemplo n.º 6
0
 public TimerDisplayView(WurmTimer wurmTimer) : this()
 {
     this.wurmTimer = wurmTimer;
     SetName(wurmTimer.ShortName);
 }
Exemplo n.º 7
0
 public void StopTimer(WurmTimer wurmTimer)
 {
     layoutControl.UnregisterTimerDisplay(wurmTimer.View);
 }