Beispiel #1
0
        /// <summary>
        /// Occurs when the data source state has changed
        /// Modifies the status bar to indicate a change has occured in the data source
        /// </summary>
        /// <param name="e"></param>
        private void StateChanged(TVDataAccessorStateArgs e)
        {
            //Change the control in a thread safe manner
            this.Invoke((MethodInvoker) delegate
            {
                if (e.State == AccessorState.Loading)
                {
                    //reset the request queue size
                    _requestEventsQueueSize = 0;
                    _stopLink.Visible       = true;
                    _progressBar.Visible    = true;
                    //start the progress timer
                    _progressTimer.Start();
                }
                else if (e.State == AccessorState.Tailing)
                {
                    _tail = true;

                    _requestEventsQueueSize = 0;
                    _stopLink.Visible       = true;
                    _progressBar.Visible    = true;
                    //start the progress timer
                    _progressTimer.Start();

                    if (_dataGrid.Rows.Count > 0)
                    {
                        //select the last request in the list
                        DeselectAll();
                        int lastRow = _dataGrid.Rows.GetLastRow(DataGridViewElementStates.Visible);
                        _dataGrid.Rows[lastRow].Selected          = true;
                        _dataGrid.FirstDisplayedScrollingRowIndex = lastRow;
                    }
                }
                else if (e.State == AccessorState.Idle)
                {
                    //stop the tail if tail was on

                    _tail = false;

                    lock (_listLock)
                    {
                        //load all the remaining requests to the queue if there's any
                        DrainRequestEvents();
                        _stopLink.Visible    = false;
                        _progressBar.Visible = false;
                        _progressTimer.Stop();
                    }
                }
            }
                        );
        }
        /// <summary>
        /// Changes the enabled menues based on the state of the file
        /// </summary>
        /// <param name="e"></param>
        private void FileStateChanged(TVDataAccessorStateArgs e)
        {
            if (TrafficViewer.Instance.TrafficViewerFile.State == AccessorState.Saving)
            {
                _tvfChanged = false;
            }
            else if (TrafficViewer.Instance.TrafficViewerFile.State != AccessorState.Idle)
            {
                _tvfChanged = true;
            }

            this.Invoke((MethodInvoker) delegate
            {
                if (TrafficViewer.Instance.TrafficViewerFile.State == AccessorState.Idle)
                {
                    _menuStrip.State = TrafficViewerControls.TVMenuStripStates.Loaded;
                }
                else
                {
                    _menuStrip.State = TrafficViewerControls.TVMenuStripStates.Loading;
                }
            });
        }