Пример #1
0
        private void KeyPressed(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Escape:
                Close();
                break;

            case Key.D0:
                base_.RebootComputer();
                break;

            case Key.D1:
                base_.ShutdownComputer();
                break;

            case Key.D2:
                Process.Start("notepad", base_.SCHEDULES_FILE_LOCATION);
                break;

            case Key.D3:
                Process.Start("cmd");
                break;

            case Key.D4:

                int h = DateTime.Now.Hour;
                int m = DateTime.Now.Minute;

                ScheduleManager.ManuallyUpdateScheduleKeys(new Schedule()
                {
                    ScreenOnTime       = new int[] { h, m + 1 },
                    ScreenOffTime      = new int[] { h, m + 5 },
                    ClockScreenOnTime  = new int[] { h, m + 1 },
                    ClockScreenOffTime = new int[] { h, m },
                    FoodScreenOnTime   = new int[] { h, m + 2 },
                    FoodScreenOffTime  = new int[] { h, m + 4 },
                    BusScreenOnTime    = new int[] { h, m + 4 },
                    BusScreenOffTime   = new int[] { h, m + 5 },
                    RebootTime         = new int[] { h, m + 2 }
                });

                d.write("Schedule reset due to function test.");
                break;

            case Key.D5:
                Process.Start(base_.PWD + "/gajwa-businfo.exe");
                Environment.Exit(0);
                break;

            case Key.D6:
                ArduinoSerialControl.ToggleTVpower();
                break;

            case Key.D7:
                MessageBox.Show("WIP");
                break;
            }
        }
Пример #2
0
        private void ScheduleChangedThread(ScheduleChangedEventArgs e)
        {
            if (e.EventType == ScheduleManager.ScheduleChangedEvents.Reboot)
            {
                base_.RebootComputer();
                return;
            }


            this.Dispatcher.Invoke(new de(() =>
            {
                if (LastPage != PageType.First)
                {
                    Pages[LastPage].Visibility = Visibility.Hidden;
                }

                switch (e.EventType)
                {
                case ScheduleManager.ScheduleChangedEvents.ScreenOn:
                    ArduinoSerialControl.ToggleTVpower();
                    break;

                case ScheduleManager.ScheduleChangedEvents.ScreenOff:
                    ArduinoSerialControl.ToggleTVpower();
                    break;

                case ScheduleManager.ScheduleChangedEvents.ClockScreenOn:
                    Pages[PageType.Clock] = new ClockPage();
                    LastPage     = PageType.Clock;
                    this.Content = Pages[PageType.Clock];
                    break;

                case ScheduleManager.ScheduleChangedEvents.FoodScreenOn:
                    Pages[PageType.Food] = new FoodInfoPage();
                    LastPage             = PageType.Food;
                    this.Content         = Pages[PageType.Food];

                    break;

                case ScheduleManager.ScheduleChangedEvents.BusScreenOn:
                    Pages[PageType.Bus] = new BusInfoPage();
                    LastPage            = PageType.Bus;
                    this.Content        = Pages[PageType.Bus];
                    break;

                default:

                    if (LastPage == OffEventTypes[e.EventType])
                    {
                        Pages[PageType.Blank] = new BlankPage();
                        LastPage     = PageType.Blank;
                        this.Content = Pages[PageType.Blank];
                    }
                    break;
                }
            }));
        }
Пример #3
0
        public App()
        {
            Console.WriteLine("BUSINFO-GAJWA v2.0\nbased on selenium.webdriver");
            Console.WriteLine(
                "IMPORTANT: If the developer had already been graduated from gajwa highschool, \n" +
                "or if you're trying to maintain the program without the developer, \n" +
                "visit https://github.com/ssh9930/gajwa-businfo for more information. ");



            /////
            /////
            /////
            ///

            d.write("gajwa-businfo launch");
            d.write("checking vital files");

            string[] vitalFiles          = new string[] { "057-average.txt", "buslist.txt", "schedule.txt" };
            string   vitalFileChkFailMsg = "Vital file missing: ";
            bool     vitalFileChk        = true;

            foreach (string i in vitalFiles)
            {
                if (!File.Exists(base_.PWD + "/" + i))
                {
                    vitalFileChkFailMsg += i + ", ";
                    vitalFileChk         = false;
                }
            }

            if (!vitalFileChk)
            {
                Process.Start(base_.ERR_PROGRAM_LOCATION, vitalFileChkFailMsg.Replace("\n", "\\n"));
            }

            base_.LoadSchedules();
            base_.Update057Average(0, true);
            base_.UpdateBusShowList();


            /////
            /////
            /////
            ///

            int cntdown = base_.NETWORK_CHECK_TIMEOUT_SEC;

            while (!base_.IsNetworkAvailable())
            {
                if (cntdown <= 0)
                {
                    d.write("Network check timeout, terminating.");
                    Environment.Exit(1);
                }

                cntdown -= 1;
                Thread.Sleep(1000);
            }

            ////
            ////
            ///

            ArduinoSerialControl.OpenConnection(base_.ARDUINO_SERIAL_COMPORT);
        }