Exemplo n.º 1
0
 private void AddRitToTreeview(RitSamenVatting Rit, int NodeNr)
 {
     treeView1.Nodes.Add(Rit.StartTijd.Substring(0, 10));
     treeView1.Nodes[NodeNr].Nodes.Add("Tijd");
     treeView1.Nodes[NodeNr].Nodes.Add("Snelheid");
     treeView1.Nodes[NodeNr].Nodes.Add("Afstand");
     treeView1.Nodes[NodeNr].Nodes[0].Nodes.Add("Start: " + Rit.StartTijd.Substring(11, 8));
     treeView1.Nodes[NodeNr].Nodes[0].Nodes.Add("Eind: " + Rit.EindTijd.Substring(11, 8));
     treeView1.Nodes[NodeNr].Nodes[1].Nodes.Add("Gem.: " + (Rit.SnelheidGem / 10).ToString());
     treeView1.Nodes[NodeNr].Nodes[1].Nodes.Add("Max.: " + (Rit.SnelheidMax / 10).ToString());
     treeView1.Nodes[NodeNr].Nodes[2].Nodes.Add("Totaal: " + (Rit.Afstand / (double)1000).ToString());
     treeView1.Nodes[NodeNr].Nodes[2].Nodes.Add("Berg Op: " + (Rit.AfstandBergOp / (double)1000).ToString());
     treeView1.Nodes[NodeNr].Nodes[2].Nodes.Add("Berg Af: " + (Rit.AfstandBergAf / (double)1000).ToString());
 }
Exemplo n.º 2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            RitSamenVatting Rit    = new RitSamenVatting();
            int             NodeNr = 0;

            string[] filePaths = Directory.GetFiles(@"C:\Users\Michiel\Documents\Bryton\", "*.bdx");

            foreach (string naam in filePaths)
            {
                Rit = XMLLezen.LeesXMLSamenVatting(naam);
                Ritten.Add(Rit);
                AddRitToTreeview(Rit, NodeNr);
                NodeNr += 1;
            }
        }
Exemplo n.º 3
0
        public static RitSamenVatting LeesXMLSamenVatting(string bestand)
        {
            string element = "";
            double number  = 0;
            int    integer = 0;

            RitSamenVatting Rsv = new RitSamenVatting();

            try
            {
                using (FileStream fileSteam = File.OpenRead(bestand))
                {
                    using (XmlReader reader = XmlReader.Create(fileSteam))
                    {
                        reader.MoveToContent();
                        reader.ReadToDescendant("laps");
                        Rsv.BestandsNaam = bestand;

                        while (reader.Read())
                        {
                            switch (reader.NodeType)
                            {
                            case XmlNodeType.Element:
                                element = reader.Name;
                                for (int attInd = 0; attInd < reader.AttributeCount; attInd++)
                                {
                                    reader.MoveToAttribute(attInd);
                                    switch (element)
                                    {
                                    case "summary":
                                        if (reader.Name == "start")
                                        {
                                            Rsv.StartTijd = reader.Value;
                                        }
                                        if (reader.Name == "end")
                                        {
                                            Rsv.EindTijd = reader.Value;
                                        }
                                        break;

                                    case "speed":
                                        if (reader.Name == "max")
                                        {
                                            if (Double.TryParse(reader.Value, out number))
                                            {
                                                Rsv.SnelheidMax = number;
                                            }
                                        }
                                        if (reader.Name == "avg")
                                        {
                                            if (Double.TryParse(reader.Value, out number))
                                            {
                                                Rsv.SnelheidGem = number;
                                            }
                                        }
                                        break;

                                    case "hrm":
                                        if (reader.Name == "max")
                                        {
                                            if (int.TryParse(reader.Value, out integer))
                                            {
                                                Rsv.HartslagMax = integer;
                                            }
                                        }
                                        if (reader.Name == "avg")
                                        {
                                            if (int.TryParse(reader.Value, out integer))
                                            {
                                                Rsv.HartslagGem = integer;
                                            }
                                        }
                                        break;

                                    case "cadance":
                                        if (reader.Name == "max")
                                        {
                                            if (int.TryParse(reader.Value, out integer))
                                            {
                                                Rsv.CadanceMax = integer;
                                            }
                                        }
                                        if (reader.Name == "avg")
                                        {
                                            if (int.TryParse(reader.Value, out integer))
                                            {
                                                Rsv.CadanceGem = integer;
                                            }
                                        }
                                        break;
                                    }
                                }
                                break;

                            case XmlNodeType.Text:
                                switch (element)
                                {
                                case "distance":
                                {
                                    if (int.TryParse(reader.Value, out integer))
                                    {
                                        Rsv.Afstand = integer;
                                    }
                                }
                                break;

                                case "calorie":
                                {
                                    if (Double.TryParse(reader.Value, out number))
                                    {
                                        Rsv.Calorie = number;
                                    }
                                }
                                break;

                                case "altloss":
                                {
                                    if (Double.TryParse(reader.Value, out number))
                                    {
                                        Rsv.HoogteVerlies = number;
                                    }
                                }
                                break;

                                case "altgain":
                                {
                                    if (Double.TryParse(reader.Value, out number))
                                    {
                                        Rsv.HoogteWinst = number;
                                    }
                                }
                                break;

                                case "rtime":
                                {
                                    if (int.TryParse(reader.Value, out integer))
                                    {
                                        Rsv.RitTijd = integer;
                                    }
                                }
                                break;

                                case "gainaltlen":
                                {
                                    if (int.TryParse(reader.Value, out integer))
                                    {
                                        Rsv.AfstandBergOp = integer;
                                    }
                                }
                                break;

                                case "lostaltlen":
                                {
                                    if (int.TryParse(reader.Value, out integer))
                                    {
                                        Rsv.AfstandBergAf = integer;
                                    }
                                }
                                break;

                                case "gainalttime":
                                {
                                    if (int.TryParse(reader.Value, out integer))
                                    {
                                        Rsv.TijdBergOp = integer;
                                    }
                                }
                                break;

                                case "lostalttime":
                                {
                                    if (int.TryParse(reader.Value, out integer))
                                    {
                                        Rsv.TijdBergAf = integer;
                                    }
                                }
                                break;
                                }
                                break;

                            case XmlNodeType.EndElement:
                                break;
                            }
                        }
                    }
                }
            }
            catch (XmlException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("Exception object Line, pos: (" + ex.LineNumber + "," + ex.LinePosition + ")");
            }
            finally
            {
            }
            return(Rsv);
        }
