public void Execute(object parameter) { var graph = this.logItemVetice.graph; //var g = Guid.NewGuid(); //string name = g.ToString().Substring(0, 10); var p = new LogItemVetice(graph); graph.AddVertexNoRedraw(p); graph.AddEdge(new Edge <IVertice>(this.logItemVetice, p, new Arrow(), new Arrow())); }
public void CreatePerson() { if (this.PersonNames.Any(x => x == this.NewPersonName)) { // such a person already exists: there should be some validation message, but // it is not so important in a demo return; } var p = new LogItemVetice(this.Graph); this.Graph.AddVertex(p); }
private void TestSubGraph(Graph <IVertice> graph) { var g = new LogItemVetice(graph); var h = new LogItemVetice(graph); var subGraph = new SubGraph <IVertice> { Label = "Work" }; graph.AddSubGraph(subGraph); subGraph.AddVertex(g); subGraph.AddVertex(h); this.Graph = graph; this.Graph.Changed += GraphChanged; }
void NewWay() { var graph = new Graph <IVertice>(); var allItems = ReadDatabase.Instance.FindAll(); var groupedByClass = allItems.GroupBy( x => new { x.ClassName, x.Name }, (key, group) => { var @class = new AnonymousClass(); @class.ClassName = key.ClassName; @class.Name = key.Name; @class.Items = @group.ToList(); return(@class); }); HashSet <ClassRelationship> classRelSet = new HashSet <ClassRelationship>(); Random rnd = new Random(); foreach (var item in groupedByClass) { var verticeName = item.ClassName + ":" + item.Name; var color = Color.FromArgb((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255)); SolidColorBrush solid = new SolidColorBrush(color); var el = new LogItemVetice(graph) { ClassName = item.ClassName, MethodName = item.Name, ItemColor = solid }; graph.AddVertex(el); foreach (var logItem in item.Items) { var classRel = new ClassRelationship(logItem); if (!classRelSet.Contains(classRel)) { } else { } } } this.Graph = graph; this.Graph.Changed += GraphChanged; }
private void OnReceiveMsg(object sender, MessageType message) { lock (this) { if (message is MsgNewVertex) { var msg = message as MsgNewVertex; if (_dictVertex.Keys.Contains(msg.Name)) { //TODO better management throw new Exception("Vertex already exists"); } else { var item = new LogItemVetice(Graph) { ClassName = msg.Name }; Graph.AddVertex(item); _dictVertex.Add(msg.Name, item); this.RaisePropertyChanged("Graph"); } } else if (message is MsgNewEdge) { var msg = message as MsgNewEdge; if (_dictVertex.Keys.Contains(msg.Source) && _dictVertex.Keys.Contains(msg.Destination)) { var source = _dictVertex.GetValue(msg.Source); var dest = _dictVertex.GetValue(msg.Destination); //Graph.AddEdge(new Edge<IVertice>()) Graph.AddEdge(new Edge <IVertice>(source, dest, new Arrow())); } else { //TODO better throw new Exception("Missing source or destination"); } } } }
void OldWay() { var graph = new Graph <IVertice>(); var allItems = ReadDatabase.Instance.FindAll().Select(x => new { x.Name, x.ClassName, x.ParentClass, x.ParentMethod }).Distinct(); var count = allItems.Count(); var uniqueItems = allItems.Select(e => new { Name = e.Name, ClassName = e.ClassName }).Distinct(); var uniqueItems2 = allItems.Select(e => new { Name = e.ParentMethod, ClassName = e.ParentClass }).Distinct(); var union1 = uniqueItems.Concat(uniqueItems2).Distinct(); var listClassNames = union1.Select(x => x.ClassName).Distinct(); List <SubGraphItem> subGraphItems = new List <SubGraphItem>(); Random rnd = new Random(); foreach (var className in listClassNames) { var subGraph = new SubGraph <IVertice> { Label = className }; var color = Color.FromArgb((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255)); subGraphItems.Add(new SubGraphItem { ClassName = className, _subGraph = subGraph, _color = color }); } List <VertexItem> vItems = new List <VertexItem>(); foreach (var item in union1) { var verticeName = item.ClassName + ":" + item.Name; var color = subGraphItems.First(x => x.ClassName.Equals(item.ClassName))._color; SolidColorBrush solid = new SolidColorBrush(color); var el = new LogItemVetice(graph) { ClassName = item.ClassName, MethodName = item.Name, ItemColor = solid }; var vi = new VertexItem { ClassName = item.ClassName, MethodName = item.Name, p = el }; vItems.Add(vi); graph.AddVertex(el); } var intersect1 = (from a in vItems join b in allItems on new { a.ClassName, a.MethodName } equals new { b.ClassName, MethodName = b.Name } into gp select new { a.ClassName, a.MethodName, a.p, gp }); foreach (var item in intersect1) { foreach (var element in item.gp) { var parent = vItems.First(x => x.ClassName == element.ParentClass && x.MethodName == element.ParentMethod); graph.AddEdge(new Edge <IVertice>(parent.p, item.p, new Arrow())); } } //foreach (var item in vItems) //{ // try // { // var children = allItems.Where(x => x.ParentClass.Equals(item.ClassName) && x.ParentMethod.Equals(item.MethodName)).Select(x => new { MethodName = x.Name, ClassName = x.ClassName } ).Distinct(); // var intersect = (from a in children // join b in vItems // on new { a.ClassName, a.MethodName } equals new { b.ClassName, b.MethodName } // select new { a.ClassName, a.MethodName, b.p }); // foreach (var element in intersect) // { // graph.AddEdge(new Edge<IVertice>(item.p, element.p, new Arrow())); // } // } // catch (Exception e) // { // System.Diagnostics.Debug.Write("bug"); // } //} //foreach (var item in union1) //{ // try // { // var verticeName = item.ClassName + ":" + item.Name; // var src = vItems.First(x => x.VerticeName.Equals(verticeName)); // var dest = allItems.First(x => x.ClassName.Equals(item.ClassName) && x.Name.Equals(item.Name)); // var destVersticeName = dest.ParentClass + ":" + dest.ParentMethod; // var dest2 = vItems.First(x => x.VerticeName.Equals(destVersticeName)); // graph.AddEdge(new Edge<IVertice>(dest2.p, src.p, new Arrow())); // } // catch (Exception e) // { // System.Diagnostics.Debug.Write("bug"); // } //} this.Graph = graph; this.Graph.Changed += GraphChanged; this.NewPersonName = "Enter new name"; this.UpdatePersonNewName = "Enter new name"; }
public AddCommandImpl(LogItemVetice logItemVetice) { this.logItemVetice = logItemVetice; }
public RemoveCommandImpl(LogItemVetice logItemVetice) { this.logItemVetice = logItemVetice; }