Example #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;
            }
        }
Example #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;
                }
            }));
        }