public bool Draw() { Matrix transformMatrix; if (ScaleType == InterfaceScaleType.Game) { PlayerInput.SetZoom_World(); transformMatrix = Main.GameViewMatrix.ZoomMatrix; } else if (ScaleType == InterfaceScaleType.UI) { PlayerInput.SetZoom_UI(); transformMatrix = Main.UIScaleMatrix; } else { PlayerInput.SetZoom_Unscaled(); transformMatrix = Matrix.Identity; } bool result = false; Main.spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, transformMatrix); try { result = DrawSelf(); } catch (Exception e) { TimeLogger.DrawException(e); } Main.spriteBatch.End(); return(result); }
void ControlTimeOut() { if (!clientController.ClientCommunication.IsConnected) { if (!timeoutEnd.HasValue) { timeoutEnd = DateTime.Now.AddSeconds(connTimeOut); } else { if (DateTime.Now > timeoutEnd) { state = Connection.Disconnected; clientController.ClientCommunication.Disconnect(); TimeLogger.Log("CLIENT - connection timeout - check IP {0} and try again", _insertedString); ResetControlTimeVariables(); } } } else { state = Connection.Connected; ResetControlTimeVariables(); } }
private void RenderContent() { if (!IsVisible) { return; } if (_operator == null || _operator.Outputs.Count <= 0) { return; } if (TimeLoggingSourceEnabled) { TimeLogger.BeginFrame(App.Current.Model.GlobalTime); } D3DDevice.BeginFrame(); try { var context = new OperatorPartContext(_defaultContext, (float)App.Current.Model.GlobalTime); // FIXME: the following lines are commented out to enable different values for debugOverlay-Variable //if (context.Time != _previousTime) //{ var invalidator = new OperatorPart.InvalidateInvalidatables(); _operator.Outputs[_shownOutputIndex].TraverseWithFunctionUseSpecificBehavior(null, invalidator); //_previousTime = context.Time; //} var evaluationType = _operator.Outputs[_shownOutputIndex].Type; switch (evaluationType) { case FunctionType.Scene: case FunctionType.Mesh: _renderSetup.Operator = _operator; var isMeshType = evaluationType == FunctionType.Mesh; _renderSetup.Render(context, _shownOutputIndex, ShowGridAndGizmos, isMeshType); _D3DImageContainer.InvalidateD3DImage(); break; case FunctionType.Image: _renderSetup.Operator = _operator; _renderSetup.RenderImage(context, _shownOutputIndex); _D3DImageContainer.InvalidateD3DImage(); break; } } catch (Exception exception) { Logger.Error(exception.ToString()); } D3DDevice.EndFrame(); if (TimeLoggingSourceEnabled) { TimeLogger.EndFrame(); } }
static public GameData LoadGameData() { string destination = Path.Combine(Application.persistentDataPath, manualFileLastIPPath, universalSaveName); // Get FILE or throw exception FileStream file; if (File.Exists(destination)) { file = File.OpenRead(destination); } else { throw new System.Exception(string.Format("File at {0} not found", destination)); } // Get data from BINARY FILE (LOAD) BinaryFormatter binForm = new BinaryFormatter(); GameData data = (GameData)binForm.Deserialize(file); file.Close(); TimeLogger.Log("Loaded file from {0}", destination); return(data); }
static public void SaveGameData(string lastIPUsed) { string destination = Path.Combine(Application.persistentDataPath, manualFileLastIPPath, universalSaveName); // Get or create FILE FileStream file; if (File.Exists(destination)) { file = File.OpenWrite(destination); } else { Directory.CreateDirectory(Path.Combine(Application.persistentDataPath, manualFileLastIPPath)); file = File.Create(destination); } // Get DATA to FILE GameData data = new GameData { lastIP = lastIPUsed }; // Format BINARY FILE (SAVE) BinaryFormatter binForm = new BinaryFormatter(); binForm.Serialize(file, data); file.Close(); TimeLogger.Log("Save last ip ({0}) file in {1}", lastIPUsed, destination); }
private static void DivisionTests() { ResultsLogger.Log("Division"); TimeLogger.LogExecutionTime("Int", () => { var __ = 300 / 291; }); TimeLogger.LogExecutionTime("Long", () => { var __ = 34534500 / 29534534531; }); TimeLogger.LogExecutionTime("Float", () => { var __ = 2.342342340f / 29.132423f; }); TimeLogger.LogExecutionTime("Double", () => { var __ = 30.00010d / 20000.91d; }); TimeLogger.LogExecutionTime("Decimal", () => { var __ = 30.000030m / 291.9m; }); }
private static void SubstractionTests() { ResultsLogger.Log("Square root"); TimeLogger.LogExecutionTime("Int", () => { var __ = 300 - 291; }); TimeLogger.LogExecutionTime("Long", () => { var __ = 34534500 - 29534534531; }); TimeLogger.LogExecutionTime("Float", () => { var __ = 2.342342340f - 29.132423f; }); TimeLogger.LogExecutionTime("Double", () => { var __ = 30.00010d - 20000.91d; }); TimeLogger.LogExecutionTime("Decimal", () => { var __ = 30.000030m - 291.9m; }); }
public bool Draw() { Matrix transformMatrix; if (this.ScaleType == InterfaceScaleType.Game) { PlayerInput.SetZoom_World(); transformMatrix = Main.GameViewMatrix.ZoomMatrix; } else if (this.ScaleType == InterfaceScaleType.UI) { PlayerInput.SetZoom_UI(); transformMatrix = Main.UIScaleMatrix; } else { PlayerInput.SetZoom_Unscaled(); transformMatrix = Matrix.Identity; } bool flag = false; Main.spriteBatch.Begin(SpriteSortMode.Deferred, (BlendState)null, (SamplerState)null, (DepthStencilState)null, (RasterizerState)null, (Effect)null, transformMatrix); try { flag = this.DrawSelf(); } catch (Exception ex) { TimeLogger.DrawException(ex); } Main.spriteBatch.End(); return(flag); }
public void SettingSystemTime_Always_ChangesTime() { SystemTime.Set(new DateTime(2000, 1, 1)); //Ustawienie sztucznej daty string output = TimeLogger.CreateMessage("a"); StringAssert.Contains("01.01.2000", output); }
public void SettingSystemTime_Always_ChangesTime() { SystemTime.Set(new DateTime(2000, 1, 1)); string output = TimeLogger.CreateMessage("a"); StringAssert.Contains("1/1/2000", output); }
public void StartReporterThread() { var settings = new Settings(new SettingsReader("ActivityLogger.ini")); ActivityReport = new ActivityReport(); _activityLogger = ActivityLogger.Instance(ActivityReport, settings); var mouseClickLogger = MouseClickLogger.Instance(); var mouseClickReporter = MouseClickReporter.Instance(_activityLogger); mouseClickReporter.Subscribe(mouseClickLogger); var keyLogger = KeyLogger.Instance(); var keyReporter = KeyReporter.Instance(_activityLogger); keyReporter.Subscribe(keyLogger); Task.Factory.StartNew(() => { var activityReporter = new ActivityReporter(_activityReceiver); activityReporter.Subscribe(_activityLogger); var mouseLogger = new MouseLogger(); var mouseReporter = new MouseReporter(_activityLogger); mouseReporter.Subscribe(mouseLogger); var processLogger = new ProcessLogger(); var processReporter = new ProcessReporter(_activityLogger); processReporter.Subscribe(processLogger); var timeLogger = new TimeLogger(); var timeReporter = new TimeReporter(_activityLogger); timeReporter.Subscribe(timeLogger); var activityTypeLogger = new ActivityTypeLogger(settings); var activityTypeReporter = new ActivityTypeReporter(_activityLogger); activityTypeReporter.Subscribe(activityTypeLogger); while (true) { Thread.Sleep(1000); // KeyLogger & MouseClickLogger will log when keystrokes/clicks are // recorded, so no need to tell it to log here. mouseLogger.Log(); processLogger.Log(); timeLogger.Log(); activityTypeLogger.DetermineActivityType( processReporter.ProcessReport, mouseReporter.MouseReport, MouseClickReporter.Instance().MouseClickReport, KeyReporter.Instance().KeyReport); activityTypeLogger.Log(); _activityLogger.Log(); } }); }
public void SettingSystemTime_Always_ChangesTime() { //设置一个假日期 SystemTime.Set(new DateTime(2000, 1, 1)); string output = TimeLogger.CreateMessage("a"); // 微软的和Nunit的StringAssert.Contains有差异,两个参数是相反的 StringAssert.Contains("2000/1/1", output); }
protected override void StateEnd() { clientController.InstantiateBoardManager(); uiController.DeactiveBackButton(); TimeLogger.Log("CLIENT {0} - game start", clientController.ClientId); ResetStateController(); }
internal void Rename(TimeLogger _clock, string p) { string newName = Manager.GetUniqueName(p); _clocks.Add(newName, _clocks[_clock.Name]); _clocks.Remove(_clock.Name); _clock.Name = _clock.NiceName = newName; RefreshClocks(); }
internal void Delete(TimeLogger _clock) { DialogResult rslt = MessageBox.Show(string.Format("Permanently delete '{0}' ?", _clock.Name), "Delete item", MessageBoxButtons.OKCancel); if (rslt == DialogResult.OK) { Manager.Delete(_clock); RefreshClocks(); } }
private static void Main(string[] args) { //MulticastDelegateProgram pgm = new MulticastDelegateProgram(); //pgm.Execute(); using (TimeLogger timeLogger = new TimeLogger("Testing Thread Execution")) { Print(); } Console.Read(); }
private void InitializeGame() { player = new Player(); enemyManager = EnemyManager.GetInstance(); enemyManager.Initialize(); projectileManager = ProjectileManager.GetInstance(); projectileManager.Initialize(); loopTimer = LoopTimer.GetInstance(); timeLogger = TimeLogger.GetInstance(); Loop(); }
public static void DrawBackgroundWater() { if (Main.drawToScreen) { Reflection.DrawWaters(true, -1, true); } else { Main.spriteBatch.Draw(Main.instance.backWaterTarget, Main.sceneBackgroundPos - Main.screenPosition, Microsoft.Xna.Framework.Color.White); TimeLogger.DetailedDrawTime(11); } }
public void ScheduleGetResultsRequest() { int id = ClientId; GetResultsRequestData request = new GetResultsRequestData(id); TimeLogger.Log("CLIENT {0} - schedule request - GetResults", id); IJob job = DataPackageWrapper.CreateSendDataJob(m_ClientDriver, m_clientToServerConnection[0], request.DataToArray()); jobHandler.QueueJob(job); }
protected override void GetResultsCommand(UdpNetworkDriver driver, NetworkConnection connection, DataStreamReader strm) { GetResultsResponseData responseReceived = new GetResultsResponseData(strm); ClientController.PlayerState playerState = (ClientController.PlayerState)responseReceived.playerState; PlayerTurnData.UIColors playerColor = (PlayerTurnData.UIColors)responseReceived.playerColor; TimeLogger.Log("CLIENT {0} - {3} - response - GetResults ({1} at {2})", ((ClientCommunication)owner).ClientId, playerState, responseReceived.playerPosition, playerColor); GetResultsEvent?.Invoke(playerState, responseReceived.playerPosition, playerColor); }
protected override void ExecuteLogic() { if (!isExecuting) { TimeLogger.Log("SERVER - end game"); isExecuting = true; ProcessEndGame(); serverController.DelayedCall(ResetGame, 10f); // NODE SYNCHRONIZATION DELAY - future match feedback } }
public void LogTime_FailedOnDBSave_LogException_Success() { FakeUserLogger userLogger = new FakeUserLogger(); FakeTaskManager taskManager = new FakeTaskManager(); FakeTaskAlwaysFalse task = new FakeTaskAlwaysFalse(); FakeErrorLogger errorLogger = new FakeErrorLogger(); TimeLogger time = new TimeLogger(userLogger, taskManager, task, null, errorLogger); var ex = Assert.Throws <Exception>(() => time.LogTime(2, 30, "Working on TimesheetApp")); Assert.That(ex.Message, Is.EqualTo(errorLogger.Error.Message)); }
public void LogTime_ValidInput_Success() { FakeUserLogger userLogger = new FakeUserLogger(); FakeTaskManager taskManager = new FakeTaskManager(); FakeTaskAlwaysTrue task = new FakeTaskAlwaysTrue(); FakeEmailSender emailSender = new FakeEmailSender(); TimeLogger time = new TimeLogger(userLogger, taskManager, task, emailSender, null); time.LogTime(2, 30, "Working on TimesheetApp"); StringAssert.Contains("Time logged successfully", emailSender.Title); }
public async Task InvokeAsync(HttpContext context) { using (var time = TimeLogger.Start()) { context.Response.OnStarting(state => { var httpContext = (HttpContext)state; httpContext.Response.Headers.Add("Time", time.FormatedTime); return(Task.CompletedTask); }, context); await _next(context); } }
protected override void GetResultsCommand(UdpNetworkDriver driver, NetworkConnection connection, DataStreamReader strm) { GetResultsRequestData requestReceived = new GetResultsRequestData(strm); int clientId = requestReceived.playerId; PlayerSimplifiedTurnData data = ((ServerCommunication)owner).PopPlayerData(clientId); TimeLogger.Log("SERVER - {0}[{1}] - {3} - request - GetResults ({2})", clientId, connection.InternalId, data.state, (PlayerTurnData.UIColors)data.playerColor); GetResultsResponseData response = new GetResultsResponseData(clientId, data.playerColor, data.state, data.position); IJob job = DataPackageWrapper.CreateSendDataJob(driver, connection, response.DataToArray()); jobHandler.QueueJob(job); }
protected override void PutPlayCommand(UdpNetworkDriver driver, NetworkConnection connection, DataStreamReader strm) { PutPlayRequestData requestReceived = new PutPlayRequestData(strm); TimeLogger.Log("SERVER - {0}[{1}] request - PutPlay (({2:00},{3:00}) ({4:00},{5:00}) ({6}))", requestReceived.playerId, connection.InternalId, requestReceived.movementTo.x, requestReceived.movementTo.y, requestReceived.sound.x, requestReceived.sound.y, requestReceived.PlayerAttacked); PutPlayEvent?.Invoke(requestReceived); PutPlayResponseData response = new PutPlayResponseData(requestReceived.playerId); IJob job = DataPackageWrapper.CreateSendDataJob(driver, connection, response.DataToArray()); jobHandler.QueueJob(job); }
static void Main(string[] args) { ILogger logger = new TimeLogger(); IWeatherClient client = new FlurlWeatherClient(); SalutationBuilder salutationBuilder = new SalutationBuilder(); Greeter greeter = new Greeter(logger, salutationBuilder); logger.Print("Calling OpenWeatherMap"); Weather weather = client.getWeather("Oberhausen"); logger.Print(weather.name); Console.ReadLine(); }
void EndScript() { endReached = true; TimeLogger.Log("Player use the GIVE UP button"); Destroy(this.GetComponent <UnityEngine.UI.Button>()); controller.CleanMovementGlowTiles(); controller.CleanSoundGlowTiles(); controller.Audio.PlayerDiedEffect(); CoroutineHelper.DelayedCall(controller, controller.ReloadClient, 3.5f); uiController.SetActiveClientFooterGroup(false); }
public void LogTime_SendEmailError_BadData_Fail() { FakeUserLogger userLogger = new FakeUserLogger(); userLogger.badEmail = "*****@*****.**"; FakeTaskManager taskManager = new FakeTaskManager(); FakeTaskAlwaysTrue task = new FakeTaskAlwaysTrue(); IEmailSender emailSender = Substitute.For <IEmailSender>(); TimeLogger time = new TimeLogger(userLogger, taskManager, task, emailSender, null); time.LogTime(2, 30, "Working on TimesheetApp"); emailSender.DidNotReceive().SendEmail("*****@*****.**", "Time logged successfully", "2 hours and 30 minutes successfully logged to task with ID=100"); }
private void Update() { var time = Bass.BASS_ChannelBytes2Seconds(_soundStream, Bass.BASS_ChannelGetPosition(_soundStream, BASSMode.BASS_POS_BYTES)); if (time >= _soundLength) { if (_settings.Looped) { Bass.BASS_ChannelSetPosition(_soundStream, 0); } else if (!_exitTimer.IsRunning) { _exitTimer.Restart(); } else if (_exitTimer.ElapsedMilliseconds >= 2000) { _form.Close(); } } // try { // _undoRedoStack.ProcessReceivedCommands(); // } // catch (Exception exception) { // Logger.Warn("Error when excecuting remote command: {0}", exception.Message); // } //double time = (double)_globalTime.ElapsedTicks / Stopwatch.Frequency; TimeLogger.BeginFrame(time); D3DDevice.BeginFrame(); DrawFrame((float)time); D3DDevice.SwapChain.Present(_settings.VSyncEnabled ? 1 : 0, PresentFlags.None); Int64 elapsedTicks = _stopwatch.ElapsedTicks; Console.Write("time: {0:000.000}, fps: {1:000.0} ({2:000.0}/{3:000.0}), resources used: {4,2}, free: {5,2} \r", time, (double)_numMeasureValues * Stopwatch.Frequency / _averagedElapsed.Sum(e => e), (double)Stopwatch.Frequency / _averagedElapsed.Max(), (double)Stopwatch.Frequency / _averagedElapsed.Min(), ResourceManager.NumUsedResources, ResourceManager.NumFreeResources); _averagedElapsed[_currentAveragedElapsedIndex] = elapsedTicks; _currentAveragedElapsedIndex++; _currentAveragedElapsedIndex %= _numMeasureValues; _stopwatch.Restart(); D3DDevice.EndFrame(); TimeLogger.EndFrame(); }