/// <summary>
        /// Sets up the chart style.
        /// </summary>
        /// <param name="chartXy"></param>
        private void SetupChartStyle(ChartXy chartXy)
        {
            ChartXyVisualStyle cstyle = chartXy.ChartVisualStyle;

            cstyle.Background      = new Background(Color.White);
            cstyle.BorderThickness = new Thickness(1);
            cstyle.BorderColor     = new BorderColor(Color.Navy);

            cstyle.Padding = new DevComponents.DotNetBar.Charts.Style.Padding(6);

            ChartSeriesVisualStyle sstyle = chartXy.ChartSeriesVisualStyle;
            PointMarkerVisualStyle pstyle = sstyle.MarkerHighlightVisualStyle;

            pstyle.Background = new Background(Color.Yellow);
            pstyle.Type       = PointMarkerType.Ellipse;
            pstyle.Size       = new Size(15, 15);

            CrosshairVisualStyle chstyle = chartXy.ChartCrosshair.CrosshairVisualStyle;

            chstyle.ValueXLineStyle.LineColor   = Color.Navy;
            chstyle.ValueXLineStyle.LinePattern = LinePattern.Dot;

            chstyle.ValueYLineStyle.LineColor   = Color.Navy;
            chstyle.ValueYLineStyle.LinePattern = LinePattern.Dot;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds a series to the given chart.
        /// </summary>
        /// <param name="chartXy"></param>
        public void AddSeries(ChartXy chartXy)
        {
            // Let's load our data in from our app resources.

            System.Diagnostics.PerformanceCounter cpuCounter;
            ManagementScope scope = new ManagementScope("\\\\.\\ROOT\\cimv2");

            //create object query
            ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_PerfFormattedData_PerfProc_Process");

            //create object searcher
            ManagementObjectSearcher searcher =
                new ManagementObjectSearcher(scope, query);

            //get collection of WMI objects
            ManagementObjectCollection data = searcher.Get();
            //List<string> data = ShellServices.LoadText("BubblePlot_Life.Resources.LifeExpectancy.txt");

            // data.Sort();

            string lastPosition = string.Empty;

            ChartSeries series = null;

            // Iterate through each data element, creating new series based
            // upon the associated Country name.

            foreach (var item in data)
            {
                if (int.Parse(item["IDProcess"].ToString()) != 0)
                {
                    string s = item["Name"] + "\t" + "Process" + "\t" + item["IDProcess"] + "\t" +
                               item["WorkingSet"] + "\t" + item["PercentProcessorTime"] + "\t" + item["WorkingSet"];
                    CountryInfo cinfo = new CountryInfo(s);

                    if (series == null || series.Name.Equals(cinfo.ProcessName) == false)
                    {
                        // Add the current series, and create the new country series.

                        if (series != null)
                        {
                            chartXy.ChartSeries.Add(series);
                        }

                        series = new ChartSeries(cinfo.ProcessName, SeriesType.Bubble);



                        // Locate our predefined series style, and use it
                        // to establish the series look and feel.

                        //SeriesStyle ss = GetSeriesStyle(cinfo.Country);
                        //Random rdm = new Random();
                        //KnownColor[] names = (KnownColor[])Enum.GetValues(typeof(KnownColor));
                        //KnownColor randomColorName = names[rdm.Next(names.Length)];
                        //Color rdmColor = Color.FromKnownColor(randomColorName);
                        //ss.MarkerColor = rdmColor;

                        ChartSeriesVisualStyle sstyle = series.ChartSeriesVisualStyle;
                        PointMarkerVisualStyle pstyle = sstyle.MarkerVisualStyle;
                        sstyle.ItemColor   = Color.Black;
                        pstyle.BorderColor = Color.FromArgb(150, Color.WhiteSmoke);
                        pstyle.BorderWidth = 2;
                        // pstyle.Background = new Background(Color.FromArgb(128, ss.MarkerColor));

                        pstyle = sstyle.MarkerHighlightVisualStyle;

                        pstyle.BorderColor = Color.White;
                        pstyle.BorderWidth = 4;
                    }

                    // Our SeriesPoint defines the x/y coordinate (GDP/LifeExpectancy),
                    // plus the relative bubble size (Size).

                    series.SeriesPoints.Add(new
                                            SeriesPoint(cinfo.ProcessID, cinfo.MemoryUsage, cinfo.Size));
                }

                if (series != null)
                {
                    chartXy.ChartSeries.Add(series);
                }
            }
        }