예제 #1
0
        private void PermissionAnalysis(List <string> permissionList)
        {
            try
            {
                List <Threat> threatList = new List <Threat>();
                foreach (string permission in permissionList)
                {
                    int    threatvalue = GetThreatValue(permission);
                    Threat threat      = new Threat(permission.Replace("android.permission.", ""), threatvalue);
                    threatList.Add(threat);
                }
                threatList.Sort(new ThreatResultComparer());
                //Draw
                //////////////////////////////////////
                Chart chart = new Chart();
                chart.View3D = true;
                Title title = new Title();
                title.Text = "Permission Threats";
                chart.Titles.Add(title);
                chart.ColorSet = "VisiRed";
                //X坐标
                Axis       xaxis = new Axis();
                AxisLabels xal   = new AxisLabels
                {
                    Enabled = true,
                    Angle   = 0
                };
                xaxis.AxisLabels = xal;
                // Y坐标
                Axis       yaxis = new Axis();
                AxisLabels yal   = new AxisLabels
                {
                    Enabled = true,
                    Angle   = 0
                };
                yaxis.AxisLabels = yal;
                yaxis.Suffix     = "/10";

                chart.AxesX.Add(xaxis);
                chart.AxesY.Add(yaxis);

                DataSeries dataSeries = new DataSeries();
                dataSeries.RenderAs = RenderAs.Bar;

                foreach (Threat threat in threatList)
                {
                    DataPoint dataPoint = new DataPoint {
                        AxisXLabel = threat.name, YValue = threat.value
                    };
                    dataSeries.DataPoints.Add(dataPoint);
                    //dataSeries.ShowInLegend = true;
                }
                chart.Series.Add(dataSeries);
                Grid grid = new Grid();
                grid.Height = 250;
                grid.Children.Add(chart);
                panel1.Children.Add(grid);
            }
            catch
            {
            }
        }