/// <summary> /// Notifies the listener at the start of a test suite. /// </summary> public void BeginTestSuite(ITestSuite testSuite) { Push("test-suite"); CurrentWriter.WriteAttributeString("name", testSuite.Name); CurrentTimer.Start(); Push("results"); }
/// <summary> /// Disposes this instance. /// </summary> public void Dispose() { if (CurrentTimer != null) { CurrentTimer.Dispose(); } Rollback(); if (_dataContext == null) { return; } try { if (_dataContext.Database.GetDbConnection() != null && _dataContext.Database.GetDbConnection().State == System.Data.ConnectionState.Open) { _dataContext.Database.CloseConnection(); } _dataContext.Dispose(); _dataContext = null; } catch (ObjectDisposedException) { _dataContext = null; } }
private void StopAllQualityTimers() { foreach (Timer CurrentTimer in QualityTimers) { CurrentTimer.Stop(); } }
/// <summary> /// Notifies the listener at the end of a fixture. /// </summary> public void EndFixture(IFixture fixture) { Pop(); CurrentTimer.Stop(); CurrentWriter.WriteAttributeString("time", CurrentTimer.Elapsed.TotalSeconds.ToString("0.000")); CurrentWriter.WriteAttributeString("success", _fixturePassed.ToString()); Pop(); }
/// <summary> /// Notifies the listener at the end of a test suite. /// </summary> public void EndTestSuite(ITestSuite testSuite) { Pop(); CurrentTimer.Stop(); CurrentWriter.WriteAttributeString("time", CurrentTimer.Elapsed.TotalSeconds.ToString("0.000")); CurrentWriter.WriteAttributeString("success", (FailCount == 0).ToString()); Pop(); }
private void PauseButton_Click(object sender, EventArgs e) { CurrentTimer.Stop(); _document.gHook.unhook(); SetAvailability(false, true, false, true, false); }
/// <summary> /// Notifies the listener at the start of a fixture. /// </summary> public void BeginFixture(IFixture fixture) { Push("test-suite"); CurrentWriter.WriteAttributeString("name", fixture.Name); CurrentWriter.WriteAttributeString("description", fixture.Description); Push("results"); _fixturePassed = true; CurrentTimer.Start(); }
private void StopButton_Click(object sender, EventArgs e) { CurrentTimer.Stop(); _document.gHook.unhook(); SetAvailability(true, true, false, false, true); CreateReportButton.Enabled = true; }
private void OnLeavingBackground(object sender, LeavingBackgroundEventArgs e) { if (CurrentTimer != null) { CurrentTimer.CheckTime(); } if (IsTimerInProgress) { NotificationManager.Current.RemoveAllNotificationsButFirst(IsInPomodoro, CurrentTimer.StartTime + CurrentTimer.TotalTime); } }
/// <summary> /// Sets the unit of work timeout. /// </summary> /// <param name="value">The value of the timer.</param> public void SetTimeout(Int32 value) { Timeout = value; if (value <= 0) { throw new ArgumentException("Invalid timeout"); } if (CurrentTimer != null) { CurrentTimer.Change(value, System.Threading.Timeout.Infinite); } }
private async void OnLeavingBackground(object sender, LeavingBackgroundEventArgs e) { if (CurrentTimer != null && IsTimerInProgress) { CurrentTimer.CheckTime(); } if (IsTimerInProgress) { NotificationManager.Current.RemoveAllNotificationsButFirst(IsInPomodoro, CurrentTimer.StartTime + CurrentTimer.TotalTime); await DataService.RemoveFuturePeriodsAsync(); } }
/// <summary> /// Run when the unit of work is created. /// </summary> private void StartTimer() { if (Timeout == default(Int32)) { Timeout = 60000; } if (CurrentTimer != null) { CurrentTimer.Dispose(); } CurrentTimer = new Timer(OnTimeout, null, Timeout, System.Threading.Timeout.Infinite); }
void myUnload() { foreach (Oxide.Core.Libraries.Timer.TimerInstance CurrentTimer in Timers) { if (CurrentTimer != null) { if (CurrentTimer.Destroyed == false) { CurrentTimer.Destroy(); } } } Timers.Clear(); }
private void MainForm_Resize(object sender, EventArgs e) { if (MinimizeButtonFlag) // only when "minimize to tray" button is used and not standard minimizing { MinimizeButtonFlag = false; NotifyIcon1.Visible = true; this.Hide(); //NotifyIcon1.BalloonTipText = "Minimized To Tray" //NotifyIcon1.ShowBalloonTip(250) } else if (this.WindowState == FormWindowState.Normal) { CurrentTimer.Start(); NotifyIcon1.Visible = false; } }
private void StartButton_Click(object sender, EventArgs e) { if (StopButton.Enabled == false) { ResetData(); } _document.InactiveTimer = 1; _document.KeysCounter = 0; CurrentTimer.Start(); _document.gHook.hook(); SetAvailability(false, false, true, true, false); WindowState = FormWindowState.Minimized; }
private async void OnLeavingBackground(object sender, LeavingBackgroundEventArgs e) { try { if (CurrentTimer != null && IsTimerInProgress) { CurrentTimer.CheckTime(); } if (IsTimerInProgress) { await NotificationManager.Current.RemoveAllNotificationsButFirstAsync(IsInPomodoro, CurrentTimer.StartTime + CurrentTimer.TotalTime); await DataService.RemoveFuturePeriodsAsync(); } } catch (Exception ex) { Microsoft.AppCenter.Crashes.Crashes.TrackError(ex); } }
/// <summary> /// A timer that fires at the specified time. /// </summary> /// <param name="t">The time to fire at.</param> /// <returns>A stream which fires at the specified time.</returns> public Stream <T> At(Cell <IMaybe <T> > t) { StreamSink <T> alarm = new StreamSink <T>(); CurrentTimer current = new CurrentTimer(); IListener l = t.Listen(m => { current.Timer.Match(timer => timer.Cancel(), () => { }); current.Timer = m.Match( timer => Maybe.Just(this.implementation.SetTimer(timer, () => { lock (this.eventQueue) { this.eventQueue.Enqueue(new Event(timer, alarm)); } // Open and close a transaction to trigger queued // events to run. Transaction.RunVoid(() => { }); })), Maybe.Nothing <ITimer>); }); return(alarm.AddCleanup(l)); }
private void MinimizeToTrayButton_Click(object sender, EventArgs e) { CurrentTimer.Stop(); MinimizeButtonFlag = true; // button was just clicked this.WindowState = FormWindowState.Minimized; }
private void TimeSelectForm_Load(object sender, EventArgs e) { CurrentTimer.Start(); }
public void Awake() { Bomb = GetComponent <Bomb>(); holdable = Bomb.GetComponentInChildren <FloatingHoldable>(); timerComponent = Bomb.GetTimer(); widgetManager = Bomb.WidgetManager; holdable.OnLetGo += () => BombStatus.Instance.currentBomb = null; Color modeColor = ModeColors[Tweaks.CurrentMode]; BombStatus.Instance.TimerPrefab.color = modeColor; timerComponent.text.color = modeColor; timerComponent.StrikeIndicator.RedColour = modeColor; if (Tweaks.CurrentMode == Mode.Zen) { ZenModeTimePenalty = Mathf.Abs(Modes.settings.ZenModeTimePenalty); ZenModeTimerRate = -timerComponent.GetRate(); timerComponent.SetRateModifier(ZenModeTimerRate); Modes.initialTime = timerComponent.TimeRemaining; //This was in the original code to make sure the bomb didn't explode on the first strike Bomb.NumStrikesToLose++; } realTimeStart = Time.unscaledTime; BombEvents.OnBombDetonated += OnDetonate; BombEvents.OnBombSolved += OnSolve; foreach (BombComponent component in Bomb.BombComponents) { Dictionary <string, object> makeEventInfo(string type) { Dictionary <string, object> eventInfo = new Dictionary <string, object>() { { "type", type }, { "moduleID", Modes.GetModuleID(component) }, { "bombTime", CurrentTimer }, { "realTime", Time.unscaledTime - realTimeStart }, }; if (componentIDs.TryGetValue(component, out int loggingID)) { eventInfo["loggingID"] = loggingID; } return(eventInfo); } component.OnPass += delegate { BombStatus.Instance.UpdateSolves(); var eventInfo = makeEventInfo("PASS"); if (Tweaks.CurrentMode == Mode.Time) { if ( !Modes.settings.ComponentValues.TryGetValue(Modes.GetModuleID(component), out double ComponentValue) && !Modes.DefaultComponentValues.TryGetValue(Modes.GetModuleID(component), out ComponentValue) ) { ComponentValue = 10; } if ( !Modes.settings.TotalModulesMultiplier.TryGetValue(Modes.GetModuleID(component), out double totalModulesMultiplier) && !Modes.DefaultTotalModulesMultiplier.TryGetValue(Modes.GetModuleID(component), out totalModulesMultiplier) ) { totalModulesMultiplier = 0; } var modules = Bomb.GetSolvableComponentCount(); var points = ComponentValue + modules * totalModulesMultiplier; float finalMultiplier = Mathf.Min(Modes.Multiplier, Modes.settings.TimeModeMaxMultiplier); float time = (float)(points * finalMultiplier * Modes.settings.TimeModePointMultiplier); float finalTime = Math.Max(Modes.settings.TimeModeMinimumTimeGained, time); // Show the alert string alertText = ""; if (Math.Round(totalModulesMultiplier, 3) != 0) { alertText += $"{ComponentValue} + {totalModulesMultiplier:0.###} <size=36>x</size> {modules} mods = {points:0}\n"; } string multiplierText = Math.Round(Modes.settings.TimeModePointMultiplier, 3) == 1 ? "" : $"<size=36>x</size> {Modes.settings.TimeModePointMultiplier:0.###} "; alertText += $"{points:0} points <size=36>x</size> {finalMultiplier:0.#} {multiplierText}= {(time > 0 ? "+" : "")}{time.FormatTime()}\n"; if (time < Modes.settings.TimeModeMinimumTimeGained) { alertText += $"Min Time Added = {(finalTime > 0 ? "+" : "")}{finalTime.FormatTime()}\n"; } eventInfo["timeMode"] = alertText.TrimEnd('\n').Replace("<size=36>x</size>", "×"); // Build the logging information for time mode. alertText += component.GetModuleDisplayName(); AddAlert(alertText.Replace(' ', ' '), Color.green); // Replace all spaces with nbsp since we don't want the line to wrap. CurrentTimer += finalTime; Modes.Multiplier += Modes.settings.TimeModeSolveBonus; BombStatus.Instance.UpdateMultiplier(); } Tweaks.LogJSON("LFAEvent", eventInfo); return(false); }; var OnStrike = component.OnStrike; component.OnStrike = (BombComponent source) => { var eventInfo = makeEventInfo("STRIKE"); if (Tweaks.CurrentMode == Mode.Time) { float multiplier = Modes.Multiplier - Modes.settings.TimeModeMultiplierStrikePenalty; float finalMultiplier = Math.Max(multiplier, Modes.settings.TimeModeMinMultiplier); // Show the alert string alertText = $"TIME LOST = {Modes.settings.TimeModeTimerStrikePenalty:0.###} <size=36>x</size> {CurrentTimer.FormatTime()} = {(CurrentTimer * Modes.settings.TimeModeTimerStrikePenalty).FormatTime()}\n"; alertText += $"MULTIPIER = {Modes.Multiplier:0.#} - {Modes.settings.TimeModeMultiplierStrikePenalty:0.#} = {multiplier:0.#}\n"; if (multiplier < Modes.settings.TimeModeMinMultiplier) { alertText += $"REDUCED TO MIN = {finalMultiplier}\n"; } eventInfo["timeMode"] = alertText.TrimEnd('\n').Replace("<size=36>x</size>", "×"); // Build the logging information for time mode. alertText += component.GetModuleDisplayName(); AddAlert(alertText.Replace(' ', ' '), Color.red); Modes.Multiplier = finalMultiplier; BombStatus.Instance.UpdateMultiplier(); if (CurrentTimer < (Modes.settings.TimeModeMinimumTimeLost / Modes.settings.TimeModeTimerStrikePenalty)) { CurrentTimer -= Modes.settings.TimeModeMinimumTimeLost; } else { CurrentTimer -= CurrentTimer * Modes.settings.TimeModeTimerStrikePenalty; } // We can safely set the number of strikes to -1 since it's going to be increased by the game after us. Bomb.NumStrikes = -1; } OnStrike(source); // These mode modifications need to happen after the game handles the strike since they change the timer rate. if (Tweaks.CurrentMode == Mode.Zen) { Bomb.NumStrikesToLose++; ZenModeTimerRate = Mathf.Max(ZenModeTimerRate - Mathf.Abs(Modes.settings.ZenModeTimerSpeedUp), -Mathf.Abs(Modes.settings.ZenModeTimerMaxSpeed)); timerComponent.SetRateModifier(ZenModeTimerRate); CurrentTimer += ZenModeTimePenalty * 60; ZenModeTimePenalty += Mathf.Abs(Modes.settings.ZenModeTimePenaltyIncrease); } if (Tweaks.CurrentMode == Mode.Steady) { timerComponent.SetRateModifier(1); CurrentTimer -= Modes.settings.SteadyModeFixedPenalty * 60 - Modes.settings.SteadyModePercentPenalty * BombStartingTimer; } BombStatus.Instance.UpdateStrikes(); Tweaks.LogJSON("LFAEvent", eventInfo); return(false); }; } var moduleTweaks = new Dictionary <string, Func <BombComponent, ModuleTweak> >() { { "Emoji Math", bombComponent => new EmojiMathLogging(bombComponent) }, { "Probing", bombComponent => new ProbingLogging(bombComponent) }, { "SeaShells", bombComponent => new SeaShellsLogging(bombComponent) }, { "WordScrambleModule", bombComponent => new WordScramblePatch(bombComponent) }, { "Color Decoding", bombComponent => new ColorDecodingTweak(bombComponent) }, { "TurnTheKeyAdvanced", bombComponent => new TTKSTweak(bombComponent) }, { "Wires", bombComponent => new WiresLogging(bombComponent) }, { "Keypad", bombComponent => new KeypadLogging(bombComponent) } }; modules = new string[Bomb.Faces.Sum(face => face.Anchors.Count)]; anchors = new decimal[Bomb.Faces.Sum(face => face.Anchors.Count)][]; bombLogInfo = new Dictionary <string, object>() { { "serial", JsonConvert.DeserializeObject <Dictionary <string, string> >(Bomb.WidgetManager.GetWidgetQueryResponses(KMBombInfo.QUERYKEY_GET_SERIAL_NUMBER, null)[0])["serial"] }, { "displayNames", displayNames }, { "ids", ids }, { "anchors", anchors }, { "modules", modules }, { "timestamp", DateTime.Now.ToString("O") } }; modulesUnactivated = Bomb.BombComponents.Count; foreach (BombComponent component in Bomb.BombComponents) { KMBombModule bombModule = component.GetComponent <KMBombModule>(); if (bombModule != null && (bombModule.ModuleType == "TurnTheKey" || Tweaks.settings.ModuleTweaks)) { switch (bombModule.ModuleType) { // TTK is our favorite Zen mode compatible module // Of course, everything here is repurposed from Twitch Plays. case "TurnTheKey": new TTKComponentSolver(component, bombModule, Tweaks.CurrentMode.Equals(Mode.Zen) ? Modes.initialTime : timerComponent.TimeRemaining); break; // Correct some mispositioned objects in older modules case "ForeignExchangeRates": case "resistors": case "CryptModule": case "LEDEnc": // This fixes the position of the module itself (but keeps the status light in its original location, which fixes it) component.transform.Find("Model").transform.localPosition = new Vector3(0.004f, 0, 0); break; case "Listening": // This fixes the Y-coordinate of the position of the status light component.transform.Find("StatusLight").transform.localPosition = new Vector3(-0.0761f, 0.01986f, 0.075f); break; case "TwoBits": case "errorCodes": case "primeEncryption": case "memorableButtons": case "babaIsWho": case "colorfulDials": case "scalarDials": // This fixes the position of the status light component.GetComponentInChildren <StatusLightParent>().transform.localPosition = new Vector3(0.075167f, 0.01986f, 0.076057f); break; case "tWords": case "moon": case "sun": case "jewelVault": // This fixes the scale of the light components component.GetComponentInChildren <Light>().range *= component.transform.lossyScale.x; break; } // This fixes the position of the highlight switch (bombModule.ModuleType) { case "babaIsWho": case "needlesslyComplicatedButton": component.GetComponent <Selectable>().Highlight.transform.localPosition = Vector3.zero; break; } } ModuleTweak moduleTweak = null; string moduleType = bombModule != null ? bombModule.ModuleType : component.ComponentType.ToString(); if (moduleTweaks.ContainsKey(moduleType) && (moduleType != "WordScrambleModule" || Tweaks.settings.ModuleTweaks)) { moduleTweak = moduleTweaks[moduleType](component); } component.StartCoroutine(GetModuleInformation(component, moduleTweak)); if (component.ComponentType == ComponentTypeEnum.Mod || component.ComponentType == ComponentTypeEnum.NeedyMod) { ReflectedTypes.FindModeBoolean(component); } else if (Tweaks.settings.ModuleTweaks) { switch (component.ComponentType) { case ComponentTypeEnum.Keypad: Tweaks.FixKeypadButtons(((KeypadComponent)component).buttons); break; case ComponentTypeEnum.Simon: Tweaks.FixKeypadButtons(((SimonComponent)component).buttons); break; case ComponentTypeEnum.Password: Tweaks.FixKeypadButtons(component.GetComponentsInChildren <KeypadButton>()); break; case ComponentTypeEnum.NeedyVentGas: Tweaks.FixKeypadButtons(((NeedyVentComponent)component).YesButton, ((NeedyVentComponent)component).NoButton); break; } } } }
protected virtual void OnStop() { CurrentTimer.Dispose(); CurrentTimer = null; ChangeStatus(AgentStatus.Stopped); }