}//End of method Initialize_dot_clock protected void All_systems_go(Object sender, EventArgs events)//Event handler of the start button. { //The motion clock will either pause or resume if (this_is_first_click_on_start_button) { //This section updates the position of the ball one time when the start button is first clicked. This is necessary when- //refresh_rate > dot_update_rate. The location of the ball will be displayed incorrectly in the interval between the //first click on the start button and the first tic of the dot_motion_clock. Therefore, the following section performs //a one-time update of the position of the ball. curve_algorithms.get_next_coordinates(amplitude, coefficient, delta, ref t, out x, out y); //Convert the Cartesian coordinates to scaled coordinates for viewing on a monitor x_scaled_double = scale_factor * x + offset; y_scaled_double = (double)form_height / 2.0 - scale_factor * y; this_is_first_click_on_start_button = false; if (x_scaled_double > (double)(form_width - 1)) { dot_motion_clock.Enabled = false; graphic_area_refresh_clock.Enabled = false; System.Console.WriteLine("Both clocks have stopped. 1 You may close the window."); } //End of if } //End of section updating the position of the ball one time if (motion_clock_active) { dot_motion_clock.Enabled = false; graphic_area_refresh_clock.Enabled = false; start_button.Text = "Resume"; } else { dot_motion_clock.Enabled = true; graphic_area_refresh_clock.Enabled = true; start_button.Text = "Pause"; } motion_clock_active = !motion_clock_active; }//End of method All_system_go
} //End of Manage_spiral_clock //The next method updates the x and y coordinates of the dot that is tracing the sine curve. protected void Update_the_position_of_the_dot(System.Object sender, ElapsedEventArgs an_event) { //Call a method to compute the next pair of Cartesian coordinates for the moving particle. curve_algorithms.get_next_coordinates(amplitude, coefficient, delta, ref t, out x, out y); //Convert the Cartesian coordinates to scaled coordinates for viewing on a monitor x_scaled_double = scale_factor * x + offset; y_scaled_double = (double)form_height / 2.0 - scale_factor * y; if (x_scaled_double > (double)(form_width - 1)) { dot_refresh_clock.Enabled = false; graphic_area_refresh_clock.Enabled = false; System.Console.WriteLine("Both clocks have stopped. You may close the window."); } } //End of method Update_the_position_of_the_dot