Esempio n. 1
0
        /// <summary>
        /// Dequeues the Commands in MovementCommandsQueue and Executes them
        /// </summary>
        internal static async void CommandCaller(Graphics GraphicsObj, PictureBox DrawSurface, TurtleGraphicsForm ActiveForm)
        {
            System.Windows.Forms.Timer DrawingWait = new System.Windows.Forms.Timer();
            DrawingWait.Interval = 2000;

            Drawing.CurrentAngle = 0;
            while (MovementCommandsQueue.Count != 0)
            {
                CurrentCommand = MovementCommandsQueue.Dequeue();
                for (ulong RepeatCommand = 1; RepeatCommand <= CurrentCommand.Quantity; RepeatCommand++)
                {
                    ActiveForm.UpdateTurtlePosition();
                    DrawSurface.Invalidate();
                    await Task.Delay(125);

                    CurrentCommand.Command?.Invoke(GraphicsObj);
                }
            }
            DrawSurface.Invalidate();
        }
Esempio n. 2
0
 /// <summary>
 /// Loads the Specified Drawing Command into the Queue
 /// </summary>
 /// <param name="CurrentlyCalledCommand">The Drawing Command (from the Drawing Class) in the form of a Paramterless Procudure to be queued</param>
 internal static void CommandQueueLoader(Action <Graphics> CurrentlyCalledCommand = null)
 {
     if (CurrentCommandQuantityPair.Command != null)
     {
         if (CurrentCommandQuantityPair.Command == CurrentlyCalledCommand && CurrentCommandQuantityPair.Quantity < uint.MaxValue)
         {
             CurrentCommandQuantityPair.Quantity++;
         }
         else
         {
             MovementCommandsQueue.Enqueue(CurrentCommandQuantityPair);
             CurrentCommandQuantityPair = new CommandQuantityDuad(CurrentlyCalledCommand, 1);
         }
     }
     else
     {
         CurrentCommandQuantityPair = new CommandQuantityDuad(CurrentlyCalledCommand, 1);
         Angles.Intialise();
     }
 }