Пример #1
0
        private void CreatePageOfGraphs(string sim, Graph[] graphs)
        {
            if (!panel.Cache.ContainsKey(sim))
            {
                panel.Cache.Add(sim, new Dictionary <int, List <SeriesDefinition> >());
            }

            IStorageReader storage   = GetStorage();
            GraphPage      graphPage = new GraphPage();

            // Configure graphs by applying user overrides.
            for (int i = 0; i < graphs.Length; i++)
            {
                if (graphs[i] != null && graphs[i].Enabled)
                {
                    graphPage.Graphs.Add(ConfigureGraph(graphs[i], sim));
                }

                if (cts.Token.IsCancellationRequested)
                {
                    return;
                }
            }

            // If any sims in this tab are missing from the cache, then populate
            // the cache via the GraphPage instance.
            if (panel.Cache[sim].Count != graphs.Length)
            {
                // Read data from storage.
                IReadOnlyList <GraphPage.GraphDefinitionMap> definitions = graphPage.GetAllSeriesDefinitions(panel, storage, new List <string>()
                {
                    sim
                }).ToList();

                // Now populate the cache for this simulation. The definitions
                // should - in theory - be the same length as the graphs array.
                for (int i = 0; i < graphs.Length; i++)
                {
                    GraphPage.GraphDefinitionMap definition = definitions[i];
                    panel.Cache[sim][i] = definition.SeriesDefinitions;
                    if (cts.Token.IsCancellationRequested)
                    {
                        return;
                    }
                }
            }

            // Finally, add the graphs to the tab.
            GraphTab tab = new GraphTab(sim, this.presenter);

            for (int i = 0; i < graphPage.Graphs.Count; i++)
            {
                tab.AddGraph(graphPage.Graphs[i], panel.Cache[sim][i]);
            }

            this.graphs.Add(tab);
            view.AddTab(tab, panel.NumCols);
        }
Пример #2
0
        private void CreatePageOfGraphs(string sim, Graph[] graphs)
        {
            IStorageReader storage = GetStorage();
            GraphTab tab = new GraphTab(sim, this.presenter);
            for (int i = 0; i < graphs.Length; i++)
            {
                Graph graph = ReflectionUtilities.Clone(graphs[i]) as Graph;
                graph.Parent = panel;
                graph.ParentAllDescendants();

                if (panel.LegendOutsideGraph)
                    graph.LegendOutsideGraph = true;

                if (panel.LegendOrientation != GraphPanel.LegendOrientationType.Default)
                    graph.LegendOrientation = (Graph.LegendOrientationType)Enum.Parse(typeof(Graph.LegendOrientationType), panel.LegendOrientation.ToString());

                if (graph != null && graph.Enabled)
                {
                    // Apply transformation to graph.
                    panel.Script.TransformGraph(graph, sim);

                    if (panel.LegendPosition != GraphPanel.LegendPositionType.Default)
                        graph.LegendPosition = (Graph.LegendPositionType)Enum.Parse(typeof(Graph.LegendPositionType), panel.LegendPosition.ToString());

                    // Create and fill cache entry if it doesn't exist.
                    if (!panel.Cache.ContainsKey(sim) || panel.Cache[sim].Count <= i)
                    {
                        try
                        {
                            int x = storage.GetSimulationID(sim);
                        }
                        catch (KeyNotFoundException)
                        {
                            throw new Exception($"Illegal simulation name: '{sim}'. Try running the simulation, and if that doesn't fix it, there is a problem with your config script.");
                        }
                        List<SeriesDefinition> definitions = graph.GetDefinitionsToGraph(storage, new List<string>() { sim }).ToList();
                        if (!panel.Cache.ContainsKey(sim))
                            panel.Cache.Add(sim, new Dictionary<int, List<SeriesDefinition>>());

                        panel.Cache[sim][i] = definitions;
                    }
                    tab.AddGraph(graph, panel.Cache[sim][i]);
                }

                if (processingThread.CancellationPending)
                    return;
            }

            this.graphs.Add(tab);
            view.AddTab(tab, panel.NumCols);
        }
Пример #3
0
        private void CreatePageOfGraphs(string sim, Graph[] graphs)
        {
            IStorageReader storage = GetStorage();
            GraphTab       tab     = new GraphTab(sim, this.presenter);

            for (int i = 0; i < graphs.Length; i++)
            {
                if (graphs[i].Enabled)
                {
                    // Apply transformation to graph.
                    panel.Script.TransformGraph(graphs[i], sim);

                    // Create and fill cache entry if it doesn't exist.
                    if (!panel.Cache.ContainsKey(sim) || panel.Cache[sim].Count <= i)
                    {
                        try
                        {
                            int x = storage.GetSimulationID(sim);
                        }
                        catch (KeyNotFoundException)
                        {
                            throw new Exception($"Illegal simulation name: '{sim}'. Try running the simulation, and if that doesn't fix it, there is a problem with your config script.");
                        }
                        List <SeriesDefinition> definitions = graphs[i].GetDefinitionsToGraph(storage, new List <string>()
                        {
                            sim
                        });
                        if (!panel.Cache.ContainsKey(sim))
                        {
                            panel.Cache.Add(sim, new Dictionary <int, List <SeriesDefinition> >());
                        }

                        panel.Cache[sim][i] = definitions;
                    }
                    tab.AddGraph(graphs[i], panel.Cache[sim][i]);
                }

                if (processingThread.CancellationPending)
                {
                    return;
                }
            }

            this.graphs.Add(tab);
            view.AddTab(tab, panel.NumCols);
        }