コード例 #1
0
 public void Load()
 {
     try { if (Image == null)
           {
               Image = Image.FromFile(ImagePath);
           }
     }
     catch { Image = null; Debug.WriteLine("Unable to load image for " + Name); }
     try
     {
         if (Audio == null)
         {
             string[] SupportedAudioFileType = { ".mp3", ".wav" };
             foreach (string ext in SupportedAudioFileType)
             {
                 if (File.Exists(AudioPath + ext))
                 {
                     Audio = new NAudioPlayerWrapper(AudioPath + ext);
                     Audio.Load();
                     return;
                 }
             }
             Debug.WriteLine("Audio not exists " + Name);
         }
     }
     catch { Audio = null; Debug.WriteLine("Unable to load audio for " + Name); }
 }
コード例 #2
0
        public Layout_02(FlashCardController controller)
        {
            InitializeComponent();
            MainPicture.SizeMode = PictureBoxSizeMode.Zoom;
            Controller           = controller;
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            Controller.LessonLoaded += new EventHandler(Controller_LessonLoaded);
            Controller.MenuLoad     += new EventHandler(Controller_MenuLoad);
            BtMenu.Text              = "Menu";
            lbCardCounter.Text       = string.Empty;

            BackColor = Color.Transparent;
            Options   = new OptionButton[] { optionButton1, optionButton2, optionButton3, optionButton4 };
            InitializeControls();

            WrongAnswerSound   = TryLoadSound("WrongAnswer.mp3");
            CorrectAnswerSound = TryLoadSound("CorrectAnswer.mp3");

            tbResults.ColumnHeadersVisible = false;
            tbResults.Rows.Clear();

            Synth        = new SpeechSynthesizer();
            Synth.Volume = 100;
            Synth.Rate   = -5;
        }
コード例 #3
0
        private void Initialize()
        {
            Cards        = new FlashCardCollection();
            OptionDialog = new SelectionDialog();
            UseThread    = true;

            SpellingModeHintInterval        = 5000;
            SpellingModeHintIntervalInitial = 1000;

            CodeProfiler.Start("Load Characters");
            Debug.WriteLine("Loading characters audio...");
            string soundPath = RootPath + "\\System\\Characters\\";

            Characters = new Dictionary <char, NAudioPlayerWrapper>();
            for (char tChar = 'A'; tChar <= 'Z'; tChar++)
            {
                try
                {
                    string audioFile = soundPath + "Char_" + tChar.ToString() + ".mp3";
                    if (File.Exists(audioFile))
                    {
                        NAudioPlayerWrapper charPlayer = new NAudioPlayerWrapper(audioFile);
                        charPlayer.Load();
                        Characters.Add(tChar, charPlayer);
                    }
                    Debug.WriteLine("WARNING: Audio file for char " + tChar + "not found!");
                }
                catch
                {
                    Debug.WriteLine("WARNING: Unable to load audio file for char " + tChar);
                }
            }
            CodeProfiler.Stop("Load Characters");
        }
コード例 #4
0
 private NAudioPlayerWrapper TryLoadSound(string fileName)
 {
     try
     {
         NAudioPlayerWrapper audio = new NAudioPlayerWrapper(".\\System\\" + fileName);
         audio.Load();
         return(audio);
     }
     catch { return(null); }
 }