Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ArrowShapeType"/> class.
        /// </summary>
        /// <param name="shape">The shape.</param>
        public ArrowShapeType(CompositeArrowShape shape)
        {
            if (shape == null)
            {
                throw new ArgumentNullException("shape");
            }

            compositeArrowShape = shape;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Produces the dot for the specified demo.
        /// </summary>
        /// <returns>DOT.</returns>
        protected override IGraphExpression CreateGraph()
        {
            #region ExportCode
            var graph = Fluently.CreateDirectedGraph();
            
            int a = 1;
            int b = 2;

            var arrowShapes = typeof(ArrowShape)
                .GetFields(BindingFlags.Public | BindingFlags.Static)
                .Where(x => typeof(ArrowShape).IsAssignableFrom(x.FieldType))
                .Select(x => (ArrowShape) x.GetValue(null))
                .ToArray();

            var random = new Random((int)(DateTime.Now.Ticks % Int32.MaxValue));

            for (int i = 0; i< 10; i++)
            {
                const int numberOfArrowShapes = 2;

                var chosenArrowShapes = new List<ArrowShape>();

                for (int j = 0; j< numberOfArrowShapes; j++)
                {
                    var chosenShape = arrowShapes[random.Next(arrowShapes.Length)];

                    if ((chosenShape == ArrowShape.None) || (chosenArrowShapes.Contains(chosenShape))) {
                        j--;
                        continue;
                    }
                    
                    chosenArrowShapes.Add(chosenShape);
                }

                var shape = new CompositeArrowShape(chosenArrowShapes.ToArray());

                graph.Edges.Add(x => x.FromNodeWithName(a.ToString()).ToNodeWithName(b.ToString())
                                        .WithArrowHead(shape)
                                        .WithLabel(shape.ToDot()));

                a+=2;
                b+=2;
            }

            return graph;
            #endregion
        }
Exemplo n.º 3
0
 public void ToDot_Produces_CompositeArrowShape_Value_If_Specified()
 {
     var shape = new CompositeArrowShape(ArrowShape.Box, ArrowShape.Crow);
     Assert.AreEqual(new ArrowShapeType(shape).ToDot(), shape.ToDot());
 }
 public void ToDot_Appends_Arrow_Shapes()
 {
     var shape = new CompositeArrowShape(ArrowShape.Box, ArrowShape.Crow.Modify(ArrowShapeModifier.LeftClip));
     Assert.AreEqual(shape.ToDot(), ArrowShape.Box.ToDot() + ArrowShape.Crow.Modify(ArrowShapeModifier.LeftClip).ToDot());
 }