private void refreshVideoDetail() { String filePath = currentLessonModel.videoMainJsonFilePath; String jsonString = FileHandle.readJsonFile(filePath); currentMainVideoModel = (MainVideoModel)JSONHandle.getObjFromJson <MainVideoModel>(jsonString); if (currentMainVideoModel == null) { currentMainVideoModel = new MainVideoModel(); } else { mainVideoTItletextBox1.Text = currentMainVideoModel.videoTitle; lessonIntroTextBox.Text = currentMainVideoModel.videoLessonIntro; videoDetialLabel.Text = "第" + (currentLessonModel.orderNum + 1) + "课"; } String zqfilePath = currentLessonModel.videoZhengJueJsonFilePath; String zqjsonString = FileHandle.readJsonFile(zqfilePath); List <ItemVideoModel> zqList = (List <ItemVideoModel>)JSONHandle.getObjFromJson <List <ItemVideoModel> >(zqjsonString); if (zqList == null) { return; } foreach (ItemVideoModel m in zqList) { zhengQueVideoList.Add(m); } refreshZhengQueVideoListView(); String cwfilePath = currentLessonModel.videoCuoWuJsonFilePath; String cwjsonString = FileHandle.readJsonFile(cwfilePath); List <ItemVideoModel> cwList = (List <ItemVideoModel>)JSONHandle.getObjFromJson <List <ItemVideoModel> >(cwjsonString); if (cwList == null) { return; } foreach (ItemVideoModel m in cwList) { zhengQueVideoList.Add(m); } refreshCuoWuVideoListView(); }
public void initData() { String cPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\滑雪数据\\jsonData\\"; switch (type) { case LType.LTypeErTongShuangBan: { commonPath = cPath + "er_tong_shuang_ban_jiao_cheng\\"; jsonFileLocalPath = commonPath + "lesson_json_er_tong_shuang_ban.txt"; } break; case LType.LTypeChengRenShuangBan: { commonPath = cPath + "cheng_ren_shuang_ban_jiao_cheng\\"; jsonFileLocalPath = commonPath + "lesson_json_cheng_ren_shuang_ban.txt"; } break; case LType.LTypeErtongDanBan: { commonPath = cPath + "er_tong_dan_ban_jiao_cheng\\"; jsonFileLocalPath = commonPath + "lesson_json_er_tong_dan_ban.txt"; } break; case LType.LTypeChengRenDanBan: { commonPath = cPath + "cheng_ren_dan_ban_jiao_cheng\\"; jsonFileLocalPath = commonPath + "lesson_json_cheng_ren_dan_ban.txt"; } break; } String filePath = jsonFileLocalPath; String jsonString = FileHandle.readJsonFile(filePath); List <LessonModel> lList = (List <LessonModel>)JSONHandle.getObjFromJson <List <LessonModel> >(jsonString); if (lList == null) { return; } foreach (LessonModel m in lList) { lessonList.Add(m); } }
//添加主视频 private void addMainVideoBtn_Click(object sender, EventArgs e) { if (null == currentLessonModel) { MessageBox.Show("请先选择课程"); return; } AddEditMainVideoForm frm = new AddEditMainVideoForm(currentLessonModel, currentMainVideoModel); if (frm.ShowDialog() == DialogResult.OK)//对话框返回值为ok时运行 { String filePath = currentLessonModel.videoMainJsonFilePath; String jsonString = JSONHandle.getJsonString(currentMainVideoModel); FileHandle.saveJsonFile(filePath, jsonString); refreshVideoDetail(); } }
//添加课程 private void button5_Click(object sender, EventArgs e) { LessonModel lessonModel = new LessonModel(moduleModel.type, moduleModel.lessonList.Count); //lessonModel.type = moduleModel.type; // lessonModel.orderNum = moduleModel.lessonList.Count; LessonDetailForm frm = new LessonDetailForm(lessonModel, moduleModel, LessonDetailType.LessonDetailTypeAdd); if (frm.ShowDialog() == DialogResult.OK)//对话框返回值为ok时运行 { moduleModel.lessonList.Add(lessonModel); refreshLessonListView(); String jsonString = JSONHandle.getJsonString(moduleModel.lessonList); //MessageBox.Show("jsonString:" + jsonString); String filePath = moduleModel.jsonFileLocalPath; FileHandle.saveJsonFile(filePath, jsonString); } }
private void lessonListView_MouseDoubleClick(object sender, MouseEventArgs e) { ListView.SelectedIndexCollection c = lessonListView.SelectedIndices; if (c.Count > 0) { //MessageBox.Show("index:"+c[0]); int index = c[0]; LessonModel lessonModel = (LessonModel)moduleModel.lessonList[index]; LessonDetailForm frm = new LessonDetailForm(lessonModel, moduleModel, LessonDetailType.LessonDetailTypeEdit); if (frm.ShowDialog() == DialogResult.OK)//对话框返回值为ok时运行 { moduleModel.lessonList.Add(lessonModel); refreshLessonListView(); String jsonString = JSONHandle.Obj2Json(moduleModel.lessonList); //MessageBox.Show("jsonString:"+jsonString); String filePath = moduleModel.jsonFileLocalPath; FileHandle.saveJsonFile(filePath, jsonString); } } }