コード例 #1
0
 private void NoActivityDetected()
 {
     //if (this.InvokeRequired)
     //{
     //    NoActivityDetectedDelegate del = new NoActivityDetectedDelegate(NoActivityDetected);
     //    object[] parameters = { };
     //    this.Invoke(del);
     //}
     //else
     //{
     if (_cabinetLights == CabinetLights.On && _lastMotionDetectedTime < DateTime.Now.AddSeconds(-1 * MOTIONTIMEOUT))
     {
         this.Opacity = 0;
         nusbioPixel?.AnalogWrite(Mcu.GpioPwmPin.Gpio5, 0);
         nusbioPixel?.SetStrip(Color.Beige, 20);
         _logger.LogInfo($"Turn Arcade Machine Off at {DateTime.Now}. _lastMotionDetectedTime: {_lastMotionDetectedTime}");
         _cabinetLights = CabinetLights.Off;
         _logger.LogVerbose("Cabinet lights were toggled off.");
     }
     //}
 }
コード例 #2
0
 private void ToggleCabinetLights()
 {
     if (nusbioPixel == null)
     {
         return;
     }
     if (_cabinetLights == CabinetLights.On)
     {
         _logger.LogVerbose("Cabinet lights are currently on. Turning them off.");
         //Color doesn't matter here...set the intensity to zero
         nusbioPixel?.SetStrip(70, 191, 238, 0);
         ToggleMarqueeLights();
         _cabinetLights = CabinetLights.Off;
     }
     else
     {
         _logger.LogVerbose("Cabinet lights are currently off. Turning them on.");
         nusbioPixel?.SetStrip(70, 191, 238, 64);
         ToggleMarqueeLights();
         _cabinetLights = CabinetLights.On;
     }
 }
コード例 #3
0
        public MainWindow()
        {
            KonamiCode[0]  = Key.R;
            KonamiCode[1]  = Key.R;
            KonamiCode[2]  = Key.F;
            KonamiCode[3]  = Key.F;
            KonamiCode[4]  = Key.D;
            KonamiCode[5]  = Key.G;
            KonamiCode[6]  = Key.D;
            KonamiCode[7]  = Key.G;
            KonamiCode[8]  = Key.A;
            KonamiCode[9]  = Key.S;
            KonamiCode[10] = Key.C;
            InitializeComponent();
            _cabinetLights = CabinetLights.Off;
            _rootDirectory = ConfigurationManager.AppSettings["rootDirectory"];
            _mameArgs      = ConfigurationManager.AppSettings["MAME_Args"];
            _logFile       = Path.Combine(_rootDirectory, "log.txt");
            _mameExe       = Path.Combine(_rootDirectory, "MAME64.EXE");
            _snapDirectory = Path.Combine(_rootDirectory, "snap");
            _snapshots     = new Dictionary <string, System.Windows.Media.ImageSource>();
            _gamesJson     = Path.Combine(_rootDirectory, "games.json");
            _supportCamera = Boolean.Parse(ConfigurationManager.AppSettings["Support_Camera"]);
            _supportNusbio = Boolean.Parse(ConfigurationManager.AppSettings["Support_Nusbio"]);
            JUMPDISTANCE   = Int32.Parse(ConfigurationManager.AppSettings["JUMPDISTANCE"]);
            _logger        = new Logger(_logFile);

            Boolean.Parse(ConfigurationManager.AppSettings["Support_Nusbio"]);
            string errorText;

            if (!File.Exists(_mameExe))
            {
                errorText = $"{_mameExe} does not exist.";
                MessageBox.Show(errorText, "Fatal Error");
                _logger.LogException(errorText, new Exception("MAME executable not found"));
                Environment.Exit(1);
            }
            else if (!File.Exists(_gamesJson))
            {
                GameListCreator glc = new GameListCreator();
                glc.GenerateGameList(_mameExe, _gamesJson, _snapDirectory);
            }
            else if (!Directory.Exists(_snapDirectory))
            {
                errorText = $"{_snapDirectory} does not exist.";
                MessageBox.Show(errorText, "Fatal Error");
                _logger.LogException(errorText, new Exception("Snap directory not found"));
                Environment.Exit(1);
            }

            Application.Current.MainWindow.Left = 0;
            Application.Current.MainWindow.Top  = 0;
            HideMouse();
            _logger.LogInfo("===============================================================================");
            _logger.LogInfo("Starting MAME");
            _logger.LogInfo("===============================================================================");
            Loaded += MainWindow_Loaded;

            _lastMotionDetectedTime = DateTime.Now.AddSeconds(20);

            if (_supportNusbio)
            {
                _whiteStripPWMIntensity = 254;

                nusbioPixel = ConnectToMCU(null, MAX_LED);
                if (nusbioPixel != null)
                {
                    _logger.LogVerbose("About to turn on the cabinet lights at the beginning.");
                    //FadeIn();
                    _logger.LogVerbose("Done with light initialization.");
                }
                //_logger.WriteToLogFile("FadeIn() complete");
                //PlaySound really only makes sense during the FadeIn sequence. If there are no lights, don't play the sound
                PlaySound("startup.wav");
                //_logger.WriteToLogFile("Intro sound was played");
            }


            #region Load games from disk and bind to the ListView
            LoadGamesFromJSON();
            lvGames.ItemsSource = GetUpdatedGameList();

            CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(lvGames.ItemsSource);
            lvGames.Focus();
            lvGames.SelectionMode = SelectionMode.Single;
            lvGames.SelectedIndex = 0;
            #endregion



            if (_supportCamera)
            {
                //Turn on the motion detection & voice recognition
                AForge.Controls.VideoSourcePlayer videoSourcePlayer2 = new AForge.Controls.VideoSourcePlayer();
                //            try
                //            {
                //                detector = GetDefaultMotionDetector();
                //                //videoSourcePlayer2.VideoSource = new VideoCaptureDevice(EnumerateVideoDevices().MonikerString);
                //                videoSourcePlayer2.NewFrame += Cam_NewFrame2;
                ////                videoSourcePlayer2.Start();
                //                //videoSourcePlayer2.Show();
                //                _localWebCam.Start();

                //            }
                //            catch (Exception ex)
                //            {
                //                //Do nothing. There is probably no webcam hooked up.
                //            }
                //this.LogRecognitionStart();
                //if (this.micClient == null)
                //{
                //    this.CreateMicrophoneRecoClient();
                //}
            }
        }