void node_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            PropertyInfo propInfo;

            propInfo = sender.GetType().GetProperty(e.PropertyName);
            if (GraphShape.IsEdge(propInfo))
            {
                EntityRelationGraphReset();
            }
            if (PropertyChanged != null)
            {
                PropertyChanged(sender, e);
            }
        }
コード例 #2
0
        public bool AddDataSource(IGraphDataSource graphDataSource)
        {
            if (graphDataProviders.Count == MaxDataSources)
            {
                // Maximum number of data sources has already been reached
                return(false);
            }

            var provider = new GraphDataProvider {
                DataSource = graphDataSource, IsGraphed = true
            };

            provider.PenData = graphDataPens.FirstOrDefault(p => !usedPens.Contains(p));
            if (!(graphDataSource is IHiddenGraphDataSource))
            {
                this.usedPens.Add(provider.PenData);
            }
            this.graphDataProviders.Add(provider);
            provider.DataChanged += OnProviderDataChanged;

            var shape = new GraphShape {
                Stroke = provider.PenData.Brush, StrokeDashCap = PenLineCap.Round, StrokeLineJoin = PenLineJoin.Round
            };

            shape.SetBinding(Shape.StrokeThicknessProperty, new Binding {
                Source = provider, Path = new PropertyPath(GraphDataProvider.StrokeThicknessProperty)
            });
            shape.SetBinding(Shape.StrokeDashArrayProperty, new Binding {
                Source = provider, Path = new PropertyPath(GraphDataProvider.StrokeDashArrayProperty)
            });
            shape.SetBinding(Shape.FillProperty, new Binding {
                Source = provider, Path = new PropertyPath(GraphDataProvider.FillProperty)
            });
            shape.SetBinding(Panel.ZIndexProperty, new Binding {
                Source = provider, Path = new PropertyPath(GraphDataProvider.ZIndexProperty)
            });

            this.shapeTable.Add(provider, shape);

            if (this.canvas != null)
            {
                this.canvas.Children.Add(shape);
            }

            OnProviderDataChanged(provider, EventArgs.Empty);

            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Returns the entity graph as defined by associations that are marked with the 'EntityGraphAttribute' attribute.
        /// The resulting graph consists of a list of GraphNodes. Each GraphNode has an element 'Node' of type 'T',
        /// which represents the actual node, a set, SingleEdges, which correspond to EntityRefs, and a
        /// a set, ListEdges, which correspond to EntityCollections.
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="graph"></param>
        private void BuildEntityGraph(TEntity entity, EntityRelationGraph <TEntity> graph)
        {
            if (graph.Nodes.Any(n => n.Node == entity))
            {
                return;
            }
            EntityRelation <TEntity> node = new EntityRelation <TEntity>()
            {
                Node = entity
            };

            graph.Nodes.Add(node);

            foreach (PropertyInfo edge in GraphShape.OutEdges(entity))
            {
                if (typeof(IEnumerable).IsAssignableFrom(edge.PropertyType))
                {
                    var assocList = GraphShape.GetNodes(entity, edge);
                    if (assocList == null)
                    {
                        continue;
                    }
                    node.ListEdges.Add(edge, new List <TEntity>());
                    foreach (TEntity e in assocList)
                    {
                        if (e != null)
                        {
                            node.ListEdges[edge].Add(e);
                            BuildEntityGraph(e, graph);
                        }
                    }
                }
                else
                {
                    TEntity e = (TEntity)GraphShape.GetNode(entity, edge);
                    if (e != null)
                    {
                        node.SingleEdges.Add(edge, e);
                        BuildEntityGraph(e, graph);
                    }
                }
            }
        }
コード例 #4
0
        private protected void MakeContent(TreeViewItem snd)
        {
            var          elem = (snd.GetValue(ContentProperty) as Func <object>)();
            GraphElement ge   = null;

            if (elem is ATransformation t)
            {
                ge = new GraphTransform(t);
            }
            else if (elem is Renderable r)
            {
                ge = new GraphShape(r);
            }
            else if (elem is GraphParent gp)
            {
                ge = gp;
            }
            newElement = MakeContentSub(snd.Header as string, ge);
        }
コード例 #5
0
        public bool AddDataSource(IGraphDataSource graphDataSource)
        {
            if (graphDataProviders.Count == MaxDataSources)
            {
                // Maximum number of data sources has already been reached
                return false;
            }

            var provider = new GraphDataProvider { DataSource = graphDataSource, IsGraphed = true };
            provider.PenData = graphDataPens.FirstOrDefault(p => !usedPens.Contains(p));
            if (!(graphDataSource is IHiddenGraphDataSource))
            {
                this.usedPens.Add(provider.PenData);
            }
            this.graphDataProviders.Add(provider);
            provider.DataChanged += OnProviderDataChanged;

            var shape = new GraphShape { Stroke = provider.PenData.Brush, StrokeDashCap = PenLineCap.Round, StrokeLineJoin = PenLineJoin.Round };

            shape.SetBinding(Shape.StrokeThicknessProperty, new Binding { Source = provider, Path = new PropertyPath(GraphDataProvider.StrokeThicknessProperty) });
            shape.SetBinding(Shape.StrokeDashArrayProperty, new Binding { Source = provider, Path = new PropertyPath(GraphDataProvider.StrokeDashArrayProperty) });
            shape.SetBinding(Shape.FillProperty, new Binding { Source = provider, Path = new PropertyPath(GraphDataProvider.FillProperty) });
            shape.SetBinding(Panel.ZIndexProperty, new Binding { Source = provider, Path = new PropertyPath(GraphDataProvider.ZIndexProperty) });

            this.shapeTable.Add(provider, shape);

            if (this.canvas != null)
            {
                this.canvas.Children.Add(shape);
            }

            OnProviderDataChanged(provider, EventArgs.Empty);

            return true;
        }