/// <summary> /// Triggers the activation of the analytical algorithms container. /// </summary> public void ShowAnalyticalAlgorithms() { ContainerViewPort cv = inheritor; cv.ShowPanel(PanelToShow); cv.StatusText.text = "Showing Analytical Algorithms"; }
/// <summary> /// Function, that enables the options container and makes it visible. /// </summary> public void OpenOptions() { ContainerViewPort cv = inheritor; cv.StatusText.text = "Choose Options"; cv.ShowPanel(optionsContainer); }
/// <summary> /// Function, that enables the Link Appearence container and makes it visible. /// </summary> public void ShowLinkStyles() { ContainerViewPort cv = inheritor; cv.ShowPanel(PanelToShow); cv.StatusText.text = "Available Link Appearences"; }
/// <summary> /// Function, that enables the graph container and makes it visible. /// </summary> public void ShowGraphs() { ContainerViewPort cv = inheritor; cv.ShowPanel(PanelToShow); cv.StatusText.text = "Showing Available Graphs"; }
/// <summary> /// Creates a new gameobject, located in the parent gameobject (special case for viewport). /// </summary> /// <param name="parent"></param> /// <param name="appearence"></param> /// <remarks> /// This can be optimized in future. /// </remarks> /// <returns></returns> private GameObject NewGameObject(ContainerViewPort parent, GameObject appearence) { GameObject button = Instantiate(appearence); button.transform.SetParent(parent.transform); button.transform.localScale = new Vector3(1, 1, 1); button.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, 0)); button.transform.localPosition = new Vector3(0, 0, 0); return(button); }
/// <summary> /// Hides the buttons of analytical algorithms and shows the outcome of the executed one. /// </summary> /// <param name="instance"></param> private void ChangeButtonsForResults(AnalyticsScript instance) { instance.AddResults(instance.ToString()); ContainerViewPort cv = inheritor; cv.ShowPanel(resultPanel); cv.StatusText.text = "Showing Results of " + instance.ToString(); foreach (DictionaryEntry result in instance.Results) { GameObject textmeshKey = NewGameObject(resultPanel, textMesh); GameObject textmeshValue = NewGameObject(resultPanel, textMesh); textmeshKey.GetComponent <TextMeshProUGUI>().SetText((string)result.Key); textmeshValue.GetComponent <TextMeshProUGUI>().SetText(result.Value.ToString()); } }
/// <summary> /// Function which clears the scene. /// </summary> /// <remarks>It does so, by destroying all gameobjects which are vertices or edges (see <see cref="Vertice"/>, <see cref="Edge"/>), /// and clears all related hashtables. /// </remarks> public void ClearScene() { ContainerViewPort cv = inheritor; cv.StatusText.text = "Clearing Scene"; if (GlobalVariables.RenderedNodes.Count > 0) { bool customEdges = GlobalVariables.CustomEdge; Hashtable nodes = GlobalVariables.RenderedNodes; Hashtable links = GlobalVariables.RenderedLinks; int nodeCount = nodes.Count; int linkCount = links.Count; for (int j = 1; j <= linkCount; j++) { Hashtable graphLinks = (Hashtable)links[j]; foreach (DictionaryEntry link in graphLinks) { ((Edge)link.Value).SelfDestroy(); } } for (int k = 1; k <= nodeCount; k++) { Hashtable graphNodes = (Hashtable)nodes[k]; foreach (DictionaryEntry node in graphNodes) { ((Vertice)node.Value).SelfDestroy(); } } } GlobalVariables.Graphnodes.Clear(); GlobalVariables.Graphlinks.Clear(); GlobalVariables.RenderedNodes.Clear(); GlobalVariables.RenderedLinks.Clear(); nodeCount.text = ""; edgeCount.text = ""; }
/// <summary> /// Regular start function, enabling the usage of parsing buttons. /// </summary> /// <remarks> /// It obtains all graphnames from the respective resources folder and maps the provided parsers /// over them. For each file with a fileextension for which a parser exists, it generates a button. /// If there are more then one parser for a fileextension, the graph button opens a selection of available parsers, /// showing the description of the parser as button name. /// </remarks> void Start() { List <string> graphs = GlobalVariables.GetFullFilesFrom("Graphs", ""); Hashtable graphExtensions = new Hashtable(); List <string> extensions = new List <string>(); Hashtable instances = new Hashtable(); ContainerViewPort cv = inheritor; // Sortiere Graphen nach extensions for (int k = 0; k < graphs.Count; k++) { string extension = graphs[k].Split('.')[graphs[k].Split('.').Length - 1]; if (graphExtensions.ContainsKey(extension)) { ((List <string>)graphExtensions[extension]).Add(graphs[k]); } else { List <string> tmpGraphs = new List <string> { graphs[k] }; graphExtensions.Add(extension, tmpGraphs); } } // Ermittle Parser var type = typeof(Pipe); var types = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(s => s.GetTypes()) .Where(p => type.IsAssignableFrom(p) && p != typeof(Pipe)).ToList(); // Generiere Instanzen der Parser mit mapping auf fileextensions for (int k = 0; k < types.Count; k++) { Pipe instance = (Pipe)Activator.CreateInstance(types[k]); extensions.Add(instance.FileExtension); if (instances.ContainsKey(instance.FileExtension)) { ((List <Pipe>)instances[instance.FileExtension]).Add(instance); } else { List <Pipe> tmpPipes = new List <Pipe> { instance }; instances.Add(instance.FileExtension, tmpPipes); } } // Hole alle Graphen foreach (DictionaryEntry graphList in graphExtensions) { string currentFileextension = (string)graphList.Key; List <string> currentGraphs = (List <string>)graphList.Value; // Pro Graph, hole alle parser if (instances.ContainsKey(currentFileextension)) { foreach (string currentGraph in currentGraphs) { List <Pipe> currentParsers = (List <Pipe>)instances[currentFileextension]; GameObject graphButton = NewGameObject(ContentGraphFiles, LookOfButtons); graphButton.transform.GetChild(0).GetComponent <Text>().text = currentGraph; if (currentParsers.Count == 1) { // Wenn #parser == 1 Pipe currentParser = currentParsers[0]; graphButton.GetComponent <Button>().onClick.AddListener(() => { if (GlobalVariables.Graphnodes.Count > 0) { clearButton.ClearScene(); } cv.StatusText.text = "Graphfile " + currentGraph + " was chosen"; GlobalVariables.NewGraphLoaded = !GlobalVariables.NewGraphLoaded; currentParser.NodesAndLinksToList(currentGraph); currentParser.InsertGraph(currentParser.Nodes, currentParser.Links); }); } else if (currentParsers.Count > 1) { // Wenn #parser > 1 GameObject thisGraphsContainer = NewGameObject(inheritor, parserContainer); graphButton.GetComponent <Button>().onClick.AddListener(() => { cv.ShowPanel(thisGraphsContainer); GlobalVariables.ChosenGraph = graphButton.transform.GetChild(0).GetComponent <Text>().text; cv.StatusText.text = "Graphfile " + GlobalVariables.ChosenGraph + " was chosen"; }); foreach (Pipe currentParser in currentParsers) { GameObject chooseParserButton = NewGameObject(thisGraphsContainer, LookOfButtons); chooseParserButton.transform.GetChild(0).GetComponent <Text>().text = currentParser.Description; chooseParserButton.GetComponent <Button>().onClick.AddListener(() => { if (GlobalVariables.Graphnodes.Count > 0) { clearButton.ClearScene(); } GlobalVariables.NewGraphLoaded = !GlobalVariables.NewGraphLoaded; currentParser.NodesAndLinksToList(GlobalVariables.ChosenGraph); currentParser.InsertGraph(currentParser.Nodes, currentParser.Links); }); } } } } } }