public static void SaveProperty(this Control control, string propertyName) { if (control == null) { return; } string directory = Directories.Create(@"Asmodat\Extensions.Windows.Forms.ControlEx").FullName; string fileName = Files.RemoveInvalidFilenameCharacters(control.GetFullPathName()); string path = directory + @"\" + fileName + ".adbs"; DatabseSimpleton dbs = new DatabseSimpleton(path, false); object value = control.GetType().GetProperty(propertyName).GetValue(control, null); dbs.Set(propertyName, value); dbs.Save(); }
public void StartTraining() { string[] files = this.GetFiles(1); if (files == null || files.Length <= 0) { return; } foreach (string file in files) { string name = null; List <int> numbers = new List <int>(); try { name = Path.GetFileNameWithoutExtension(file); if (LoadedFiles.Contains(name)) { continue; } for (int i = 0; i < name.Length; i++) { if (!Char.IsNumber(name[i])) { break; } numbers.Add(int.Parse(name[i].ToString())); } } catch { continue; } if (numbers.Count <= 0) { continue; } int[] words_split = Asmodat.Audio.Converter.GetMp3WordsSplit(file, numbers.Count); string[] temp_files = new string[numbers.Count]; for (int i = 0; i < temp_files.Length; i++) { temp_files[i] = string.Format("{0}\\temp\\audio{1}-{2}.wav", Directory, (i + 1), TickTime.NowTicks); } Asmodat.Audio.Converter.Mp3Split(file, words_split, temp_files, true); for (int i = 0; i < temp_files.Length; i++) { Dictionary <string, double> result = recognition.RecognizeWAV(temp_files[i]); this.Learn(name, numbers[i], result); } for (int i = 0; i < temp_files.Length; i++) { if (System.IO.File.Exists(temp_files[i])) { System.IO.File.Delete(temp_files[i]); } } Database.Save(); } }