Example #1
0
        private int[] AddExercisesToRound(int round, SplitKind chosenSplit, Category category, int howmanyIneed, bool isCompound = false)
        {
            CourseExercise courseExercise = new CourseExercise();

            if (exercisesList[round] == null)
            {
                exercisesList[round] = new List <CourseExercise>();
            }

            List <CourseExercise> ListToPickFrom = new List <CourseExercise>();

            ListToPickFrom = ExercisesLoader.SelectExercisesFromMatrix(chosenSplit, category, difficulty, includeZejax, isCompound);
            int howmanyArethere = ListToPickFrom.Count;

            //int howmanyArethere = exercisesMatrix[(int)chosenSplit, (int)category].Count;

            int[] randomNumbers = RandomExerciseIndexes(howmanyIneed, howmanyArethere);
            for (int i = 0; i < howmanyIneed; i++)
            {
                //courseExercise = exercisesMatrix[(int)chosenSplit, (int)category][randomNumbers[i]];
                courseExercise = ListToPickFrom[randomNumbers[i]];
                exercisesList[round].Add(courseExercise);
            }
            return(randomNumbers);
        }
Example #2
0
        public Routine(List <CourseExercise>[,] exercisesMatrix, SplitKind chosenSplit, Difficulty chosenLevel, int howManyRounds, CoolDown coolDownLevel = CoolDown.Beginner, bool includeZejax = false)
        {
            this.exercisesMatrix = exercisesMatrix;
            this.difficulty      = chosenLevel;
            rounds        = howManyRounds;
            exercisesList = new List <CourseExercise> [5];
            Indexes.Round = new RoundIndexes[4];
            if (chosenSplit == SplitKind.All)
            {
                splitKind = (SplitKind)GlobalVar.r.Next(1, 4);
            }
            else
            {
                splitKind = chosenSplit;
            }
            this.includeZejax = includeZejax;

            // Add exercises to each round \\
            AddWarmupExercises(splitKind, difficulty);
            Indexes.Round = new RoundIndexes[4];
            for (int round = 1; round <= howManyRounds; round++)
            {
                CreateRound(round, chosenSplit, difficulty);
            }
            bool includeCoolDown = coolDownLevel != CoolDown.None;

            if (includeCoolDown)
            {
                AddCoolDownExercises(difficulty);
            }
        }
Example #3
0
        private void AddWarmupExercises(SplitKind split, Difficulty difficulty)
        {
            //Add joint rotations.
            CourseExercise jointRotations = new CourseExercise();

            jointRotations = exercisesMatrix[(int)SplitKind.All, (int)Category.Mobility][GlobalVar.jointRotationsIndex];
            exercisesList[(int)Category.WarmUp] = new List <CourseExercise>();
            exercisesList[(int)Category.WarmUp].Add(jointRotations);
            Indexes.Warmup = new List <int>();
            //routineIndexes.Warmup.Add(GlobalVar.jointRotationsIndex);

            //Add conditioning exercises.
            bool isCompound = true;

            int[] warmupIndexes1 = AddExercisesToRound(GlobalVar.Warmup, SplitKind.All, Category.WarmUp, 1 + GlobalVar.r.Next(0, 3), isCompound);
            Indexes.Warmup.AddRange(warmupIndexes1);
            int[] warmupIndexes2 = AddExercisesToRound(GlobalVar.Warmup, SplitKind.All, Category.WarmUp, 1 + GlobalVar.r.Next(0, 3), !isCompound);
            Indexes.Warmup.AddRange(warmupIndexes2);

            //Add warmup circles.
            Circles c             = new Circles(split, difficulty);
            var     warmupCircles = c.PickedCircles;

            exercisesList[(int)Category.WarmUp].AddRange(warmupCircles);
            Indexes.Circles = new List <int>();
            Indexes.Circles = c.indexes;
        }
