コード例 #1
0
ファイル: NemoAdProcessor.cs プロジェクト: nat2k5us/mmkay
 public NemoAdProcessor(
     ScreenShotsManager screenShotsManager,
     List <Bitmap> toFindBitmaps,
     List <Bitmap> clickDotBitmap,
     List <Bitmap> closeBitmaps,
     int displayIndex,
     bool fakeMoves,
     Dispatcher cd)
 {
     this.screenShotsManager = screenShotsManager;
     this.toFindBitmaps      = toFindBitmaps;
     this.clickDotBitmap     = clickDotBitmap;
     this.closeBitmaps       = closeBitmaps;
     this.fakeMoves          = fakeMoves;
     this.DisplayScreen      = DisplayIndex.GetDisplayRectangle(displayIndex);
     this.StopAllProcessing  = false;
     this.currentDispatcher  = cd;
     Logger.Info($"{MethodBase.GetCurrentMethod().Name} - Finished Initialization");
 }
コード例 #2
0
        public ClixSenseAdProcessor(
            ScreenShotsManager screenShotsManager,
            List <Bitmap> toFindBitmaps,
            Dictionary <string, Bitmap> catBitmaps,
            List <Bitmap> closeBitmaps,
            int displayIndex,
            int zoomFactorX,
            int zoomFactorY,
            bool fakeMoves,
            Dispatcher cd)
        {
            this.screenShotsManager = screenShotsManager;
            this.toFindBitmaps      = toFindBitmaps;
            this.closeBitmaps       = closeBitmaps;
            this.catBitmaps         = catBitmaps;
            this.fakeMoves          = fakeMoves;
            this.zoomFactorX        = zoomFactorX;
            this.zoomFactorY        = zoomFactorY;
            this.CaptureCatImage    = false;
            this.StopAllProcessing  = false;
            this.DisplayScreen      = DisplayIndex.GetDisplayRectangle(displayIndex);
            this.clixConfig         = new ClixSenseAdProcessorConfig();
            if ((this.clixConfig = this.clixConfig.Load($".\\ClixSenseAdProcessorConfig" + ".xml")) == null)
            {
                this.clixConfig = new ClixSenseAdProcessorConfig();
                this.clixConfig.Save($".\\ClixSenseAdProcessorConfig" + ".xml");
                Logger.Info($"Saved {nameof(this.clixConfig)} correctly : {this.clixConfig}");
            }
            else
            {
                Logger.Info($"Loaded {nameof(this.clixConfig)} correctly : {this.clixConfig}");
            }

            this.currentDispatcher = cd;
            //this.TalkingCool = new Talking();
            Logger.Info($"ClickSense initialize - Trying to initialize speech ");
            try
            {
                this.installedVoices    = new List <InstalledVoice>(this.synthesizer.GetInstalledVoices());
                this.synthesizer.Volume = 100; // 0...100
                this.synthesizer.Rate   = -2;  // -10...10
                this.synthesizer.SelectVoice(this.installedVoices.First().VoiceInfo.Name);
                var numbers = new Choices();
                numbers.Add("one", "two", "three", "four", "five", "Refresh", "Close"); //, "Close"
                // Create a GrammarBuilder object and append the Choices object.
                var gb = new GrammarBuilder();
                gb.Append(new GrammarBuilder(numbers), 1, 5);
                var grammer = new Grammar(gb)
                {
                    Priority = 127
                };
                this.speechRecognitionEngine.RequestRecognizerUpdate();
                this.speechRecognitionEngine.LoadGrammar(grammer);
                this.speechRecognitionEngine.SetInputToDefaultAudioDevice();
                this.speechRecognitionEngine.SpeechRecognized          += this.SpeechRecognitionEngine_SpeechRecognized;
                this.speechRecognitionEngine.SpeechDetected            += this.SpeechRecognitionEngine_SpeechDetected;
                this.speechRecognitionEngine.SpeechRecognitionRejected += this.SpeechRecognitionEngine_SpeechRecognitionRejected;
                this.speechRecognitionEngine.RecognizeCompleted        += this.SpeechRecognitionEngine_RecognizeCompleted;
            }
            catch (Exception exception)
            {
                Logger.Error(exception.Message + exception.InnerException?.Message);
                throw exception;
            }
            Logger.Info($" Finished audio Initializer with no exceptions - found {this.installedVoices.Count} voices");
        }