Exemplo n.º 4
0
        private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            RitSamenVatting Rit       = new RitSamenVatting();
            List <LogPoint> LogPoints = new List <LogPoint>();
            double          xTeller   = 1;

            if (e.Node.Parent == null)
            //e.Node.Parent.GetType() == typeof(TreeNode))
            {
                treeView1.CollapseAll();
                Rit = Ritten[e.Node.Index];
                treeView1.Nodes[e.Node.Index].ExpandAll();
            }
            LogPoints = XMLLezen.LeesLogPointsUitXML(Rit.BestandsNaam);

            while (chart1.Series.Count > 0)
            {
                chart1.Series.RemoveAt(0);
            }
            while (chart1.Legends.Count > 0)
            {
                chart1.Legends.RemoveAt(0);
            }
            while (chart1.Titles.Count > 0)
            {
                chart1.Titles.RemoveAt(0);
            }

            chart1.ChartAreas["ChartArea1"].AxisY2.Enabled = AxisEnabled.True;
            chart1.Titles.Add("bestand");
            chart1.Titles[0].Text = Rit.BestandsNaam;

            if (chart1.Series.IsUniqueName("Cadance"))
            {
                chart1.Series.Add("Cadance");
                chart1.Legends.Add(new Legend("Cadances"));
                chart1.Series[0].LegendText         = "Cadance";
                chart1.Legends[0].DockedToChartArea = "ChartArea1";
                chart1.Series[0].YAxisType          = AxisType.Secondary;
            }
            if (chart1.Series.IsUniqueName("HartRate"))
            {
                chart1.Series.Add("HartRate");
                chart1.Legends.Add(new Legend("HartRate"));
                chart1.Series[1].LegendText         = "HartRate";
                chart1.Legends[1].DockedToChartArea = "ChartArea1";
                chart1.Series[1].YAxisType          = AxisType.Secondary;
            }

            if (chart1.Series.IsUniqueName("Speed"))
            {
                chart1.Series.Add("Speed");
                chart1.Legends.Add(new Legend("Speed"));
                chart1.Series[2].LegendText         = "Speed";
                chart1.Legends[2].DockedToChartArea = "ChartArea1";
            }


            foreach (LogPoint lp in LogPoints)
            {
                chart1.Series[0].Points.AddXY(xTeller, lp.Cadance);
                chart1.Series[1].Points.AddXY(xTeller, lp.Hartrate);
                chart1.Series[2].Points.AddXY(xTeller, lp.Speed);
                xTeller += 1;
            }

            chart1.Series[0].ChartType = SeriesChartType.FastLine;
            chart1.Series[0].Color     = Color.Blue;
            chart1.Series[1].ChartType = SeriesChartType.FastLine;
            chart1.Series[1].Color     = Color.Red;
            chart1.Series[2].ChartType = SeriesChartType.FastLine;
            chart1.Series[2].Color     = Color.Cyan;
        }