コード例 #1
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");
        }
コード例 #2
0
        private void ReleaseManagedResources()
        {
            SaveSettings();

            //Release managed resources
            foreach (NAudioPlayerWrapper ptrPlayer in Characters.Values)
            {
                ptrPlayer.Dispose();
            }
            Characters.Clear();
            Cards.Dispose(); Cards = null;
            OptionDialog.Dispose(); OptionDialog = null;

            if (SelectedLayout != null)
            {
                SelectedLayout.Close();
                SelectedLayout = null;
            }
        }
コード例 #3
0
        private bool SelectLesson()
        {
            SelectedLesson               = string.Empty;
            OptionDialog                 = new SelectionDialog();
            OptionDialog.Text            = "Select Lessons";
            OptionDialog.ShowDescription = true;
            OptionDialog.ItemsBackColor  = Color.LightSkyBlue;
            OptionDialog.ItemsForeColor  = Color.DarkBlue;

            if (Directory.Exists(LessonBasePath))
            {
                Debug.WriteLine("Loading lessons from " + LessonBasePath);
                string[] lessonFolders = Directory.GetDirectories(LessonBasePath);
                Dictionary <string, string> lessons = new Dictionary <string, string>();
                foreach (string ptrPath in lessonFolders)
                {
                    //Skip hidden folders
                    DirectoryInfo ptrDir = new DirectoryInfo(ptrPath);
                    if ((ptrDir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
                    {
                        continue;
                    }
                    lessons.Add(ptrPath.Replace(LessonBasePath, ""), ptrPath);
                }

                Debug.WriteLine("Found " + lessons.Count.ToString() + " lessons.");
                foreach (string ptrKey in lessons.Keys)
                {
                    Debug.WriteLine("> " + ptrKey.ToString());
                }

                //Select lesson
                SelectionDialogItem ptrMenuItem;
                OptionDialog.ClearItems();
                foreach (string ptrItem in lessons.Keys)
                {
                    ptrMenuItem = OptionDialog.AddItem(ptrItem);
                    if (Directory.GetFiles(LessonBasePath + ptrItem).Length == 0)
                    {
                        OptionDialog.DisableItem(ptrItem);
                    }
                    else
                    {
                        string[] files = Directory.GetFiles(LessonBasePath + ptrItem);
                        foreach (string ptrFile in files)
                        {
                            if (IsImageTypeSupported(ptrFile))
                            {
                                continue;
                            }
                            ptrMenuItem.DescriptionImage = Image.FromFile(ptrFile);
                            break;
                        }
                    }
                }
            }

            //Add additional system menu
            OptionDialog.AllowToCancel    = true;
            OptionDialog.CancelButtonText = "Back to Main Menu";

            SelectedLesson = null;
            if (OptionDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SelectedLesson = OptionDialog.SelectedItem;
                LoadSelectedLesson();
                CaseSensitive = false;
                return(true);
            }
            return(false);
        }