123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- using Common.system;
-
- using System;
- using System.Windows;
- using System.Windows.Forms;
- using System.Windows.Input;
-
- namespace XHWK.WKTool
- {
- /// <summary>
- /// 创建微课
- /// </summary>
- public partial class CreateAMicroLessonWindow : Window
- {
- #region 字段
- private FolderBrowserDialog ofd;
- private DialogResult result;
- #endregion
-
- /// <summary>
- /// 创建微课
- /// </summary>
- public CreateAMicroLessonWindow()
- {
- InitializeComponent();
- txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
- }
-
- #region 事件
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnDown_Click(object sender, RoutedEventArgs e)
- {
- System.Environment.Exit(0);
- }
- /// <summary>
- /// 浏览
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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);
- }
- }
- }
- /// <summary>
- /// 开始
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- //if (!FileToolsCommon.IsLegalPath(txbStoragePath.Text.Trim(), out string ErrMessage))
- //{
- // System.Windows.MessageBox.Show(ErrMessage);
- // return;
- //}
- APP.WKData.WkPath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
- if (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath))
- {
- //微课已存在
- MessageBoxResult dr = System.Windows.MessageBox.Show("讲解已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
- if (dr == MessageBoxResult.OK)
- {
- FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
- }
- else
- {
- return;
- }
- }
- #endregion
- //创建文件夹
- FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
- //存储文件
- FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Text);
- APP.WKData.WkName = txbExplainName.Text;
- APP.WKData.WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
- if (APP.W_XHMicroLessonSystemWindow == null)
- {
- APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
- //APP.W_XHMicroLessonSystemWindow .Topmost = true;
- }
- APP.W_XHMicroLessonSystemWindow.Show();
- this.Hide();
- }
- /// <summary>
- /// 窗体移动
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- DragMove();
- }
- #endregion
- }
- }
|