예제 #1
0
 private static int GetCirclesCount(Vertex vertex)
 {
     State state = myMachine.States.Where(s => s.Name == vertex.Name).ToList()[0];
     int count = 0;
     foreach (var function in myMachine.Functions)
     {
         if ((function.From == state) && (function.To == state)) count++;
     }
     return count;
 }
예제 #2
0
 static void VerticalLine(double end, int count, double indention, int currentVertex)
 {
     double interval = end / (count + 1);
     double start = interval;
     for (int i = 0; i < count; i++)
     {
         string name = myMachine.States[currentVertex].Name;
         Vertex vertex = new Vertex(name, indention, start);
         start += interval;
         vertices.Add(vertex);
         currentVertex++;
     }
 }
예제 #3
0
        private static List<Tuple<Point, int>> GetCircles(Vertex vertex)
        {
            Point PolygonCenter = new Point(canvasWidth / 2, canvasHeight / 2);
            Point statePoint = new Point(vertex.W, vertex.H);

            Vector a = new Vector(statePoint.X - PolygonCenter.X, statePoint.Y - PolygonCenter.Y);
            if (a.Length == 0) a = new Vector(100, 100);
            double rad = a.Length;
            Vector itog = new Vector(a.X / rad, a.Y / rad);

            var list = new List<Tuple<Point, int>>();
            var count = GetCirclesCount(vertex);
            if (count == 0) throw new Exception("Невозможно построить окружность");
            else
            {
                for (int i = 1; i <= count; i++)
                {
                    rad = 30 * i;
                    Point newPoint = new Point(statePoint.X + rad * itog.X / Math.Sqrt(2) - rad, statePoint.Y + rad * itog.Y / Math.Sqrt(2) - rad);
                    list.Add(new Tuple<Point, int>(newPoint, (int)rad));
                }
                return list;
            }
        }