private void UpdateConsole(Object src, ElapsedEventArgs e)
        {
            //Check if any switches or crossings should change on the current hour:minute
            CheckCrossingPlan();
            CheckSwitchPlan();
            Console.Clear();
            TrainTrack.RefreshTrack();

            //Place each train on the map
            foreach (Train t in trains)
            {
                TrainTrack.TrackGrid[t.GetPosition.Y][t.GetPosition.X] = 'T';
            }

            //Convert the 2d char array into a full string to print in the console
            string[] rows = new string[TrainTrack.TrackGrid.Length]; //Make a string array based on the trackgrids Y-axis length
            for (int i = 0; i < rows.Length; i++)
            {
                rows[i] = new string(TrainTrack.TrackGrid[i]); //Make a string at current index with the char array at row index
            }
            string track = string.Join('\n', rows);            //Make a full string of the whole track

            Console.WriteLine(track);
            ControllerLog.Log(@"C:\Users\Sebastian\source\repos\the-train-track-lattepappor\Source\TrainEngine\Data\controllerlog.txt", GlobalTime);
            GlobalTime = GlobalTime.AddMinutes(1);

            //If the current time is >= 11:42 all trains SHOULD have arrived at their final destination and we should stop observing the train states.
            if (GlobalTime >= DateTime.Parse("11:42"))
            {
                ObserverTimer.Close();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("\nAll trains have arrived at their final destination. Terminating program :)");
            }
        }
예제 #2
0
        /// <summary>
        /// Handles EventController sent by DirectInputManager via EventBus<
        /// EventController> when any controller input occurs.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnEventController(object sender, BusEventArgs <EventController> e)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.Invoke(new OnEventControllerInvoker(OnEventController), sender, e);
                return;
            }

            EventController controllerEvent = e.BusEvent;

            switch (controllerEvent.Type)
            {
            case EventController.EventType.Button:
                ControllerLog.Text += " " + controllerEvent.Joystick.Information.InstanceName +
                                      " (Button " + controllerEvent.Button + " " + controllerEvent.ButtonValue + ")\r\n";
                break;

            case EventController.EventType.POV:
                ControllerLog.Text += " " + controllerEvent.Joystick.Information.InstanceName +
                                      " (POV " + controllerEvent.POVState + ")\r\n";
                break;

            // TODO do something with axis name and value
            case EventController.EventType.Axis:
                break;
            }
            ControllerLog.ScrollToEnd();
        }
예제 #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            lblMessage.Text = "Loggar in....";
            ControllerLog controller = new ControllerLog();
            string        username   = txtUser.Text;
            string        pw         = txtPassword.Text;
            int           login      = controller.ControllerLogin(username, pw);


            switch (login)
            {
            case 1:
                this.Hide();
                var formManager = new FormLandlord.Form1();
                formManager.Closed += (s, args) => this.Close();
                formManager.Show();
                break;

            case 2:
                this.Hide();
                var formTenant = new FormTenant.Form1();
                formTenant.Closed += (s, args) => this.Close();
                formTenant.Show();
                break;

            default:
                lblMessage.Text = "Felaktigt användarnamn eller lösenord!";
                break;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            String Saida = ControllerLog.enviar(Txt_Report.Text);

            if (Saida == "E-mail enviado com sucesso!")
            {
                MessageBox.Show(Saida, "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);

                Txt_Report.Clear();
            }
            else
            {
                MessageBox.Show(Saida, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #5
0
 private void OnButtonClear(object sender, RoutedEventArgs e)
 {
     ControllerLog.Clear();
 }