using Common.system; using System; using System.Windows; using System.Windows.Forms; using System.Windows.Input; namespace XHWK.WKTool { /// /// 创建微课 /// public partial class CreateAMicroLessonWindow : Window { #region 字段 private FolderBrowserDialog ofd; private DialogResult result; #endregion /// /// 创建微课 /// public CreateAMicroLessonWindow() { InitializeComponent(); txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath"); } #region 事件 /// /// 关闭 /// /// /// private void BtnDown_Click(object sender, RoutedEventArgs e) { MessageBoxResult dr = System.Windows.MessageBox.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel); if (dr == MessageBoxResult.OK) { System.Environment.Exit(0); } else { return; } } /// /// 浏览 /// /// /// private void BtnBrowse_Click(object sender, RoutedEventArgs e) { string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); ofd = new System.Windows.Forms.FolderBrowserDialog(); result = ofd.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { if (ofd.SelectedPath != "") { txbStoragePath.Text = ofd.SelectedPath; //string ApplicationData = ZConfig.dataPath + "fileStorageAddress.txt"; //string temp = ofd.SelectedPath; //System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default); } } } /// /// 开始 /// /// /// private void BtnStart_Click(object sender, RoutedEventArgs e) { #region 合法性判断 if (string.IsNullOrWhiteSpace(txbExplainName.Text.Trim())) { System.Windows.MessageBox.Show("讲解名称不可为空!"); return; } if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim())) { System.Windows.MessageBox.Show("路径不可为空!"); return; } #endregion string wkpath=FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim()+"/"; //读取微课数据 APP.ReadWkData(wkpath); if(APP.WKData==null) { APP.WKData = new Model.Model_WKData(); APP.WKData.WkPath = wkpath; APP.WKData.WkName = txbExplainName.Text; APP.WKData.WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); } //创建文件夹 FileToolsCommon.CreateDirectory(APP.WKData.WkPath); //存储文件 FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Text); APP.ReadDrawData(); #region 微课不允许有多个视频 废弃 ////判断微课是否存在,存在则询问 //if (APP.WKDataList != null&& APP.WKDataList.Count>0) //{ // if (APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName)) // { // MessageBoxResult dr = System.Windows.MessageBox.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel); // if (dr == MessageBoxResult.OK) // { // FileToolsCommon.DeleteDirectory(APP.WKData.WkPath); // FileToolsCommon.CreateDirectory(APP.WKData.WkPath); // APP.WKDataList.RemoveAll(x => x.WkName == APP.WKData.WkName); // } // else // { // return; // } // } //} #endregion if (APP.W_XHMicroLessonSystemWindow == null) { APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow(); //APP.W_XHMicroLessonSystemWindow .Topmost = true; } APP.W_XHMicroLessonSystemWindow.Show(); this.Hide(); } /// /// 窗体移动 /// /// /// private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { DragMove(); } #endregion } }