Example #4
0
 private void CreateRound(int round, SplitKind chosenSplit, Difficulty difficulty)
 {
     int[] KinesiologicalStretching = AddExercisesToRound(round, chosenSplit, Category.KinesiologicalStretching, 3 + GlobalVar.r.Next(0, 3));
     int[] MovementHabituation      = AddExercisesToRound(round, chosenSplit, Category.MovementHabituation, GlobalVar.r.Next(1, 3));
     int[] Strength = AddExercisesToRound(round, chosenSplit, Category.Strength, 1);
     Indexes.Round[round].KinesiologicalStretching = new List <int>();
     Indexes.Round[round].MovementHabituation      = new List <int>();
     Indexes.Round[round].Strength = new List <int>();
     Indexes.Round[round].KinesiologicalStretching.AddRange(KinesiologicalStretching);
     Indexes.Round[round].MovementHabituation.AddRange(MovementHabituation);
     Indexes.Round[round].Strength.AddRange(Strength);
 }
Example #5
0
        /*
         * public static void LoadTxtRoutine(string fileName)
         * {
         *  LessonPlanRoutine lessonPlan = new LessonPlanRoutine();
         *  lessonPlan.Warmup = new List<CourseExercise>();
         *  lessonPlan.Round1 = new List<CourseExercise>();
         *  lessonPlan.Round2 = new List<CourseExercise>();
         *  lessonPlan.Round3 = new List<CourseExercise>();
         *  lessonPlan.CoolDown = new List<CourseExercise>();
         *
         *  StreamReader stream = new StreamReader(fileName);
         *
         *  int[] sectionExCount = new int[5];
         *  sectionExCount[GlobalVar.Warmup] = int.Parse(stream.ReadLine());
         *  for (int i = 0; i < sectionExCount[GlobalVar.Warmup]; i++)
         *  {
         *      string exName = stream.ReadLine();
         *      var ceList = exercisesMatrix[GlobalVar.Warmup, (int)Category.Mobility].Where(ex => ex.name.Contains(exName));
         *      lessonPlan.Warmup.Add(ceList.ToArray()[0]);
         *  }
         *  //TODO: do the same for the other sections (rounds1,2,3, cooldown etc).
         * }
         */

        public static List <CourseExercise> SelectExercisesFromMatrix(SplitKind split, Category category, Difficulty difficulty, bool includeZejax = false, bool isCompound = false)
        {
            List <CourseExercise> selectedExercises = new List <CourseExercise>();

            selectedExercises = ExercisesLoader.exercisesMatrix[(int)split, (int)category];

            if (category == Category.WarmUp)
            {
                if (isCompound)
                {
                    selectedExercises = selectedExercises.Where(exercise => exercise.trainingInfo.isCompound == true).ToList();
                }
                else
                {
                    selectedExercises = selectedExercises.Where(exercise => exercise.trainingInfo.isCompound == false).ToList();
                }
            }

            if (difficulty == Difficulty.All)
            {
                if (includeZejax)
                {
                    selectedExercises = ExercisesLoader.exercisesMatrix[(int)split, (int)category];
                }
                else if (!includeZejax)
                {
                    selectedExercises = selectedExercises.Where(exercise => !(exercise.name.ToLower().Contains("zejax"))).ToList();
                }
            }
            else if (difficulty != Difficulty.All)
            {
                if (includeZejax)
                {
                    selectedExercises = selectedExercises.Where(exercise => (exercise.trainingInfo.difficulty == difficulty)).ToList();
                }
                else
                {
                    selectedExercises = selectedExercises.Where(exercise => (exercise.trainingInfo.difficulty == difficulty) && !(exercise.name.ToLower().Contains("zejax"))).ToList();
                }
            }

            if (selectedExercises.Count == 0)
            {
                selectedExercises = ExercisesLoader.exercisesMatrix[(int)split, (int)category];
            }
            return(selectedExercises);
        }
