public void FindAndSelectNodeByCodeLocation(string text) { var docUrl = text.Split('|')[0]; StringBuilder b = new StringBuilder(); b.Append(char.ToLower(docUrl[0])); b.Append(docUrl.Skip(1).ToArray()); docUrl = b.ToString().ToLower(); var lineNumberStart = text.Split('|')[1]; var lineNumberBottom = text.Split('|')[2]; List <KeyValuePair <string, string> > foundedNodes = new List <KeyValuePair <string, string> >(); Dispatcher.Invoke((Action) delegate { for (int i = Int32.Parse(lineNumberStart); i <= Int32.Parse(lineNumberBottom); i++) { foundedNodes.Add(tipContents.Where(t => t.Value.ToLower().Contains(docUrl + ":" + i.ToString())).FirstOrDefault()); } if (foundedNodes.Count > 0) { MyDotViewer.ClearBitmpOnAllNode(); foreach (var node in foundedNodes) { MyDotViewer.SetGlowOnNodeByTag(node.Key, Colors.Coral); } } else { MessageBox.Show("Node not found. " + docUrl + ":" + lineNumberStart + "-" + lineNumberBottom); } }); }
private void PrintExecuted(object sender, ExecutedRoutedEventArgs e) { PrintDialog pd = new PrintDialog(); if (pd.ShowDialog() == true) { MyDotViewer.Print(pd); } }
private void lbRuns_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var number = (int)((ListBox)sender).SelectedItem.GetType().GetProperty("Number").GetValue(((ListBox)sender).SelectedItem, null); var testgenerated = (bool)((ListBox)sender).SelectedItem.GetType().GetProperty("TestGenerated").GetValue(((ListBox)sender).SelectedItem, null); var run = pexRuns.Where(r => r.Number == number).FirstOrDefault(); MyDotViewer.ClearBitmpOnAllNode(); selectedNodes.Clear(); foreach (var node in run.Path) { selectedNodes.Add(node.ToString()); MyDotViewer.SetGlowOnNodeByTag(node.ToString(), Colors.DarkOrange); } }
/// <summary> /// Constructing the main window. /// </summary> public MainWindow() { InitializeComponent(); DataContext = this; Uri uri = new Uri(@"pack://application:,,,/Resources/SEViz.png"); Icon = BitmapFrame.Create(uri); CommandBindings.Add(new CommandBinding(ApplicationCommands.Open, OpenExecuted)); InputBindings.Add(new InputBinding(ApplicationCommands.Open, new KeyGesture(Key.O, ModifierKeys.Control))); InputBindings.Add(new InputBinding(ApplicationCommands.Open, new KeyGesture(Key.L, ModifierKeys.Control))); CommandBindings.Add(new CommandBinding(ApplicationCommands.Print, PrintExecuted)); InputBindings.Add(new InputBinding(ApplicationCommands.Print, new KeyGesture(Key.P, ModifierKeys.Control))); Loaded += new RoutedEventHandler(MainWindow_Loaded); MyDotViewer.ShowNodeTip += MyDotViewer_ShowToolTip; this.Closed += new EventHandler(MainWindow_Closed); Pipeserver.invoker = this; ThreadStart pipeThread = new ThreadStart(Pipeserver.createPipeServer); Thread listenerThread = new Thread(pipeThread); listenerThread.SetApartmentState(ApartmentState.STA); listenerThread.IsBackground = true; listenerThread.Start(); this.selectedNodes = MyDotViewer.selectedNodes; pexRuns = new List <PexRun>(); VSConnected = null; MyDotViewer.MouseDoubleClickOnGraphElement += (p1, p2) => { if (tabiDetails.Visibility == System.Windows.Visibility.Collapsed) { tabiDetails.Visibility = System.Windows.Visibility.Visible; } var run = pexRuns.Where(r => r.Path.Last() == Int32.Parse(p2.Node)).FirstOrDefault(); if (run != null) { MyDotViewer.ClearBitmpOnAllNode(); foreach (var r in run.Path) { MyDotViewer.SetGlowOnNodeByTag(r.ToString(), Colors.DarkOrange); } MyDotViewer.SetGlowOnNodeByTag(p2.Node, Colors.MediumPurple); } if (selectedNodes.Count > 0) { var pathConditions = tipContents[selectedNodes[0]].Replace(";lt;", "<").Replace(";gt;", ">").Replace("<", "<").Replace(">", ">").Replace("&", "&").Replace("&& ", Environment.NewLine).Split(new string[] { "<LineBreak />" }, StringSplitOptions.None); var pathCondition = pathConditions[0].Remove(0, 106); tbLiterals.Text = pathCondition.Remove(pathCondition.Length - 7, 7); tbNodeNum.Text = "NODE " + selectedNodes[0]; tbMethod.Text = tbttMethod.Text = pathConditions[1]; tbSource.Text = tbttSource.Text = pathConditions[2].Remove(pathConditions[2].Length - 15, 15); tbExhaustedReason.Text = exhaustedReasons[Int32.Parse(selectedNodes[0])]; var lastRun = pexRuns.Where(r => r.Path.Last().ToString() == selectedNodes[0]).FirstOrDefault(); tbMethodCode.Text = "No test was generated here."; if (lastRun != null) { if (tests.ContainsKey(lastRun.Number)) { tbMethodCode.Text = tests[lastRun.Number]; } } } }; }