internal CtagsVertex AddCtagsAnchor(string tag, PocVertex source_vertex) { CtagsVertex new_vertex = new CtagsVertex(tag); Graph.AddVertex(new_vertex); Graph.AddEdge(new PocEdge(source_vertex, new_vertex)); return(new_vertex); }
private PocEdge AddNewGraphEdge(PocVertex from, PocVertex to) { string edgeString = string.Format("{0}-{1} Connected", from.ID, to.ID); PocEdge newEdge = new PocEdge(edgeString, from, to); Graph.AddEdge(newEdge); return(newEdge); }
internal SearchResultsVertex PerformSearch(string search_string, PocVertex source_vertex, List <string> extensions_to_search) { SearchResultsVertex search_result = new SearchResultsVertex(search_string); search_result.Results = new List <SearchResult>(); search_result.ExtensionsToSearch = extensions_to_search; Graph.AddVertex(search_result); Graph.AddEdge(new PocEdge(source_vertex, search_result)); return(search_result); }
partial void CreateSampleGraphs() { var graph = new PocGraph(); var from = new PocVertex("Force", 32); graph.AddVertex(from); Add(graph, from, TestTagViewModel.Create(), 0, 16); GraphModels.Add(new GraphModel("Fa", graph)); SelectedGraphModel = GraphModels.First(); }
private void CloseVertex(PocVertex vertex_to_remove) { if (graph_area.Graph.OutEdges(vertex_to_remove).Count() > 0) { var edges = graph_area.Graph.OutEdges(vertex_to_remove).ToList(); foreach (PocEdge edge in edges) { CloseVertex(edge.Target); RemoveEdge(edge); } } graph_area.Graph.RemoveVertex(vertex_to_remove); graph_area.RemoveVertex(vertex_to_remove); }
partial void CreateSampleGraphs() { #region SimpleTree int i = 0; { var graph = new PocGraph(); for (int j = 0; j < 11; i++, j++) { var v = new PocVertex(i.ToString()); graph.AddVertex(v); v.Desc = "test" + i.ToString(); } graph.AddEdge(new PocEdge("StartToImporter", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(1))); graph.AddEdge(new PocEdge("ImporterToTarget", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(2))); graph.AddEdge(new PocEdge("ImporterToSource", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(3))); // Target Side graph.AddEdge(new PocEdge("TargetCleanupToStopword", graph.Vertices.ElementAt(2), graph.Vertices.ElementAt(4))); graph.AddEdge(new PocEdge("TargetStopwordToStemmer", graph.Vertices.ElementAt(4), graph.Vertices.ElementAt(6))); graph.AddEdge(new PocEdge("TargetStemmerToDictionary", graph.Vertices.ElementAt(6), graph.Vertices.ElementAt(8))); graph.AddEdge(new PocEdge("TargetDictionaryToTracer", graph.Vertices.ElementAt(8), graph.Vertices.ElementAt(9))); // Source side graph.AddEdge(new PocEdge("SourceCleanupToStopword", graph.Vertices.ElementAt(3), graph.Vertices.ElementAt(5))); graph.AddEdge(new PocEdge("SourceStopwordToStemmer", graph.Vertices.ElementAt(5), graph.Vertices.ElementAt(7))); graph.AddEdge(new PocEdge("SourceStemmerToTracer", graph.Vertices.ElementAt(7), graph.Vertices.ElementAt(9))); graph.AddEdge(new PocEdge("DecisionToImporter", graph.Vertices.ElementAt(9), graph.Vertices.ElementAt(1))); graph.AddEdge(new PocEdge("DecisionToEnd", graph.Vertices.ElementAt(9), graph.Vertices.ElementAt(10))); GraphModels.Add(new GraphModel("Fa", graph)); } { var graph = new PocGraph(); for (int j = 0; j < 2; i++, j++) { var v = new PocVertex(i.ToString()); graph.AddVertex(v); v.Desc = "test" + i.ToString(); } graph.AddEdge(new PocEdge("StartToImporter", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(1))); GraphModels.Add(new GraphModel("Fb", graph)); } #endregion }
async private void SearchString(object sender, ExecutedRoutedEventArgs e) { // TODO - this needs sorting out. At the moment we're hacking up a solution // where we test for whether they've selected some text in the box, or // entered something in the root node. string selected_text = ""; List <string> extensions = new List <string>(); TextArea textarea = e.OriginalSource as TextArea; PocVertex source_vertex = (PocVertex)((VertexControl)e.Source).Vertex; if (textarea == null) { VertexControl source_vertex_control = e.Source as VertexControl; if (source_vertex_control == null) { return; } selected_text = ((FileBrowser)source_vertex_control.DataContext).SearchTerm; //System.Windows.Controls.TextBox textbox = Utils.TreeHelpers.FindVisualChildren<System.Windows.Controls.TextBox>(source_vertex_control).Last(); //System.Windows.Controls.TextBox textbox = Utils.TreeHelpers.FindVisualChildByName<System.Windows.Controls.TextBox>(typeof(MainWindow), extensionList); extensions = extensionList.Text.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList(); extensions.ForEach(extension => extension.ToLower()); } else { selected_text = textarea.Selection.GetText(); string parameter = e.Parameter as string; if (parameter == "same_type") // Should use an enum or similar { extensions.Add(Path.GetExtension(((FileVertex)source_vertex).FilePath)); } else if (parameter == "restricted") { System.Windows.Controls.TextBox textbox = Utils.TreeHelpers.FindVisualChildren <System.Windows.Controls.TextBox>(root_control).LastOrDefault(); if (textbox != null) { extensions = textbox.Text.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries).ToList(); extensions.ForEach(extension => extension.ToLower()); } } } await SearchForString(selected_text, (VertexControl)e.Source, extensions); graph_provider.SaveGraph(); }
internal FileVertex AddFileView(FileItem f, PocVertex from_vertex) { FileVertex new_vertex; FileVertex existing_file_view = (FileVertex)Graph.Vertices.Where(x => x as FileVertex != null && ((FileVertex)x).FileName == f.RelPath).FirstOrDefault(); if (existing_file_view != null) { new_vertex = new FileVertex(f.FileName, f.FullPath, root_vertex.FilePath, existing_file_view.Document); } else { new_vertex = new FileVertex(f.FileName, f.FullPath, root_vertex.FilePath); } Graph.AddVertex(new_vertex); Graph.AddEdge(new PocEdge(from_vertex, new_vertex)); return(new_vertex); }
private VertexControl AddCtagsAnchor(String tag, VertexControl source, PocVertex source_vertex) { CtagsVertex new_vertex = graph_provider.AddCtagsAnchor(tag, source_vertex); VertexControl new_vertex_control = new VertexControl(new_vertex) { DataContext = new_vertex }; graph_area.AddVertex(new_vertex, new_vertex_control); PocEdge new_edge = new PocEdge(source_vertex, new_vertex); graph_area.InsertEdge(new_edge, new EdgeControl(source, new_vertex_control, new_edge)); graph_area.RelayoutGraph(true); graph_area.UpdateLayout(); centre_on_me = new_vertex_control; return(new_vertex_control); }
async private void TestEditor_KeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == System.Windows.Input.Key.S && !((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)) // Not doing ctrl-s to save { string selected_text = ""; TextArea textarea = e.OriginalSource as TextArea; VertexControl sv = TreeHelpers.FindVisualParent <VertexControl>(textarea); PocVertex source_vertex = (PocVertex)sv.Vertex; selected_text = textarea.Selection.GetText(); await SearchForString(selected_text, sv); } else if (e.Key == System.Windows.Input.Key.N && !((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)) // Not doing ctrl-n for new project { string selected_text = ""; string link_text = ""; TextArea textarea = e.OriginalSource as TextArea; var texteditor = Utils.TreeHelpers.FindVisualParent <TextEditor>(textarea); VertexControl sv = TreeHelpers.FindVisualParent <VertexControl>(textarea); FileVertex source_vertex = (FileVertex)sv.Vertex; selected_text = textarea.Selection.GetText(); var no_lines = 0; var start_line = ""; if (textarea.Selection.EndPosition.Line < textarea.Selection.StartPosition.Line) { no_lines = textarea.Selection.StartPosition.Line - textarea.Selection.EndPosition.Line + 1; start_line = textarea.Selection.EndPosition.Location.ToString(); } else { no_lines = textarea.Selection.EndPosition.Line - textarea.Selection.StartPosition.Line + 1; start_line = textarea.Selection.StartPosition.Location.ToString(); } link_text = source_vertex.ID.ToString() + ":" + source_vertex.FileName + ":" + start_line + ":" + no_lines.ToString(); NotesEditor.TextArea.Document.Text += "\n\n"; NotesEditor.TextArea.Document.Text += link_text + "\n"; NotesEditor.TextArea.Document.Text += selected_text; NotesEditor.TextArea.Document.Text += "\n\n"; NotesEditor.ScrollToEnd(); graph_provider.SaveNotes(); } }
private void AddFileView(FileItem file_item, VertexControl source, PocVertex source_vertex, List <int> lines = null) { if (!graph_provider.root_vertex.CtagsRun) { System.Windows.Forms.MessageBox.Show("Ctags is still running, so tags are not available.", "Ctags running", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } FileVertex new_vertex = graph_provider.AddFileView(file_item, source_vertex); VertexControl new_vertex_control = new VertexControl(new_vertex) { DataContext = new_vertex }; try { graph_area.AddVertex(new_vertex, new_vertex_control); } catch (GraphX.GX_InvalidDataException) { new_vertex_control = graph_area.GetAllVertexControls().Where(c => c.Vertex == new_vertex).First(); } PocEdge new_edge = new PocEdge(source_vertex, new_vertex); graph_area.InsertEdge(new_edge, new EdgeControl(source, new_vertex_control, new_edge)); graph_area.RelayoutGraph(true); graph_area.UpdateLayout(); centre_on_me = new_vertex_control; ICSharpCode.AvalonEdit.TextEditor editor = TreeHelpers.FindVisualChild <ICSharpCode.AvalonEdit.TextEditor>(new_vertex_control); if (editor != null && editor != NotesEditor) { editor.TextArea.TextView.MouseDown += TestEditor_MouseDown; editor.TextArea.SelectionChanged += TestEditor_SelectionChanged; if (graph_provider.root_vertex.CtagsRun) { editor.TextArea.TextView.LineTransformers.Add(new UnderlineCtagsMatches(graph_provider.root_vertex.CtagsMatches.Keys.ToList())); } if (lines != null) { editor.TextArea.TextView.BackgroundRenderers.Add(new HighlightSearchLineBackgroundRenderer(editor, lines)); editor.ScrollToLine(lines.Min()); } editor.Width = editor.ActualWidth; } }
private void Add(PocGraph graph, PocVertex from, TestTagViewModelCollection tags, int level, int fontsize) { if (tags == null) { return; } if (level > 2) { return; } foreach (TestTagViewModel model in tags) { var to = new PocVertex(model.Text, fontsize); graph.AddVertex(to); graph.AddEdge(new PocEdge(Guid.NewGuid().ToString(), from, to)); Add(graph, to, model.Tags, level + 1, fontsize / 2); } }
partial void CreateSampleGraphs() { var graph = new PocGraph(); for (int i = 0; i < 8; i++) { var v = new PocVertex(i.ToString(CultureInfo.InvariantCulture)); graph.AddVertex(v); } graph.AddEdge(new PocEdge("0to1", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(1))); graph.AddEdge(new PocEdge("1to2", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(2))); graph.AddEdge(new PocEdge("2to3", graph.Vertices.ElementAt(2), graph.Vertices.ElementAt(3))); graph.AddEdge(new PocEdge("2to4", graph.Vertices.ElementAt(2), graph.Vertices.ElementAt(4))); graph.AddEdge(new PocEdge("0to5", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(5))); graph.AddEdge(new PocEdge("1to7", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(7))); graph.AddEdge(new PocEdge("4to6", graph.Vertices.ElementAt(4), graph.Vertices.ElementAt(6))); GraphModels.Add(new GraphModel("Fa", graph)); SelectedGraphModel = GraphModels.First(); }
private Task SearchForString(string selected_text, VertexControl from_vertex_control, List <string> extensions_to_search = null) { if (selected_text != null && selected_text != "") { PocVertex from_vertex = (PocVertex)from_vertex_control.Vertex; SearchResultsVertex new_search_results_vertex = graph_provider.PerformSearch(selected_text, from_vertex, extensions_to_search); VertexControl new_search_results_vertex_control = new VertexControl(new_search_results_vertex) { DataContext = new_search_results_vertex }; graph_area.AddVertex(new_search_results_vertex, new_search_results_vertex_control); PocEdge new_edge = new PocEdge((PocVertex)from_vertex_control.Vertex, new_search_results_vertex); graph_area.InsertEdge(new_edge, new EdgeControl(from_vertex_control, new_search_results_vertex_control, new_edge)); graph_area.RelayoutGraph(true); graph_area.UpdateLayout(); centre_on_me = new_search_results_vertex_control; System.Windows.Controls.DataGrid grid = TreeHelpers.FindVisualChild <System.Windows.Controls.DataGrid>(new_search_results_vertex_control); System.Windows.Controls.ProgressBar bar = TreeHelpers.FindVisualChild <System.Windows.Controls.ProgressBar>(new_search_results_vertex_control); if (still_counting) { bar.Maximum = 100; } else { bar.Maximum = directory_count; } var search_progress = new Progress <int>((int some_int) => ReportProgress(bar)); return(graph_provider.PopulateResultsAsync(selected_text, new_search_results_vertex, search_progress)); //bar.Visibility = System.Windows.Visibility.Collapsed; //grid.Visibility = System.Windows.Visibility.Visible; } return(new Task(() => { })); }
private void OnCloseVertex(object sender, RoutedEventArgs e) { VertexControl vertex_control_to_close = e.Source as VertexControl; PocVertex v = vertex_control_to_close.DataContext as PocVertex; PocEdge in_edge = graph_area.Graph.InEdge(v, 0); // Will only ever have one in edge if (graph_area.Graph.OutEdges(v).Count() > 0) { System.Windows.Forms.DialogResult d = System.Windows.Forms.MessageBox.Show("Vertex has child nodes. All nodes on this branch will be deleted. Continue?", "Delete Child Nodes?", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question); if (d == System.Windows.Forms.DialogResult.No) { return; } } CloseVertex(v); RemoveEdge(in_edge); graph_area.RelayoutGraph(true); graph_area.UpdateLayout(); graph_provider.SaveGraph(); recentre = true; centre_on_me = graph_area.VertexList.Where(x => x.Key == in_edge.Source).First().Value; }
partial void CreateSampleGraphs() { #region SimpleTree var graph = new PocGraph(); for (int i = 0; i < 8; i++) { var v = new PocVertex(i.ToString()); graph.AddVertex(v); } graph.AddEdge(new PocEdge("0to1", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(1))); graph.AddEdge(new PocEdge("1to2", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(2))); graph.AddEdge(new PocEdge("2to3", graph.Vertices.ElementAt(2), graph.Vertices.ElementAt(3))); graph.AddEdge(new PocEdge("2to4", graph.Vertices.ElementAt(2), graph.Vertices.ElementAt(4))); graph.AddEdge(new PocEdge("0to5", graph.Vertices.ElementAt(0), graph.Vertices.ElementAt(5))); graph.AddEdge(new PocEdge("1to7", graph.Vertices.ElementAt(1), graph.Vertices.ElementAt(7))); graph.AddEdge(new PocEdge("4to6", graph.Vertices.ElementAt(4), graph.Vertices.ElementAt(6))); GraphModels.Add(new GraphModel("Fa", graph)); #endregion }
public void LoadProject(string filename) { using (Package package = Package.Open(filename, FileMode.OpenOrCreate)) { Properties.Settings.Default.PreviousFile = filename; XmlSerializer vertex_loader = new XmlSerializer(typeof(PocVertex)); graph = new PocGraph(true); foreach (var p in package.GetParts()) { if (p.ContentType == "text/xml" && p.Uri.OriginalString.StartsWith("/vertices") && !p.Uri.OriginalString.EndsWith(".rels") ) { PocVertex new_vertex = (PocVertex)vertex_loader.Deserialize(p.GetStream(FileMode.Open)); graph.AddVertex(new_vertex); } } foreach (var p in package.GetParts()) { if (p.ContentType == "text/xml" && p.Uri.OriginalString.StartsWith("/vertices") && !p.Uri.OriginalString.EndsWith(".rels") ) { PocVertex new_vertex = (PocVertex)vertex_loader.Deserialize(p.GetStream(FileMode.Open)); PocVertex source = graph.Vertices.Where(x => x.ID == new_vertex.ID).First(); var edges = p.GetRelationshipsByType(EdgeRelationship); foreach (var edge in edges) { new_vertex = (PocVertex)vertex_loader.Deserialize(package.GetPart(edge.TargetUri).GetStream(FileMode.Open)); PocVertex target = graph.Vertices.Where(x => x.ID == new_vertex.ID).First(); PocEdge new_edge = new PocEdge(source, target); if (!(source == target)) { graph.AddEdge(new_edge); } } } else if (p.Uri.OriginalString == "/notes/notes.txt") { using (var sr = new StreamReader(p.GetStream())) { graph.Notes.Text = sr.ReadToEnd(); } } } root_vertex = (FileBrowser)graph.Vertices.Where(x => (x as FileBrowser) != null).First(); item_provider.RootDir = root_vertex.FilePath; root_dir = root_vertex.FilePath; } UsingTempFile = false; SaveFile = filename; NotifyPropertyChanged("Graph"); }
internal PocVertex GetVertexById(int id) { PocVertex result = graph.Vertices.Where(x => x.ID == id).First(); return(result); }
static PocEdge EdgeFactory(PocVertex source, PocVertex target) { return(new PocEdge($"{source.ID}to{target.ID}", source, target)); }
private VertexControl AddCtagsAnchor(String tag, VertexControl source, PocVertex source_vertex) { CtagsVertex new_vertex = graph_provider.AddCtagsAnchor(tag, source_vertex); VertexControl new_vertex_control = new VertexControl(new_vertex) { DataContext = new_vertex }; graph_area.AddVertex(new_vertex, new_vertex_control); PocEdge new_edge = new PocEdge(source_vertex, new_vertex); graph_area.InsertEdge(new_edge, new EdgeControl(source, new_vertex_control, new_edge)); graph_area.RelayoutGraph(true); graph_area.UpdateLayout(); centre_on_me = new_vertex_control; return new_vertex_control; }
private void AddFileView(FileItem file_item, VertexControl source, PocVertex source_vertex, int line) { AddFileView(file_item, source, source_vertex, new List <int> { line }); }
private void AddFileView(FileItem file_item, VertexControl source, PocVertex source_vertex, int line) { AddFileView(file_item, source, source_vertex, new List<int> { line }); }
private void AddFileView(FileItem file_item, VertexControl source, PocVertex source_vertex, List<int> lines = null) { if (!graph_provider.root_vertex.CtagsRun) { System.Windows.Forms.MessageBox.Show("Ctags is still running, so tags are not available.", "Ctags running", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } FileVertex new_vertex = graph_provider.AddFileView(file_item, source_vertex); VertexControl new_vertex_control = new VertexControl(new_vertex) { DataContext = new_vertex }; try { graph_area.AddVertex(new_vertex, new_vertex_control); } catch (GraphX.GX_InvalidDataException) { new_vertex_control = graph_area.GetAllVertexControls().Where(c => c.Vertex == new_vertex).First(); } PocEdge new_edge = new PocEdge(source_vertex, new_vertex); graph_area.InsertEdge(new_edge, new EdgeControl(source, new_vertex_control, new_edge)); graph_area.RelayoutGraph(true); graph_area.UpdateLayout(); centre_on_me = new_vertex_control; ICSharpCode.AvalonEdit.TextEditor editor = TreeHelpers.FindVisualChild<ICSharpCode.AvalonEdit.TextEditor>(new_vertex_control); if (editor != null && editor != NotesEditor) { editor.TextArea.TextView.MouseDown += TestEditor_MouseDown; editor.TextArea.SelectionChanged += TestEditor_SelectionChanged; if (graph_provider.root_vertex.CtagsRun) editor.TextArea.TextView.LineTransformers.Add(new UnderlineCtagsMatches(graph_provider.root_vertex.CtagsMatches.Keys.ToList())); if (lines != null) { editor.TextArea.TextView.BackgroundRenderers.Add(new HighlightSearchLineBackgroundRenderer(editor, lines)); editor.ScrollToLine(lines.Min()); } editor.Width = editor.ActualWidth; } }