Example #6
0
 /// <summary>
 /// Получить список смежных одинаково ориентированных рёбер с ребром, на которую указывает курсор
 /// </summary>
 /// <param name="location"></param>
 /// <param name="width"></param>
 /// <returns></returns>
 private List <Edge> GetAjacentEdges(Point location, SplitKind splitKind, float width = Helper.Epsilon)
 {
     if (splitKind == SplitKind.None)
     {
         return(new List <Edge>());
     }
     using (var grp = new GraphicsPath())
         using (var pen = new Pen(Color.Black, width))
         {
             foreach (var item in Edges.Where(edge => splitKind == SplitKind.Vertical && edge.IsVertical ||
                                              splitKind == SplitKind.Horizontal && edge.IsHorizontal))
             {
                 var edge = item;
                 grp.Reset();
                 grp.AddLine(edge.Node1.Offset, edge.Node2.Offset);
                 if (grp.IsOutlineVisible(location, pen))
                 {
                     var result = new List <Edge>();
                     var queue  = new Queue <Edge>();
                     queue.Enqueue(edge);
                     while (true)
                     {
                         if (queue.Count == 0)
                         {
                             break;
                         }
                         edge = queue.Dequeue();
                         var pn1 = edge.Node1;
                         var pn2 = edge.Node2;
                         // найти все рёбра, разделяющие общие узловые точки
                         var list = Edges.Where(e => !result.Contains(e) && e.IsSameOrientation(edge) &&
                                                (e.Node1 == pn1 || e.Node1 == pn2 || e.Node2 == pn1 || e.Node2 == pn2)).ToList();
                         if (list.Count > 0)
                         {
                             foreach (var e in list)
                             {
                                 queue.Enqueue(e);
                             }
                             result.AddRange(list);
                         }
                     }
                     return(result);
                 }
             }
         }
     return(new List <Edge>());
 }
Example #7
0
 private Options(
     IEnumerable <string> filenames,
     OutputKind outputKind,
     SplitKind splitKind,
     IncludeKind includeKind,
     string templatePath,
     string outputPath,
     bool verbose,
     bool success
     )
 {
     Filenames    = new ReadOnlyCollection <string>(filenames.ToArray());
     OutputKind   = outputKind;
     SplitKind    = splitKind;
     IncludeKind  = includeKind;
     TemplatePath = templatePath;
     OutputPath   = outputPath;
     Verbose      = verbose;
     Success      = success;
 }
Example #8
0
        public static Options Parse(string[] args)
        {
            List <string> filenames    = new List <string>();
            bool          lastOption   = false;
            OutputKind    outputKind   = default;
            SplitKind     splitKind    = default;
            IncludeKind   includeKind  = default;
            string        templatePath = null;
            string        outputPath   = null;
            bool          verbose      = false;
            bool          success      = false;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i][0] == '-' && !lastOption)
                {
                    if (args[i] == "--")
                    {
                        lastOption = true;
                        continue;
                    }
                    switch (args[i].Length > 1 ? args[i][1] : '-')
                    {
                    case '-':
                        switch (args[i].Substring(2))
                        {
                        case "html":
                            outputKind = OutputKind.Html;
                            break;

                        case "internal":
                            includeKind |= IncludeKind.Internal;
                            break;

                        case "md":
                        case "markdown":
                            outputKind = OutputKind.Markdown;
                            break;

                        case "output":
                            if (i >= args.Length)
                            {
                                Console.Error.WriteLine($"Missing pathname after {args[i]}");
                                Environment.Exit(-1);
                                break;
                            }
                            outputPath = args[++i];
                            break;

                        case "private":
                            includeKind |= IncludeKind.Private;
                            break;

                        case "protected":
                            includeKind |= IncludeKind.Protected;
                            break;

                        case "public":
                            includeKind |= IncludeKind.Public;
                            break;

                        case "split":
                        case "split-types":
                            splitKind = SplitKind.SplitByNamespaceAndType;
                            break;

                        case "split-namespace":
                            splitKind = SplitKind.SplitByNamespace;
                            break;

                        case "template":
                            if (i >= args.Length)
                            {
                                Console.Error.WriteLine($"Missing pathname after {args[i]}");
                                Environment.Exit(-1);
                                break;
                            }
                            templatePath = args[++i];
                            break;

                        case "verbose":
                            verbose = true;
                            break;

                        default:
                            Console.Error.WriteLine($"Unknown option: {args[i]}");
                            Environment.Exit(-1);
                            break;
                        }
                        break;

                    case 'm':
                        outputKind = OutputKind.Markdown;
                        break;

                    case 's':
                        splitKind = SplitKind.SplitByNamespaceAndType;
                        break;

                    case 't':
                        if (args[i].Length > 2)
                        {
                            templatePath = args[i].Substring(2);
                        }
                        else
                        {
                            if (i >= args.Length)
                            {
                                Console.Error.WriteLine($"Missing pathname after {args[i]}");
                                Environment.Exit(-1);
                                break;
                            }
                            templatePath = args[++i];
                        }
                        break;

                    case 'o':
                        if (args[i].Length > 2)
                        {
                            outputPath = args[i].Substring(2);
                        }
                        else
                        {
                            if (i >= args.Length)
                            {
                                Console.Error.WriteLine($"Missing pathname after {args[i]}");
                                Environment.Exit(-1);
                                break;
                            }
                            outputPath = args[++i];
                        }
                        break;

                    case 'v':
                        verbose = true;
                        break;

                    case '?':
                    case 'h':
                    case 'H':
                        Console.Error.WriteLine(
                            @"Usage: crossdox [options] assembly.dll assembly2.xml ...

Crossdox reads XML documentation output from the C# compiler and any
given compiled DLLs or EXEs, and generates cross-referenced, pretty
Markdown or HTML documentation websites from them.

Selection options:
  --public            Include public (exclude private/protected)
  --internal          Include internal (exclude private/protected)
  --protected         Include protected (exclude private)
  --private           Include private

Website options:
  --html              Output is HTML website
  -m --md --markdown  Output is Markdown (default)
  --summary           Output a summary of what does & doesn't have docs
  -t path
  --template path     Use custom HTML/Markdown template(s) from here

Output options:
  -s --split
  --split-types       Output separate files by namespace and type
  --split-namespace   Output separate files only by namespace
  -o path
  --output path       Specify output file/folder (default is '.')
  -v --verbose        Emit verbose debugging information to stderr
");
                        success = false;
                        break;

                    default:
                        Console.Error.WriteLine($"Unknown option: {args[i]}");
                        success = false;
                        break;
                    }
                }
                else
                {
                    filenames.Add(args[i]);
                }
            }

            if (includeKind == default)
            {
                includeKind = IncludeKind.All;
            }

            return(new Options(
                       filenames: filenames,
                       outputKind: outputKind,
                       splitKind: splitKind,
                       includeKind: includeKind,
                       templatePath: templatePath,
                       outputPath: outputPath,
                       verbose: verbose,
                       success: success
                       ));
        }
