public MusicList(Settings settings, SongRules rules) {
            if(rules != null) {
                Rules = rules;
            } else {
                throw new ArgumentNullException(nameof(rules));
            }
            AppSettings = settings;
            Random = new Random();

            ReadListFromDisc();

            Rules.OnChange += (s, a) => {
                FillSongLists();
            };
        }
        public RulesEdit(SongRules rules, MusicList allMusic) {
            if(rules != null) {
                Rules = rules;
            } else {
                throw new ArgumentNullException(nameof(rules));
            }

            if(allMusic != null) {
                AllMusic = allMusic;
            } else {
                throw new ArgumentNullException(nameof(allMusic));
            }

            InitializeComponent();
            SetupLists();
        }
示例#3
0
        private void Init() {
            string rulesPath;
            if(AppSettings.TryGetSetting("SongRulesPath", out rulesPath) && !string.IsNullOrEmpty(rulesPath)) {
                CurrentSongRules = SettingsFile.ReadSettingFile<SongRules>(rulesPath);

                if(CurrentSongRules == null) {
                    File.Delete(rulesPath);
                    CurrentSongRules = new SongRules(rulesPath);
                }
            } else {
                MessageBox.Show("Error: RulesPath setting is empty");
                return;
            }

            MusicCollection = new MusicList(AppSettings, CurrentSongRules);
            WriteLine($"Loaded {MusicCollection.ActiveSongs.Count()} songs");

            string playerPath;
            if(AppSettings.TryGetSetting("PlayerPath", out playerPath) && !string.IsNullOrEmpty(playerPath)) {
                SpeechControll = new SpeechInput(AppSettings, MusicCollection, playerPath);
            } else {
                MessageBox.Show("Error: PlayerPath setting is empty");
                return;
            }

            foreach(var word in SpeechControll.Keywords) {
                Write(word + ", ");
            }
            WriteLine("Possible: ");

            UpdateSuggestions();

            SpeechControll.MessageSend += (s) => {
                Action<string> update = WriteLine;
                Invoke(update, s);
            };
            CurrentSongRules.OnChange += (s, a) => {
                Action update = UpdateSuggestions;
                Invoke(update);
            };
            MusicCollection.SongListUpdated += (s, a) => {
                Action update = UpdateSuggestions;
                Invoke(update);
            };
            new MessageOverlay("SpeechMusicController is listening!", 1500).Show();
        }