示例#1
0
        public static PlotModel ProcLostTimePlot(Stat stat, ViewController viewController,
                                                 int intervalNum = 0, double maxTime = -1)
        {
            var model = new PlotModel
            {
                Title = "Потерянное время"
            };

            //---  Init axis  ---//
            (var data, var _) = InitDataAndXaxis(intervalNum, false);

            var yaxis = new LinearAxis();

            yaxis.Position           = AxisPosition.Left;
            yaxis.MajorGridlineStyle = LineStyle.Dot;
            yaxis.MinorGridlineStyle = LineStyle.Dot;
            yaxis.Title             = "Время, с";
            yaxis.AxisTitleDistance = 7;
            yaxis.AbsoluteMinimum   = 0;
            if (maxTime > 0)
            {
                yaxis.Maximum = maxTime;
            }
            yaxis.Key = "Time";

            var xaxis = new CategoryAxis
            {
                Title           = "Процессоры",
                AbsoluteMinimum = -0.5
            };

            for (int i = 0; i < stat.Info.nproc; ++i)
            {
                xaxis.Labels.Add((i + 1).ToString());
                data[0].Items.Add(new ColumnItem(stat.Info.inter[intervalNum].proc_times[i].insuf_sys));
                data[1].Items.Add(new ColumnItem(stat.Info.inter[intervalNum].proc_times[i].insuf_user));
                data[2].Items.Add(new ColumnItem(stat.Info.inter[intervalNum].proc_times[i].idle));
                data[3].Items.Add(new ColumnItem(stat.Info.inter[intervalNum].proc_times[i].comm));
                //Console.WriteLine(intervalNum + " - " + i + "  |  "
                //    + stat.Info.inter[intervalNum].proc_times[i].insuf_sys + " - "
                //    + stat.Info.inter[intervalNum].proc_times[i].insuf_user + " - "
                //    + stat.Info.inter[intervalNum].proc_times[i].idle + " - "
                //    + stat.Info.inter[intervalNum].proc_times[i].comm);
            }
            for (int i = 0; i < 4; ++i)
            {
                data[i].MouseDown += (object sender, OxyMouseDownEventArgs e)
                                     => ProcLostTimePlot_MouseDown(sender, e, viewController, intervalNum);
                model.Series.Add(data[i]);
            }
            model.Axes.Add(xaxis);
            model.Axes.Add(yaxis);
            model.MouseDown += (object sender, OxyMouseDownEventArgs e)
                               => ProcLostTimePlotModel_MouseDown(sender, e, model, viewController);

            if (ViewController.SelectedProc >= 0)
            {
                foreach (var ser in model.Series)
                {
                    var color = (ser as ColumnSeries).FillColor;
                    model.InvalidatePlot(true);
                    for (int j = 0; j < (ser as ColumnSeries).Items.Count; ++j)
                    {
                        (ser as ColumnSeries).Items[j].Color =
                            color.ChangeSaturation((j == ViewController.SelectedProc) ? 1 : 0.5);
                    }
                }
            }

            return(model);
        }