Example #1
0
        /// <summary>
        /// Extracts data for the specified graph and populates the ListView with the data.
        /// </summary>
        /// <param name="graph_name">name of graph</param>
        /// <param name="series_name">name of series to be extracted</param>
        /// <param name="g_data">reference to a GraphDataForm object</param>
        /// <param name="use_iterator">specify whether to use an iterator when extracting data</param>
        public void OpenGraphData(string graph_name, string series_name, GraphDataForm g_data,
                                  bool use_iterator)
        {
            if (_currentSession.IsOpenedOrCreated == false)
            {
                return;
            }

            Graph current_graph = null;

            if (null == g_data)
            {
                g_data = new GraphDataForm();
            }
            GraphsList g_list         = _currentRun.Graphs;
            Series     current_series = null;

            current_graph  = g_list[graph_name];
            current_series = current_graph.Series[series_name];

            //PointsDefinition class used to get names of values
            for (int i = 0; i < current_series.PointsDefinition.Count; i++)
            {
                g_data.AddColumnToListView(current_series.PointsDefinition[i].Name);
            }

            //add all graph series to ComboBox
            foreach (Series s in current_graph.Series)
            {
                g_data.AddSeries(s.Name);
            }
            //select current series
            g_data.SelectSeries(current_series.Name);

            g_data.Text             = current_graph.Name.DisplayName;
            g_data.CurrentGraphName = current_graph.Name.Name;

            //fill ListView with data of current series
            FillDataIntoListView(current_series, g_data, current_graph.HasTimeAxis, use_iterator);

            _lastGraph = current_graph.Name.Name;

            //show the form
            if (false == g_data.Visible)
            {
                g_data.ShowDialog();
            }
        }
Example #2
0
        /// <summary>
        /// Inserts the list of graphs and their series to the TreeView.
        /// </summary>
        private void GetGraphsFromRun()
        {
            GraphView.Nodes.Clear();
            GraphView.BeginUpdate();

            //reference for easy access
            GraphsList graphs = _currentRun.Graphs;

            try
            {
                //iterate through all graphs
                for (int i = 0; i < graphs.Count; i++)
                {
                    //add a graph to TreeVeiw
                    GraphView.Nodes.Add(graphs[i].Name.Name, graphs[i].Name.Name, 1);
                    try
                    {
                        //if there are no series in graph - mark it as an empty
                        if (graphs[i].Series.Count == 0)
                        {
                            GraphView.Nodes[i].ImageIndex = _EmptyGraph;
                        }

                        //iterate through all series of current graph
                        foreach (Series s in graphs[i].Series)
                        {
                            //add series as a child of a graph
                            GraphView.Nodes[i].Nodes.Add(s.Name);
                        }
                    }
                    catch (Exception ex)
                    {
                        //mark problematic graph as empty
                        GraphView.Nodes[i].ImageIndex = _EmptyGraph;
                        MessageBox.Show(ex.Message);
                    }
                }
            }
            finally
            {
                GraphView.EndUpdate();
            }

            //uncheck show all graphs menu item
            showAllGraphsToolStripMenuItem.Checked = false;
        }
        private void ReadTests()
        {
            using (StreamReader reader = new StreamReader(FileName))
            {
                int testCasesCount = Int32.Parse(reader.ReadLine());

                for (int i = 0; i < testCasesCount; i++)
                {
                    int citiesNumber = Int32.Parse(reader.ReadLine());
                    GraphsList.Add(new Graph(citiesNumber));

                    for (int c = 0; c < citiesNumber; c++)
                    {
                        GraphsList[i].AddNewCity(reader.ReadLine());
                        int howManyNeighbours = Int32.Parse(reader.ReadLine());
                        for (int neigh = 0; neigh < howManyNeighbours; neigh++)
                        {
                            string[] neighbourDetails = reader.ReadLine().Trim().Split(' ');
                            GraphsList[i].AddNewNeighbour(c, Int32.Parse(neighbourDetails[0]), Int32.Parse(neighbourDetails[1]));
                        }
                    }

                    int pathToFindNumber = Int32.Parse(reader.ReadLine());

                    for (int p = 0; p < pathToFindNumber; p++)
                    {
                        string[] citiesToFindPatch = reader.ReadLine().Trim().Split(' ');

                        Console.WriteLine(GraphsList[i].FindPatchForCities(citiesToFindPatch[0], citiesToFindPatch[1]));
                        CwCount++;
                    }

                    reader.ReadLine();
                }
            }
        }