Exemplo n.º 1
0
        private void LoadXml()
        {
            //System.Net.WebUtility.HtmlEncode(Strvalue);
            //System.Net.WebUtility.HtmlDecode(Strvalue);
            string line;

            line = "";
            //bool isFirst = true;
            XMLApplicableFormat r = new XMLApplicableFormat();

            using (StreamReader reader = new StreamReader(txtBrowse1.Text))
            {
                while ((line = reader.ReadLine()) != null)
                {
                    if (!String.IsNullOrWhiteSpace(line) && !String.IsNullOrEmpty(line))
                    {
                        if (line.Contains("<Rule "))
                        {
                            string AttrFilter = "Fc";
                            string cd         = line.Substring(line.IndexOf(AttrFilter) + AttrFilter.Length + 2);
                            string val1       = cd.Substring(0, cd.IndexOf("\""));
                            r.Fc = Int32.Parse(val1);

                            AttrFilter = "Oc";
                            cd         = line.Substring(line.IndexOf(AttrFilter) + AttrFilter.Length + 2);
                            val1       = cd.Substring(0, cd.IndexOf("\""));
                            r.Oc       = Int32.Parse(val1);

                            //AttrFilter = "W";
                            //cd = line.Substring(line.IndexOf(AttrFilter) + AttrFilter.Length + 2);
                            //val1 = cd.Substring(0, cd.IndexOf("\"")  );
                            //r.W = Int32.Parse(val1);

                            r.Rule.Add(line);
                            AnalyticalData.Add(r.Fc.ToString() + "," + r.Oc.ToString());
                        }
                        if (line.Contains("<Tuple "))
                        {
                            r.Rule.Add(line);
                        }
                        if (line.Contains("</Rule>"))
                        {
                            MyApplicableXMLformat.Add(r);
                            r = new XMLApplicableFormat();
                        }
                    }
                }
            }
            foreach (string str in AnalyticalData)
            {
                string[] arr = str.Split(',');

                if (htFc.ContainsKey(Int32.Parse(arr[0])))
                {
                    htFc[Int32.Parse(arr[0])] = (Int32.Parse(htFc[Int32.Parse(arr[0])].ToString()) + 1);
                }
                else
                {
                    htFc.Add(Int32.Parse(arr[0]), 1);
                }

                if (htOc.ContainsKey(Int32.Parse(arr[1])))
                {
                    htOc[Int32.Parse(arr[1])] = (Int32.Parse(htOc[Int32.Parse(arr[1])].ToString()) + 1);
                }
                else
                {
                    htOc.Add(Int32.Parse(arr[1]), 1);
                }



                //if (htW.ContainsKey(Int32.Parse(arr[2])))
                //{
                //    htW[Int32.Parse(arr[2])] = (Int32.Parse(htW[Int32.Parse(arr[2])].ToString()) + 1);
                //}
                //else
                //{
                //    htW.Add(Int32.Parse(arr[2]), 1);
                //}
            }

            StringBuilder sb2 = new StringBuilder();

            sb2.Append("---FC---" + Environment.NewLine);
            foreach (var d in htFc)
            {
                sb2.Append(d.Key.ToString() + "->" + d.Value.ToString() + Environment.NewLine);
            }
            //sb2.Append("---OC---" + Environment.NewLine);
            //foreach (DictionaryEntry d in htOc)
            //{
            //    sb2.Append(d.Key.ToString() + ":" + d.Value.ToString() + Environment.NewLine);
            //}
            //sb2.Append("---W---" + Environment.NewLine);
            //foreach (DictionaryEntry d in htW)
            //{
            //    sb2.Append(d.Key.ToString() + ":" + d.Value.ToString() + Environment.NewLine);
            //}
            txtStatisticalData.Text = sb2.ToString();

            //Draw it.

            chart1.Series.Clear();
            var series1 = new System.Windows.Forms.DataVisualization.Charting.Series
            {
                Name              = "TuplesCount",
                Color             = System.Drawing.Color.Green,
                IsVisibleInLegend = false,
                IsXValueIndexed   = true,
                ChartType         = SeriesChartType.Line
            };

            this.chart1.Series.Add(series1);



            foreach (var d in htFc)
            {
                series1.Points.AddXY(d.Key, d.Value);
            }


            chart1.Invalidate();
        }
