private void KerbalSelectAssignedPart_Click(object sender, RoutedEventArgs e) { KmlKerbal kerbal = (sender as MenuItem).DataContext as KmlKerbal; if (kerbal.AssignedPart != null) { GuiTabsManager.GetCurrent().Select(kerbal.AssignedPart); } }
private void DockRepair_Click(object sender, RoutedEventArgs e) { KmlPartDock dock = (sender as MenuItem).DataContext as KmlPartDock; dock.Repair(); DlgMessage.ShowAndClear(Syntax.Messages); // Refresh view IGuiManager manager = GuiTabsManager.GetCurrent().VesselsManager; if (dock.Parent is KmlVessel && dock.Parent == manager.GetSelectedItem()) { manager.Select(dock.Parent); } }
private void Node_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e) { KmlPart part = null; if (sender is GuiTreeNode) { part = ((GuiTreeNode)sender).DataNode as KmlPart; } else if (sender is Label) { part = ((Label)sender).DataContext as KmlPart; } if (part != null) { GuiTabsManager.GetCurrent().Select(part); } }
private Image GenerateFlag(KmlVessel vessel) { Image image = new Image(); image.Source = new BitmapImage(new Uri("pack://application:,,,/KML;component/Images/DummyFlag.png")); image.Height = 40; image.Width = image.Height * 1.6; image.Margin = new Thickness(0, 0, 3, 0); if (vessel.RootPart != null && vessel.RootPart.Flag.Length > 0) { string flag = vessel.RootPart.Flag; flag = flag.Replace('/', '\\'); flag = Path.Combine(GuiTabsManager.GetCurrent().FileGamedataDirectory, flag); flag = Path.ChangeExtension(flag, ".png"); if (!File.Exists(flag)) { flag = Path.ChangeExtension(flag, ".dds"); if (!File.Exists(flag)) { // keep dummy image return(image); } else { // *.dds files are drawn vertically flipped image.RenderTransform = new ScaleTransform(1.0, -1.0, 0.0, image.Height / 2.0); } } // flag points to existing file here try { image.Source = (new ImageSourceConverter()).ConvertFromString(flag) as ImageSource; } catch { // there could be any problem loading the flag, ignore it and stay with dummy // one problem so far: Win 10 can load *.dds, Win 7 can't } } return(image); }
private void Search(bool continued = false) { const int SEARCHLIMIT = 100; List <KmlItem> list; // TODO DlgSearch.Search(): loading the list on every continuation isn't the best choice // but it's ok, because that is fast, only loading items into tree is slow list = GuiTabsManager.GetCurrent().TreeManager.Search(TextBoxInput.Text, CheckNodeTag.IsChecked == true, CheckNodeText.IsChecked == true, CheckAttribName.IsChecked == true, CheckAttribValue.IsChecked == true); _searchResults.Clear(); _searchResults.AddRange(list); int maxItemCount = SEARCHLIMIT; KmlNode parentNode = null; TreeViewItem parentItem = null; if (continued) { _searchContinued++; maxItemCount = SEARCHLIMIT * (_searchContinued + 1); parentItem = (TreeViewItem)Tree.Items[Tree.Items.Count - 1]; parentNode = list[maxItemCount - SEARCHLIMIT - 1].Parent; } else { _searchContinued = 0; Tree.Items.Clear(); } for (int i = maxItemCount - SEARCHLIMIT; i < list.Count; i++) { KmlItem item = list[i]; // if (Tree.Items.Count >= maxParentCount) if (i >= maxItemCount) { TreeViewItem dummy = new TreeViewItem(); dummy.Header = "..."; TreeViewItem toBeContinued = new TreeViewItem(); toBeContinued.Header = "... " + (list.Count - maxItemCount) + " more items ..."; toBeContinued.Expanded += ToBeContinued_Expanded; toBeContinued.Items.Add(dummy); Tree.Items.Add(toBeContinued); return; } if (item is KmlNode || item is KmlAttrib) { if (item.Parent != null && item.Parent != parentNode) { parentNode = item.Parent; parentItem = new TreeViewItem(); parentItem.Header = item.Parent.PathToString(@"\"); Tree.Items.Add(parentItem); parentItem.IsExpanded = true; } TreeViewItem node; if (item is KmlNode) { node = new GuiTreeNode((KmlNode)item, true, true, true, false, true, false); } else { node = new TreeViewItem(); node.DataContext = item; node.Header = item.ToString(); } node.Margin = new Thickness(-16, 0, 0, 0); if (parentNode == null) { Tree.Items.Add(node); } else { parentItem.Items.Add(node); } node.IsSelected = Tree.SelectedItem == null; } } }
private void SwitchView_Click(object sender, RoutedEventArgs e) { KmlItem item = (sender as MenuItem).DataContext as KmlItem; GuiTabsManager.GetCurrent().Select(item); }