/// <summary>
 /// Adds a view to the list of opened views, and sets <see cref="CurrentView"/>.
 /// </summary>
 /// <param name="view"></param>
 protected void OnNewViewOpened(IView view)
 {
     OpenedViews.Add(view);
     CurrentView = view;
 }
Exemplo n.º 2
0
        async Task AddDataPointsAsync(MeasurementHolder measurementHolder)
        {
            var dictPerfCtrCurrentMeasurements = measurementHolder.GetLastMeasurements();

            if (_dataPoints.Count == 0) // nothing yet
            {
                for (int i = 0; i < NumDataPoints; i++)
                {
                    _dataPoints[i] = new List <uint>(dictPerfCtrCurrentMeasurements.Values); // let all init points be equal, so y axis scales IsStartedFromZero
                }
            }
            else
            {
                _dataPoints[_bufferIndex++] = new List <uint>(dictPerfCtrCurrentMeasurements.Values);
                if (_bufferIndex == _dataPoints.Count) // wraparound?
                {
                    _bufferIndex = 0;
                }
            }
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            if (DoFullGCPerSample)
            {
                DoGC();// do a GC.Collect on main thread for every sample (the graphing uses memory)
            }
            // this needs to be done on UI thread
            _chart.Series.Clear();
            _chart.ChartAreas.Clear();
            ChartArea chartArea = new ChartArea("ChartArea");

            chartArea.AxisY.LabelStyle.Format = "{0:n0}";
            chartArea.AxisY.LabelStyle.Font   = new System.Drawing.Font("Consolas", 12);
            _chart.ChartAreas.Add(chartArea);
            int ndxSeries = 0;

            chartArea.AxisY.IsStartedFromZero = false;
            if (SetMaxGraphTo100)
            {
                _chart.ChartAreas[0].AxisY.Maximum = 100;
            }
            foreach (var entry in dictPerfCtrCurrentMeasurements)
            {
                var series = new Series
                {
                    ChartType = SeriesChartType.Line,
                    Name      = entry.Key.ToString()
                };
                _chart.Series.Add(series);
                if (UpdateInterval == 0) // if we're not doing auto update on timer, we're iterating or doing manual measurement
                {
                    series.MarkerSize  = 10;
                    series.MarkerStyle = MarkerStyle.Circle;
                }
                for (int i = 0; i < _dataPoints.Count; i++)
                {
                    var ndx = _bufferIndex + i;
                    if (ndx >= _dataPoints.Count)
                    {
                        ndx -= _dataPoints.Count;
                    }
                    var dp = new DataPoint(i + 1, _dataPoints[ndx][ndxSeries]);
                    series.Points.Add(dp);
                }
                ndxSeries++;
            }
            _chart.Legends.Clear();
            _chart.Legends.Add(new Legend());
            _chart.DataBind();

            if (_editorTracker != null)
            {
                var(openedViews, lstLeakedViews) = _editorTracker.GetCounts();
                OpenedViews.Clear();
                LeakedViews.Clear();
                foreach (var dictEntry in openedViews)
                {
                    var sp = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    sp.Children.Add(new TextBlock()
                    {
                        Text = $"{ dictEntry.Key,-15} {dictEntry.Value,3}", FontFamily = FontFamilyMono
                    });
                    OpenedViews.Add(sp);
                }

                foreach (var entry in lstLeakedViews)
                {
                    var sp = new StackPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    sp.Children.Add(new TextBlock()
                    {
                        Text = $"{ entry._contentType,-15} Ser#={entry._serialNo,3} {entry._dtCreated:hh:mm:ss} {entry._filename}", FontFamily = FontFamilyMono
                    });