public static void SelectGameElement(GameElement gameElement) { if (_gameElementsPaths.ContainsKey(gameElement)) { var path = _treeStore.GetPath(_gameElementsPaths[gameElement]); _treeView.ActivateRow(path, _treeView.Columns[0]); } }
/// <summary> /// Restores the TreePaths (expanded rows) from a file /// </summary> /// private void LoadSelectedAssembliesTreePaths() { string filepath = Path.Combine(reflector.GetConfigurationDirectory(), "SolidReflector.session"); string[] lines = null; if (File.Exists(filepath)) { lines = File.ReadAllLines(filepath); for (int i = 0; i < lines.Length; i++) { expandPath(lines[i]); } assemblyTree.SetCursor(new Gtk.TreePath(lines[lines.Length - 1]), assemblyTree.GetColumn(0), true); assemblyTree.ActivateRow(new Gtk.TreePath(lines[lines.Length - 1]), assemblyTree.GetColumn(0)); } }
/// <summary> /// Activate a row in the TreeView. Would be good to find a better way of doing this. /// </summary> /// <param name="tree">An instance of UserInterface.Views.TreeView.</param> /// <param name="path">Path to the row. e.g. ".Simulations.ContinuousWheat.Paddock".</param> private void ActivateNode(TreeView tree, string path) { tree.SelectedNode = path; Gtk.TreeView treeView = (Gtk.TreeView)ReflectionUtilities.GetValueOfFieldOrProperty("treeview1", tree); Gtk.TreePath treePath = GetTreePath(tree, path); treeView.ActivateRow(treePath, treeView.Columns[0]); GtkUtilities.WaitForGtkEvents(); }