/// <summary> /// 将设置的信息写到本地文件中 /// </summary> private void SaveJson() { //将模板信息写入本地文件中 string txt = textBox1.Text; File.WriteAllText(SetPath.FomartPath, txt); //获得各项数据 SetT setInfo = new SetT() { Count = AllField.PlayCount, Rate = (int)npSpd.Value, Time = AllField.AdvanceTime, Vol = (int)npVol.Value, Per = comboBox1.SelectedIndex, //(int)npPer.Value, Pit = (int)npPit.Value, PlayVol = AllField.PlayVol }; string json = js.Serialize(setInfo); File.WriteAllText(SetPath.SetTPath, json); }
private void SaveSomeSet() { //这里只保存播放音量,播放次数以及提前时间,其它的设置保存应该在"保存"按钮中保存 string jsonStr = File.ReadAllText(SetPath.SetTPath); SetT sets = js.Deserialize <SetT> (jsonStr); sets.Count = AllField.PlayCount; sets.Time = AllField.AdvanceTime; sets.PlayVol = AllField.PlayVol; string json = js.Serialize(sets); File.WriteAllText(SetPath.SetTPath, json); }
private void btnSave_Click_1(object sender, EventArgs e) { AllField.AdvanceTime = (int)npTime.Value; AllField.PlayCount = (int)npCount.Value; //这里只保存播放音量,播放次数以及提前时间,其它的设置保存应该在"保存"按钮中保存 string jsonStr = File.ReadAllText(SetPath.SetTPath); SetT set = js.Deserialize <SetT>(jsonStr); set.Count = AllField.PlayCount; set.Time = AllField.AdvanceTime; set.PlayVol = AllField.PlayVol; string json = js.Serialize(set); File.WriteAllText(SetPath.SetTPath, json); }
/// <summary> /// Button4_Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button4_Click(object sender, RoutedEventArgs e) { // check and indicate if T is subset of A SubsetIndicatorT = SetT.All(x => SetA.Contains(x)); if (SubsetIndicatorT) { Console.Beep(); } else { Console.Beep(); Console.Beep(); } // execute the LINQ commands IntersectionAB = new ObservableCollection <string>(SetA.Intersect(SetB)); UnionAB = new ObservableCollection <string>(SetA.Union(SetB)); RelativeComplementAB = new ObservableCollection <string>(SetA.Except(SetB)); }
private void ClearSets() { SetA.Clear(); SetB.Clear(); SetT.Clear(); if (IntersectionAB != null) { IntersectionAB.Clear(); } if (UnionAB != null) { UnionAB.Clear(); } if (RelativeComplementAB != null) { RelativeComplementAB.Clear(); } }
/// <summary> /// 读取配置文件信息并加载(如果存在) /// </summary> private void ReadSet() { //读取格式化信息 string fpStr = string.Empty; try { fpStr = File.ReadAllText(SetPath.FomartPath); } catch { } if (!string.IsNullOrEmpty(fpStr)) { //如果存在,则写入 textBox1.Text = fpStr; } //读取配置信息 string setJson = string.Empty; try { setJson = File.ReadAllText(SetPath.SetTPath); } catch { throw; } if (!string.IsNullOrEmpty(setJson)) { System.Web.Script.Serialization.JavaScriptSerializer js = new JavaScriptSerializer(); SetT sets = js.Deserialize <SetT>(setJson); //赋值 npCount.Value = sets.Count; npPit.Value = sets.Pit; npSpd.Value = sets.Rate; npTime.Value = sets.Time; npVol.Value = sets.Vol; comboBox1.SelectedIndex = sets.Per; } }
/// <summary> /// Button4_Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button4_Click(object sender, RoutedEventArgs e) { // check and indicate if T is subset of A SubsetIndicatorT = SetT.All(x => SetA.Contains(x, new KeyAndTimeComparer())); if (SubsetIndicatorT) { Console.Beep(); } else { Console.Beep(); Console.Beep(); } // execute the LINQ commands var ResultSet = SetA.Intersect(SetB, new KeyAndTimeComparer()); IntersectionAB = new ObservableCollection <KeyAndTime>(ResultSet.ToList <KeyAndTime>()); ResultSet = SetA.Union(SetB, new KeyAndTimeComparer()); UnionAB = new ObservableCollection <KeyAndTime>(ResultSet.ToList <KeyAndTime>()); ResultSet = SetA.Except(SetB, new KeyAndTimeComparer()); RelativeComplementAB = new ObservableCollection <KeyAndTime>(ResultSet.ToList <KeyAndTime>()); }
/// <summary> /// Button3_Click /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button3_Click(object sender, RoutedEventArgs e) { SetT.Add(Input); }
/// <summary> /// 测试按钮 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button2_Click(object sender, EventArgs e) { timer1.Enabled = true; if (GetPlayState != null) { bool playState = GetPlayState(); if (playState) { MessageBox.Show("正在播报中,不能测试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } if (play) { //点击了停止 //当前正在播报 play = false; button2.Text = "测试"; //当前是需要停止 axWindowsMediaPlayer1.Ctlcontrols.stop(); axWindowsMediaPlayer1.close(); if (File.Exists("测试.mp3")) { //删除测试 File.Delete("测试.mp3"); } return; } else { button2.Text = "停止"; play = true; } string text = textBox1.Text; //测试 //欢迎光临,$hallName,$movieName,$beginTime的电影已经开始了 if (text.Contains("$HallName")) { text = text.Replace("$HallName", "一号厅"); } if (text.Contains("$MovieName")) { text = text.Replace("$MovieName", "测试影片"); } if (text.Contains("$BeginTime")) { text = text.Replace("$BeginTime", "12:30"); } BaiduApiUser b = new BaiduApiUser(); //获得各项数据 SetT set = new SetT() { Count = (int)npCount.Value, Rate = (int)npSpd.Value, Time = (int)npTime.Value, Vol = (int)npVol.Value, Per = comboBox1.SelectedIndex, //(int)npPer.Value, Pit = (int)npPit.Value, }; var spd = set.Rate; //npSpd.Value; var vol = set.Vol; //npVol.Value; var per = set.Per; //npPer.Value; var pit = set.Pit; //npPit.Value; var option = new Dictionary <string, object>() { { "spd", spd }, // 语速 { "vol", vol }, // 音量 { "per", per }, // 发音人,4:情感度丫丫童声 { "pit", pit } }; string path = "测试.mp3"; bool reslut = b.Send(text, option, path); if (reslut) { axWindowsMediaPlayer1.URL = path; axWindowsMediaPlayer1.Ctlcontrols.play(); } }