CodeTV.MainForm.OnTimerGUIUpdate C# (CSharp) Method

OnTimerGUIUpdate() private method

private OnTimerGUIUpdate ( ) : void
return void
        private void OnTimerGUIUpdate()
        {
            //Trace.WriteLine("OnTimerGUIUpdate");

            // To avoid the GetSignalStatistics CPU usage during a GUI drag
            //if (Utils.GetCapture() != IntPtr.Zero) return;

            if (this.currentGraphBuilder is ITV)
            {
                bool locked, present;
                int strength, quality;
                if ((this.currentGraphBuilder as ITV).GetSignalStatistics(out locked, out present, out strength, out quality))
                {
                    if (quality < 0)
                        quality = 0;
                    else if (quality > 100)
                        quality = 100;

                    int strengthPercentage = strength;
                    if (strength < 0)
                    {
                        //strengthPercentage = 0;
                        strengthPercentage = 100 + strength;
                        if(strengthPercentage < 0)
                            strengthPercentage = 0;
                    }
                    else if (strength <= 100)
                        strengthPercentage = strength;
                    else if (strength < 40000)
                    {
                        if (quality > 80)
                        {
                            strengthPercentage = Math.Min(100, strength);
                        }
                        else
                            strengthPercentage = (int)(5.0f * (float)strength / 2000.0f);
                    }
                    else
                        strengthPercentage = 100;

                    // strength = Signal to Noise Ratio (SNR) * 1000
                    // (http://en.wikipedia.org/wiki/Signal-to-noise_ratio)
                    // ***(http://www.ces.clemson.edu/linux/signal_quality.shtml)

                    this.toolStripProgressBarSignalStrength.Value = (int)strengthPercentage;
                    this.toolStripStatusLabelSignalStrength.Text = (present ? "*" : "") + this.toolStripProgressBarSignalStrength.Value.ToString() + "%";
                    this.toolStripProgressBarSignalStrength.ToolTipText = this.toolStripStatusLabelSignalStrength.Text + " (" + strength + " dB)";

                    this.toolStripProgressBarSignalQuality.Value = quality;
                    this.toolStripProgressBarSignalQuality.ToolTipText = (locked ? "*" : "") + quality.ToString() + "%";
                    this.toolStripStatusLabelSignalQuality.Text = this.toolStripProgressBarSignalQuality.ToolTipText;
                }
            }

            if (this.currentGraphBuilder is ITimeShifting)
            {
                ITimeShifting timeShifting = (this.currentGraphBuilder as ITimeShifting);
                TimeSpan start;
                TimeSpan stop;
                timeShifting.GetPositions(out start, out stop);
                TimeSpan position = timeShifting.GetPosition();

                int minimum = 0;
                int maximum = (int)((stop - start).TotalSeconds * 1000.0);
                int pos = (int)(((position > start ? position : start) - start).TotalSeconds * 1000.0);
                if (position < start)
                    timeShifting.SetPosition(start);

                if (maximum > 0 && pos < maximum)
                {
                    this.panelTimeLine.trackBarExTimeLine.Minimum = minimum;
                    this.panelTimeLine.trackBarExTimeLine.Maximum = maximum;
                    //this.panelTimeLine.trackBarExTimeLine.Value = pos;
                    this.panelTimeLine.trackBarExTimeLine.SetValue(pos);
                }

                this.toolStripStatusLabelTimeLinePosition.Text = GetTimeString(position) + " (" + GetTimeString(start) + " - " + GetTimeString(stop) + ")";
            }
            else if (this.currentGraphBuilder is IPlayer)
            {
                IPlayer player = (this.currentGraphBuilder as IPlayer);
                TimeSpan duration = player.GetDuration();
                TimeSpan position = player.GetPosition();

                int minimum = 0;
                int maximum = (int)(duration.TotalSeconds * 1000.0);
                int pos = (int)(position.TotalSeconds * 1000.0);

                if (maximum > 0 && pos < maximum)
                {
                    this.panelTimeLine.trackBarExTimeLine.Minimum = minimum;
                    this.panelTimeLine.trackBarExTimeLine.Maximum = maximum;
                    //this.panelTimeLine.trackBarExTimeLine.Value = pos;
                    this.panelTimeLine.trackBarExTimeLine.SetValue(pos);
                }

                this.toolStripStatusLabelTimeLinePosition.Text = GetTimeString(position) + " / " + GetTimeString(duration);
            }
        }
MainForm