/// <summary> /// Executed when the Replay/Stop button is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnReplay_Click(object sender, EventArgs e) { if (_replayFeed == null) { //Start new replay using specified file name _replayFeed = new ApiEventFeedReplay(txtFileName.Text); string securitySymbol = System.IO.Path.GetFileName(txtFileName.Text).Substring(0, 3); //Create stock to process events _security = new Security(securitySymbol); _replayFeed.AddSecurity(_security); securityMarketView.Security = _security; //Initiate replay on separate thread _replayThread = new Thread(_replayFeed.Execute); _replayThread.Start(); //Update GUI controls btnPause.Enabled = true; btnReplay.Text = "Stop"; ReplayToolTips.SetToolTip(btnReplay, "Stop replay"); } else { //Stop replay Stop(); //Update GUI controls btnPause.Enabled = false; btnReplay.Text = "Replay"; ReplayToolTips.SetToolTip(btnReplay, "Start replay"); btnPause_Click(this, null); } }
/// <summary> /// Executed when the Pause/Resume button is clicked during replay /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPause_Click(object sender, EventArgs e) { if ((_replayFeed != null) && (!_replayFeed.IsPaused)) { _replayFeed.Pause(); btnPause.Text = ">>>"; ReplayToolTips.SetToolTip(btnPause, "Resume replay"); btnNextEvent.Enabled = true; } else { if (_replayFeed != null) { _replayFeed.Resume(); } btnPause.Text = "| |"; ReplayToolTips.SetToolTip(btnPause, "Pause replay"); btnNextEvent.Enabled = false; } }