private void InitializeInternalState()
        {
            // Initialize text rendering
            TextUtils.StaticInitialize();

            // Time bar display
            _timeBar = new TimeBar(TimeBarCanvas);

            // System Graphs display
            _systemPerformanceGraphs = new SystemPerformanceGraphsCanvas(SystemGraphsCanvas);

            //events
            this.Loaded += FASTBuildMonitorControl_Loaded;

            EventsScrollViewer.PreviewMouseWheel += MainWindow_MouseWheel;
            EventsScrollViewer.MouseWheel += MainWindow_MouseWheel;
            MouseWheel += MainWindow_MouseWheel;
            EventsCanvas.MouseWheel += MainWindow_MouseWheel;

            EventsScrollViewer.PreviewMouseLeftButtonDown += EventsScrollViewer_MouseDown;
            EventsScrollViewer.MouseDown += EventsScrollViewer_MouseDown;
            MouseDown += EventsScrollViewer_MouseDown;
            EventsCanvas.MouseDown += EventsScrollViewer_MouseDown;

            EventsScrollViewer.PreviewMouseLeftButtonUp += EventsScrollViewer_MouseUp;
            EventsScrollViewer.MouseUp += EventsScrollViewer_MouseUp;
            MouseUp += EventsScrollViewer_MouseUp;
            EventsCanvas.MouseUp += EventsScrollViewer_MouseUp;

            EventsScrollViewer.PreviewMouseDoubleClick += EventsScrollViewer_MouseDoubleClick;
            EventsScrollViewer.MouseDoubleClick += EventsScrollViewer_MouseDoubleClick;

            OutputTextBox.PreviewMouseDoubleClick += OutputTextBox_PreviewMouseDoubleClick;
            OutputTextBox.MouseDoubleClick += OutputTextBox_PreviewMouseDoubleClick;
            OutputTextBox.PreviewKeyDown += OutputTextBox_KeyDown;
            OutputTextBox.KeyDown += OutputTextBox_KeyDown;
            OutputTextBox.LayoutUpdated += OutputTextBox_LayoutUpdated;

            OutputWindowComboBox.SelectionChanged += OutputWindowComboBox_SelectionChanged;

            Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() =>
            {
                //update timer
                _timer = new DispatcherTimer();
                _timer.Tick += HandleTick;
                _timer.Interval = new TimeSpan(TimeSpan.TicksPerMillisecond * 16);
                _timer.Start();
            }));
        }
        private void ResetState()
        {
            _fileStreamPosition = 0;
            _fileStream.Seek(0, SeekOrigin.Begin);

            _fileBuffer.Clear();

            _buildRunningState = eBuildRunningState.Ready;
            _buildStatus = eBuildStatus.AllClear;

            _buildStartTimeMS = 0;
            _latestTimeStampMS = 0;

            _hosts.Clear();
            _localHost = null;

            _lastProcessedPosition = 0;
            _bPreparingBuildsteps = false;

            _StaticWindow.EventsCanvas.Children.Clear();
            _StaticWindow.CoresCanvas.Children.Clear();

            // Start by adding a local host
            _localHost = new BuildHost(_cLocalHostName);
            _hosts.Add(_cLocalHostName, _localHost);

            // Always add the prepare build steps event first
            BuildEvent buildEvent = new BuildEvent(_cPrepareBuildStepsText, 0);
            _localHost.OnStartEvent(buildEvent);
            _bPreparingBuildsteps = true;

            // Reset the Output window text
            OutputTextBox.Text = "";

            // Change back the tabcontrol to the TimeLine automatically
            _StaticWindow.MyTabControl.SelectedIndex = (int)eTABs.TAB_TimeLine;

            ResetOutputWindowCombox();

            // progress status
            UpdateBuildProgress(0.0f);
            StatusBarProgressBar.Foreground = (SolidColorBrush)(new BrushConverter().ConvertFrom("#FF06B025"));

            // reset to autoscrolling ON
            _autoScrolling = true;

            // reset our zoom levels
            _zoomFactor = 1.0f;
            _zoomFactorOld = 0.1f;

            // target pid
            _targetPID = 0;
            _lastTargetPIDCheckTimeMS = 0;

            // live build session state
            _isLiveSession = false;

            // graphs
            SystemGraphsCanvas.Children.Clear();
            _systemPerformanceGraphs = new SystemPerformanceGraphsCanvas(SystemGraphsCanvas);

            // allow a free render update on the first frame after the reset
            SetConditionalRenderUpdateFlag(true);

            // reset the cached SteppedBuildTime value
            _sPreviousSteppedBuildTimeMS = 0;
        }