private void zoomctrl_PreviewDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(typeof(object))) { //how to get dragged data by its type var myobject = e.Data.GetData(typeof(object)) as object; var pos = zoomctrl.TranslatePoint(e.GetPosition(zoomctrl), Area); var data = DataVertex.Create(); CreateVertex(Area, zoomctrl, data, pos.X, pos.Y); } }
public CreateVertexOperation(GraphArea graph, DataVertex data = null, double x = double.MinValue, double y = double.MinValue, Action <DataVertex, VertexControl> callback = null, Action <DataVertex> undoCallback = null) : base(graph, data, callback, undoCallback) { _vCtrl = new VertexControl(_vertex); if (x != double.MinValue) { _x = x; } if (y != double.MinValue) { _y = y; } }
public VertexOperation(GraphArea graph, DataVertex data = null, Action <DataVertex, VertexControl> callback = null, Action <DataVertex> undoCallback = null) { _graph = graph; _callback = callback; _undoCallback = undoCallback; if (data != null) { _vertex = data; } else { _vertex = DataVertex.Create(); } Status = Orc.GraphExplorer.Status.Init; }
private void UpdateEdgeRef(int fromId, int toId, out DataVertex from, out DataVertex to) { from = null; to = null; if (!vCache.TryGetValue(fromId, out from)) { from = new DataVertex(fromId); vCache.Add(fromId, from); } if (!vCache.TryGetValue(toId, out to)) { to = new DataVertex(toId); vCache.Add(toId, to); } }
void ClearEdgeDrawing() { if (_edFakeDV != null) { Area.Graph.RemoveVertex(_edFakeDV); } if (_edEdge != null) { var edge = _edEdge.Edge as DataEdge; Area.Graph.RemoveEdge(edge); Area.RemoveEdge(edge); } _edGeo = null; _edFakeDV = null; _edVertex = null; _edEdge = null; }
// Summary: // populate vertexes data from properties data loaded from csv file public static List <DataVertex> PopulateVertexes(List <PropertyData> records) { var query = from record in records group record by record.ID into g select new { g.Key, Properties = g.ToDictionary(d => d.Property, d => d.Value) }; List <DataVertex> vlist = new List <DataVertex>(); foreach (var result in query) { var vertex = new DataVertex(result.Key); vertex.SetProperties(result.Properties); //vertex.Properties = GenerateProperties(result.Properties, vertex); vlist.Add(vertex); } return(vlist); }
private NavigateHistoryItem GetHistoryItem(DataVertex v, QuickGraph.BidirectionalGraph <DataVertex, DataEdge> overrallGraph) { var hisItem = new NavigateHistoryItem(); IEnumerable <DataEdge> outs; IEnumerable <DataEdge> ins; overrallGraph.TryGetInEdges(v, out ins); var edges = new List <DataEdge>(); if (overrallGraph.TryGetOutEdges(v, out outs)) { edges.AddRange(outs); } if (overrallGraph.TryGetInEdges(v, out ins)) { edges.AddRange(ins); } if (edges.Count > 0) { List <DataVertex> vertexes = new List <DataVertex>(); foreach (var e in edges) { if (!vertexes.Contains(e.Source)) { vertexes.Add(e.Source); } if (!vertexes.Contains(e.Target)) { vertexes.Add(e.Target); } } hisItem.Edges = edges; hisItem.Vertexes = vertexes; } return(hisItem); }
public void UpdateVertex(DataVertex vertex, Action <bool, DataVertex, Exception> onComplete) { if (vertex == null) { return; } try { if (vCache.ContainsKey(vertex.Id)) { vCache[vertex.Id] = vertex; } else { vCache.Add(vertex.Id, vertex); } var list = vCache.Values.ToList(); UpdateVertexes(list, (r, e) => { if (onComplete != null) { onComplete.Invoke(r, vertex, e); } }); } catch (Exception ex) { if (onComplete != null) { onComplete.Invoke(true, vertex, new Exception(string.Format("error occuered during updating vertex to csv. vertex id [{0}]", vertex.ID), ex)); } else { throw new Exception(string.Format("error occuered during updating vertex to csv. vertex id [{0}]", vertex.ID), ex); } } }
private void CreateVertex(GraphArea area, ZoomControl zoom, DataVertex data = null, double x = double.MinValue, double y = double.MinValue) { _viewmodel.Do(new CreateVertexOperation(Area, data, x, y, (v, vc) => { _selectedVertices.Add(v.Id); //area.RelayoutGraph(true); UpdateHighlightBehaviour(false); foreach (var selectedV in _selectedVertices) { var localvc = area.VertexList.Where(pair => pair.Key.Id == selectedV).Select(pair => pair.Value).FirstOrDefault(); HighlightBehaviour.SetHighlighted(localvc, true); } if (tbtnCanDrag.IsChecked.Value) { DragBehaviour.SetIsDragEnabled(vc, true); } else { DragBehaviour.SetIsDragEnabled(vc, false); } v.IsEditing = true; v.OnPositionChanged -= v_OnPositionChanged; v.OnPositionChanged += v_OnPositionChanged; }, (v) => { _selectedVertices.Remove(v.Id); //on vertex recreated })); //FitToBounds(area.Dispatcher, zoom); }
public CreateEdgeOperation(GraphArea graph, DataVertex source, DataVertex target, Action <EdgeControl> callback = null, Action <EdgeControl> undoCallback = null) : base(graph, source, target, callback, undoCallback) { }
public AddPropertyOperation(DataVertex vertex, PropertyViewmodel property = null) : base(vertex, property) { base.Sammary = "Add Property"; }
public void Dispose() { _vertex.RemoveObserver(_observerId); _vertex = null; }
public VertexObserverable(DataVertex vertex, Guid observerId) { _vertex = vertex; _observerId = observerId; }
private static ObservableCollection <PropertyViewmodel> GenerateProperties(Dictionary <string, string> dictionary, DataVertex data) { int index = 0; var pvs = from pair in dictionary select new PropertyViewmodel(index++, pair.Key, pair.Value, data); return(new ObservableCollection <PropertyViewmodel>(pvs)); }
public void UpdateVertex(DataVertex vertex, Action <bool, Exception> onComplete) { throw new NotImplementedException(); }
public DeletePropertyOperation(DataVertex vertex) : base(vertex, null) { base.Sammary = "Delete Property"; }
public PropertyOperation(DataVertex vertex, PropertyViewmodel property) { _property = property; _vertex = vertex; }
//another constructor for inject IGraphDataService to graph explorer public GraphExplorer(IGraphDataService graphDataService) : this() { //load data if graphDataService is provided if (graphDataService != null) { this.Loaded += (s, e) => { GraphDataService = graphDataService; } } ; } void AreaNav_VertexDoubleClick(object sender, GraphX.Models.VertexSelectedEventArgs args) { //throw new NotImplementedException(); var vertex = args.VertexControl.DataContext as DataVertex; if (vertex == null || vertex == _currentNavItem) { return; } _currentNavItem = vertex; var degree = Area.Graph.Degree(vertex); if (degree < 1) { return; } NavigateTo(vertex, Area.Graph); } void Area_VertexDoubleClick(object sender, GraphX.Models.VertexSelectedEventArgs args) { if (tbtnCanEdit.IsChecked.HasValue && tbtnCanEdit.IsChecked.Value) { return; } var vertex = args.VertexControl.DataContext as DataVertex; if (vertex == null) { return; } _currentNavItem = vertex; var degree = Area.Graph.Degree(vertex); if (degree < 1) { return; } NavigateTo(vertex, Area.Graph); if (navTab.Visibility != System.Windows.Visibility.Visible) { navTab.Visibility = System.Windows.Visibility.Visible; } navTab.IsSelected = true; }
void Area_VertexSelected(object sender, GraphX.Models.VertexSelectedEventArgs args) { if (args.MouseArgs.LeftButton == MouseButtonState.Pressed) { //if (DragBehaviour.GetIsDragging(args.VertexControl)) return; SelectVertex(args.VertexControl); if (IsInEditMode && _status.HasFlag(GraphExplorerStatus.CreateLinkSelectSource)) { if (_edVertex == null) //select starting vertex { _edVertex = args.VertexControl; _edFakeDV = new DataVertex() { ID = -666 }; _edGeo = new PathGeometry(new PathFigureCollection() { new PathFigure() { IsClosed = false, StartPoint = _edVertex.GetPosition(), Segments = new PathSegmentCollection() { new PolyLineSegment(new List <Point>() { new Point() }, true) } } }); var pos = zoomctrl.TranslatePoint(args.VertexControl.GetPosition(), Area); var lastseg = _edGeo.Figures[0].Segments[_edGeo.Figures[0].Segments.Count - 1] as PolyLineSegment; lastseg.Points[lastseg.Points.Count - 1] = pos; var dedge = new DataEdge(_edVertex.Vertex as DataVertex, _edFakeDV); _edEdge = new EdgeControl(_edVertex, null, dedge) { ManualDrawing = true }; Area.AddEdge(dedge, _edEdge); Area.Graph.AddVertex(_edFakeDV); Area.Graph.AddEdge(dedge); _edEdge.SetEdgePathManually(_edGeo); _status = GraphExplorerStatus.CreateLinkSelectTarget; _viewmodel.PostStatusMessage("Select Target Node"); } else if (_edVertex != args.VertexControl && _status.HasFlag(GraphExplorerStatus.CreateLinkSelectTarget)) //finish draw { _viewmodel.CreateEdge((_edVertex.Vertex as DataVertex).Id, (args.VertexControl.Vertex as DataVertex).Id); ClearEdgeDrawing(); _status = GraphExplorerStatus.Ready; tbnNewEdge.IsChecked = false; } } } else if (args.MouseArgs.RightButton == MouseButtonState.Pressed && IsInEditMode) { args.VertexControl.ContextMenu = new System.Windows.Controls.ContextMenu(); var miDeleteVertex = new System.Windows.Controls.MenuItem() { Header = "Delete", Tag = args.VertexControl }; miDeleteVertex.Click += miDeleteVertex_Click; args.VertexControl.ContextMenu.Items.Add(miDeleteVertex); } }
public VertexPositionChangeOperation(GraphArea graph, VertexControl vc, double offsetX, double offsetY, DataVertex data = null, Action <DataVertex, VertexControl> callback = null, Action <DataVertex> undoCallback = null) : base(graph, data, callback, undoCallback) { _vc = vc; _offsetX = offsetX; _offsetY = offsetY; Status = Orc.GraphExplorer.Status.Done; }
public virtual void Dispose() { _property = null; _vertex = null; }
public DeleteEdgeOperation(GraphArea graph, DataVertex source, DataVertex target, DataEdge edge, Action <EdgeControl> callback = null, Action <EdgeControl> undoCallback = null) : base(graph, source, target, callback, undoCallback) { _Edge = edge; base.Sammary = "Delete Edge"; }