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);
        }
Ejemplo n.º 2
0
 private void RemoveEdge(PocEdge edge)
 {
     graph_area.Graph.RemoveEdge(edge);
     //tg_Area.Graph.RemoveEdge(e); // TODO - get this working.
     foreach (PocEdge f in graph_area.EdgesList.Keys.ToList())
     {
         if (edge.Target == f.Target && edge.Source == f.Source)
         {
             graph_area.RemoveEdge(f);
         }
     }
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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;
            }
        }
Ejemplo n.º 5
0
        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(() => { }));
        }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
        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;
        }
Ejemplo n.º 8
0
 private void RemoveEdge(PocEdge edge)
 {
     graph_area.Graph.RemoveEdge(edge);
     //tg_Area.Graph.RemoveEdge(e); // TODO - get this working.
     foreach (PocEdge f in graph_area.EdgesList.Keys.ToList())
     {
         if (edge.Target == f.Target && edge.Source == f.Source)
         {
             graph_area.RemoveEdge(f);
         }
     }
 }
Ejemplo n.º 9
0
        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(() => { });
        }
Ejemplo n.º 10
0
        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;
            }
        }
Ejemplo n.º 11
0
        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;
        }
Ejemplo n.º 12
0
        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");
        }