Example #9
0
        public Circles(SplitKind split, Difficulty difficulty)
        {
            PickedCircles = new List <CourseExercise>();
            var ListBySplitAndCategory = ExercisesLoader.exercisesMatrix[(int)split, (int)Category.WarmUp];

            indexes = new List <int>();
            //Determine which circles are going to be included in the routine.

            switch (difficulty)
            {
            case Difficulty.All:
                switch (GlobalVar.r.Next(1, 4))
                {
                case 1:
                    //Knee bend on the floor.
                    PickedCircles.AddRange(ListBySplitAndCategory.Where(ex => ex.name.ToLower().Contains("circle") && !ex.name.ToLower().Contains("straight")));
                    indexes.Add(1);
                    break;

                case 2:
                    //Leg straight.
                    PickedCircles.AddRange(ListBySplitAndCategory.Where(ex => ex.name.ToLower().Contains("straight")));
                    indexes.Add(2);
                    break;

                case 3:
                    //Both knee bend and leg straight.
                    PickedCircles.AddRange(ListBySplitAndCategory.Where(ex => ex.name.ToLower().Contains("circle")));
                    indexes.Add(3);
                    break;
                }
                break;

            case Difficulty.Beginner:
                PickedCircles.AddRange(ListBySplitAndCategory.Where(ex => ex.name.ToLower().Contains("circle") && !ex.name.ToLower().Contains("straight")));
                indexes.Add(1);
                break;

            case Difficulty.Intermediate:
                PickedCircles.AddRange(ListBySplitAndCategory.Where(ex => ex.name.ToLower().Contains("circle") && !ex.name.ToLower().Contains("straight")));
                indexes.Add(1);
                if (GlobalVar.r.Next(0, 2) == 0)
                {
                    PickedCircles.AddRange(ListBySplitAndCategory.Where(ex => ex.name.ToLower().Contains("straight")));
                    indexes.Add(2);
                }
                break;

            case Difficulty.Advanced:
                if (GlobalVar.r.Next(0, 2) == 1)
                {
                    PickedCircles.AddRange(ListBySplitAndCategory.Where(ex => ex.name.ToLower().Contains("circle") && !ex.name.ToLower().Contains("straight")));
                    indexes.Add(1);
                }
                PickedCircles.AddRange(ListBySplitAndCategory.Where(ex => ex.name.ToLower().Contains("straight")));
                indexes.Add(2);
                break;
            }
            //Glutes circles.
            bool includeGlutes;

            includeGlutes = GlobalVar.r.Next(0, 2) == 1;
            if (includeGlutes)
            {
                PickedCircles.AddRange(ExercisesLoader.exercisesMatrix[(int)SplitKind.All, (int)Category.Mobility].Where(ex => ex.name.ToLower().Contains("glutes circle")));
                indexes.Add(1);
            }
            else
            {
                indexes.Add(0); //No glutes exercises.
            }
        }
