public void Reset()
 {
     m_lines.Clear();
     _bitrateGraphCanvas.IfNotNull(i => i.Children.Clear());
     m_currentBitrateGraph  = new BitrateGraph(new SolidColorBrush(Colors.Red));
     m_highestPlayableGraph = new BitrateGraph(new SolidColorBrush(Colors.Green));
 }
        private void RepaintGraph(BitrateGraph graph, ulong bitrate)
        {
            // Do we have a current graph line yet? If not,
            // then we haven't started displaying anything, 
            // so just create the first line and get out
            if (graph.CurrentLine == null)
            {
                graph.LastBitrate = bitrate;
                graph.CurrentLine = CreateGraphLine(knBitrateGraphLineMinX, ComputeBitrateGraphValue(bitrate),
                    knBitrateGraphLineMinX, ComputeBitrateGraphValue(bitrate), graph.Color);

                // Add the line to our canvas
                _bitrateGraphCanvas.Children.Add(graph.CurrentLine);
                return;
            }

            // Has our frame rate value changed?
            if (graph.LastBitrate != bitrate)
            {
                // Our frame rate value has changed, so we need to draw a 
                // new vertical line connecting the old value to the new value,
                // and then draw a new horizontal line representing the new value.
                // First, the horizontal line.
                Line horizontalLine = CreateGraphLine(graph.CurrentLine.X2, ComputeBitrateGraphValue(bitrate),
                    graph.CurrentLine.X2, ComputeBitrateGraphValue(bitrate), graph.Color);

                // Add the line to our canvas
                _bitrateGraphCanvas.Children.Add(horizontalLine);

                // Now create the new vertical line
                Line verticalLine = CreateGraphLine(graph.CurrentLine.X2, graph.CurrentLine.Y1,
                    graph.CurrentLine.X2, horizontalLine.Y1, graph.Color);

                // Add this line to our canvas
                _bitrateGraphCanvas.Children.Add(verticalLine);

                // The current line becomes the horizontal line
                graph.CurrentLine = horizontalLine;
            }
            else
            {
                // Our frame rate has not changed from our last repaint,
                // so increment the X value of our current line.
                if (graph.CurrentLine.X2 < knBitrateGraphLineMaxX)
                {
                    graph.CurrentLine.X2++;
                }
                else
                {
                    // Our current line has gone over our maximum x value,
                    // so let's walk over all the lines and collapse any that have fallen off the
                    // minimum X value of our graph
                    foreach (Line graphLine in m_lines)
                    {
                        if ((graphLine != null) && (graphLine.Visibility == Visibility.Visible))
                        {
                            if (graphLine.X1 > knBitrateGraphLineMinX)
                            {
                                graphLine.X1--;
                            }
                            if (graphLine.X2 > knBitrateGraphLineMinX)
                            {
                                graphLine.X2--;
                            }
                            else
                            {
                                graphLine.Visibility = Visibility.Collapsed;
                            }
                        }
                    }
                    graph.CurrentLine.X2++;
                }
            }

            // Remember our fps for the next go around
            graph.LastBitrate = bitrate;
        }
 public void Reset()
 {
     m_lines.Clear();
     _bitrateGraphCanvas.IfNotNull(i => i.Children.Clear());
     m_currentBitrateGraph = new BitrateGraph(new SolidColorBrush(Colors.Red));
     m_highestPlayableGraph = new BitrateGraph(new SolidColorBrush(Colors.Green));
 }
        private void RepaintGraph(BitrateGraph graph, ulong bitrate)
        {
            // Do we have a current graph line yet? If not,
            // then we haven't started displaying anything,
            // so just create the first line and get out
            if (graph.CurrentLine == null)
            {
                graph.LastBitrate = bitrate;
                graph.CurrentLine = CreateGraphLine(knBitrateGraphLineMinX, ComputeBitrateGraphValue(bitrate),
                                                    knBitrateGraphLineMinX, ComputeBitrateGraphValue(bitrate), graph.Color);

                // Add the line to our canvas
                _bitrateGraphCanvas.Children.Add(graph.CurrentLine);
                return;
            }

            // Has our frame rate value changed?
            if (graph.LastBitrate != bitrate)
            {
                // Our frame rate value has changed, so we need to draw a
                // new vertical line connecting the old value to the new value,
                // and then draw a new horizontal line representing the new value.
                // First, the horizontal line.
                Line horizontalLine = CreateGraphLine(graph.CurrentLine.X2, ComputeBitrateGraphValue(bitrate),
                                                      graph.CurrentLine.X2, ComputeBitrateGraphValue(bitrate), graph.Color);

                // Add the line to our canvas
                _bitrateGraphCanvas.Children.Add(horizontalLine);

                // Now create the new vertical line
                Line verticalLine = CreateGraphLine(graph.CurrentLine.X2, graph.CurrentLine.Y1,
                                                    graph.CurrentLine.X2, horizontalLine.Y1, graph.Color);

                // Add this line to our canvas
                _bitrateGraphCanvas.Children.Add(verticalLine);

                // The current line becomes the horizontal line
                graph.CurrentLine = horizontalLine;
            }
            else
            {
                // Our frame rate has not changed from our last repaint,
                // so increment the X value of our current line.
                if (graph.CurrentLine.X2 < knBitrateGraphLineMaxX)
                {
                    graph.CurrentLine.X2++;
                }
                else
                {
                    // Our current line has gone over our maximum x value,
                    // so let's walk over all the lines and collapse any that have fallen off the
                    // minimum X value of our graph
                    foreach (Line graphLine in m_lines)
                    {
                        if ((graphLine != null) && (graphLine.Visibility == Visibility.Visible))
                        {
                            if (graphLine.X1 > knBitrateGraphLineMinX)
                            {
                                graphLine.X1--;
                            }
                            if (graphLine.X2 > knBitrateGraphLineMinX)
                            {
                                graphLine.X2--;
                            }
                            else
                            {
                                graphLine.Visibility = Visibility.Collapsed;
                            }
                        }
                    }
                    graph.CurrentLine.X2++;
                }
            }

            // Remember our fps for the next go around
            graph.LastBitrate = bitrate;
        }