/// <summary> /// Loads a KML tree from data file to the tree view /// </summary> /// <param name="filename">The full path and filename of the data file to read</param> public void Load(string filename) { WarningsManager.BeforeTreeLoad(); TreeManager.Load(filename); VesselsManager.Load(TreeManager); KerbalsManager.Load(TreeManager); WarningsManager.AfterTreeLoad(); // Show warnings tab if there are any if (Syntax.Messages.Count > 0) { WarningsTab.Visibility = System.Windows.Visibility.Visible; Tabs.SelectedItem = WarningsTab; WarningsManager.Focus(); } else { if (Tabs.SelectedItem == WarningsTab) { Tabs.SelectedItem = TreeTab; TreeManager.Focus(); } else { IGuiManager mgr = GetActiveGuiManager(); if (mgr != null) { mgr.Focus(); } } WarningsTab.Visibility = System.Windows.Visibility.Collapsed; } }
/// <summary> /// Loads a KML tree from data file to the tree view /// </summary> /// <param name="filename">The full path and filename of the data file to read</param> public void Load(string filename) { Filename = filename; WarningsManager.BeforeTreeLoad(); TreeManager.Load(filename); VesselsManager.Load(TreeManager); KerbalsManager.Load(TreeManager); WarningsManager.AfterTreeLoad(); // Show warnings tab if there are any and its not a craft file if (!WarningsManager.IsEmpty && !FileIsCraft) { WarningsTab.Visibility = System.Windows.Visibility.Visible; Tabs.SelectedItem = WarningsTab; WarningsManager.Focus(); } else { WarningsTab.Visibility = System.Windows.Visibility.Collapsed; } // Show vessels and kerbals list if its not a craft file if (FileIsCraft) { VesselsTab.Visibility = System.Windows.Visibility.Collapsed; KerbalsTab.Visibility = System.Windows.Visibility.Collapsed; } else { VesselsTab.Visibility = System.Windows.Visibility.Visible; KerbalsTab.Visibility = System.Windows.Visibility.Visible; } if (Tabs.SelectedItem is TabItem && (Tabs.SelectedItem as TabItem).Visibility != System.Windows.Visibility.Visible) { // Switch to another tab when hidden Tabs.SelectedItem = TreeTab; TreeManager.Focus(); } IGuiManager mgr = GetActiveGuiManager(); if (mgr != null) { mgr.Focus(); } }
/// <summary> /// Selects the given item in the tree view or in the list, the item fits into. /// If called when tree is active it will switch to the list when possible. /// Otherwise when list is active it will switch to the tree view. /// </summary> /// <param name="item">The KmlItem to select</param> public void Select(KmlItem item) { if (item is KmlVessel) { if (Tabs.SelectedItem == TreeTab) { Tabs.SelectedItem = VesselsTab; VesselsManager.Select(item); } else { Tabs.SelectedItem = TreeTab; TreeManager.Select(item); } } else if (item is KmlKerbal) { if (Tabs.SelectedItem == TreeTab) { Tabs.SelectedItem = KerbalsTab; KerbalsManager.Select(item); } else { Tabs.SelectedItem = TreeTab; TreeManager.Select(item); } } //else if (item is KmlNode) //{ // KmlNode node = (KmlNode)item; // if (node != null) // { // Select(node.Parent); // } //} else { Tabs.SelectedItem = TreeTab; TreeManager.Select(item); } }
/// <summary> /// Selects the given item in the tree view or in the list, the item fits into. /// If called when tree is active it will switch to the list when possible. /// Otherwise when list is active it will switch to the tree view. /// </summary> /// <param name="item">The KmlItem to select</param> /// <returns>Whether item was found or not</returns> public bool Select(KmlItem item) { if (item is KmlVessel) { KmlVessel vessel = (KmlVessel)item; if (Tabs.SelectedItem == TreeTab && vessel.Origin == KmlVessel.VesselOrigin.Flightstate) { Tabs.SelectedItem = VesselsTab; return(VesselsManager.Select(vessel)); } else { Tabs.SelectedItem = TreeTab; return(TreeManager.Select(vessel)); } } else if (item is KmlKerbal) { KmlKerbal kerbal = (KmlKerbal)item; if (Tabs.SelectedItem == TreeTab && kerbal.Origin == KmlKerbal.KerbalOrigin.Roster) { Tabs.SelectedItem = KerbalsTab; return(KerbalsManager.Select(kerbal)); } else { Tabs.SelectedItem = TreeTab; return(TreeManager.Select(kerbal)); } } else { Tabs.SelectedItem = TreeTab; return(TreeManager.Select(item)); } }