Exemplo n.º 2
0
 private void LoadTreeView(int tabIndex)
 {
     if (tabIndex == 0)
     {
         treeview_Fc.Nodes.Clear();
         TreeNode root = new TreeNode("Root");
         treeview_Fc.Nodes.Add(root);
         List <XMLApplicableFormat> SortedList;
         if (rbAsc.Checked)
         {
             SortedList = MyApplicableXMLformat.OrderBy(o => o.Fc).ToList();
         }
         else
         {
             SortedList = MyApplicableXMLformat.OrderByDescending(o => o.Fc).ToList();
         }
         int m = 0;
         for (int x = 0; x < SortedList.Count; x++)
         {
             XMLApplicableFormat item  = SortedList[x];
             TreeNode            _Rule = new TreeNode();
             //TreeNode Tuples = new TreeNode();
             for (int i = 0; i < item.Rule.Count; i++)
             {
                 if (i == 0)
                 {
                     _Rule = new TreeNode(item.Fc.ToString() + ")-" + item.Rule[i]);
                 }
                 else
                 {
                     _Rule.Nodes.Add(item.Rule[i]);
                 }
             }
             // _Rule.Nodes.Add(Tuples);
             m++;
             // treeviewCasesNr.Nodes.Add(_Rule);
             root.Nodes.Add(_Rule);
             if (m > Int32.Parse(txtTop.Text))
             {
                 break;
             }
         }
     }
     if (tabIndex == 1)
     {
         treeview_Oc.Nodes.Clear();
         TreeNode root = new TreeNode("Root");
         treeview_Oc.Nodes.Add(root);
         List <XMLApplicableFormat> SortedList;
         if (rbAsc.Checked)
         {
             SortedList = MyApplicableXMLformat.OrderBy(o => o.Oc).ToList();
         }
         else
         {
             SortedList = MyApplicableXMLformat.OrderByDescending(o => o.Oc).ToList();
         }
         int m = 0;
         for (int x = 0; x < SortedList.Count; x++)
         {
             XMLApplicableFormat item   = SortedList[x];
             TreeNode            _Rule  = new TreeNode();
             TreeNode            Tuples = new TreeNode();
             for (int i = 0; i < item.Rule.Count; i++)
             {
                 if (i == 0)
                 {
                     _Rule = new TreeNode(item.Oc.ToString() + ")-" + item.Rule[i]);
                 }
                 else
                 {
                     _Rule.Nodes.Add(item.Rule[i]);
                 }
             }
             // _Rule.Nodes.Add(Tuples);
             m++;
             // treeviewCasesNr.Nodes.Add(_Rule);
             root.Nodes.Add(_Rule);
             if (m > Int32.Parse(txtTop.Text))
             {
                 break;
             }
         }
     }
     if (tabIndex == 2)
     {
         treeview_W.Nodes.Clear();
         TreeNode root = new TreeNode("Root");
         treeview_W.Nodes.Add(root);
         List <XMLApplicableFormat> SortedList;
         if (rbAsc.Checked)
         {
             SortedList = MyApplicableXMLformat.OrderBy(o => o.Oc).ToList();
         }
         else
         {
             SortedList = MyApplicableXMLformat.OrderByDescending(o => o.Fc).ToList();
         }
         int m = 0;
         for (int x = 0; x < SortedList.Count; x++)
         {
             XMLApplicableFormat item  = SortedList[x];
             TreeNode            _Rule = new TreeNode();
             //TreeNode Tuples = new TreeNode();
             for (int i = 0; i < item.Rule.Count; i++)
             {
                 if (i == 0)
                 {
                     _Rule = new TreeNode(item.Oc.ToString() + ")-" + item.Rule[i]);
                 }
                 else
                 {
                     _Rule.Nodes.Add(item.Rule[i]);
                 }
             }
             // _Rule.Nodes.Add(Tuples);
             m++;
             // treeviewCasesNr.Nodes.Add(_Rule);
             root.Nodes.Add(_Rule);
             if (m > Int32.Parse(txtTop.Text))
             {
                 break;
             }
         }
     }
 }