Example #10
0
        /// <summary>
        /// Вычисление разрешённой области для перетаскивания рёбер
        /// </summary>
        /// <param name="edges"></param>
        /// <param name="splitKind"></param>
        /// <param name="origin"></param>
        /// <returns></returns>
        private Rectangle GetPermissibleArea(List <Edge> edges, SplitKind splitKind, Point origin)
        {
            var rect           = Area; // первоначальное ограничение
            var points         = new List <PointNode>();
            var perpendiculars = new List <Edge>();

            // получим все точки из списка рёбер, содержащих в своих списках рёбер перпендикулярные рёбра
            foreach (var edge in edges)
            {
                var pn1 = edge.Node1;
                var pn2 = edge.Node2;
                if (!points.Contains(pn1) && pn1.Edges.Any(e => e.IsPerpendicularOrientation(edge)))
                {
                    points.Add(pn1);
                    perpendiculars.AddRange(pn1.Edges.Where(e => e.IsPerpendicularOrientation(edge)));
                }
                if (!points.Contains(pn2) && pn2.Edges.Any(e => e.IsPerpendicularOrientation(edge)))
                {
                    points.Add(pn2);
                    perpendiculars.AddRange(pn2.Edges.Where(e => e.IsPerpendicularOrientation(edge)));
                }
            }
            var farPoints = new List <PointNode>();

            // получим все точки на противополжных концах рёбер
            foreach (var edge in perpendiculars)
            {
                var pn1 = edge.Node1;
                var pn2 = edge.Node2;
                if (!farPoints.Contains(pn1) && !points.Contains(pn1))
                {
                    farPoints.Add(pn1);
                }
                if (!farPoints.Contains(pn2) && !points.Contains(pn2))
                {
                    farPoints.Add(pn2);
                }
            }
            if (splitKind == SplitKind.Vertical)
            {
                var leftPoint  = farPoints.Where(pn => pn.Offset.X < origin.X).OrderBy(pn => Math.Abs(pn.Offset.X - origin.X)).FirstOrDefault();
                var left       = leftPoint != null ? leftPoint.Offset.X : Area.Left;
                var rightPoint = farPoints.Where(pn => pn.Offset.X > origin.X).OrderBy(pn => Math.Abs(pn.Offset.X - origin.X)).FirstOrDefault();
                var right      = rightPoint != null ? rightPoint.Offset.X : Area.Right;
                rect = new Rectangle(left, Area.Top, right - left, Area.Height);
            }
            else if (splitKind == SplitKind.Horizontal)
            {
                var topPoint    = farPoints.Where(pn => pn.Offset.Y < origin.Y).OrderBy(pn => Math.Abs(pn.Offset.Y - origin.Y)).FirstOrDefault();
                var top         = topPoint != null ? topPoint.Offset.Y : Area.Top;
                var bottomPoint = farPoints.Where(pn => pn.Offset.Y > origin.Y).OrderBy(pn => Math.Abs(pn.Offset.Y - origin.Y)).FirstOrDefault();
                var bottom      = bottomPoint != null ? bottomPoint.Offset.Y : Area.Bottom;
                rect = new Rectangle(Area.Left, top, Area.Width, bottom - top);
            }
            // дополнительные ограничения
            if (SplitKind == SplitKind.Horizontal)
            {
                rect.Inflate(1, -(int)Helper.Epsilon * 2);
            }
            else if (SplitKind == SplitKind.Vertical)
            {
                rect.Inflate(-(int)Helper.Epsilon * 2, 1);
            }
            return(rect);
        }