123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- using Common.system;
-
- using System;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Forms;
- using System.Windows.Input;
-
- using XHWK.Model;
- using XHWK.WKTool.Skin;
-
- namespace XHWK.WKTool
- {
- /// <summary>
- /// 创建微课
- /// </summary>
- public partial class CreateAMicroLessonWindow : Window
- {
- #region 字段
-
- private FolderBrowserDialog ofd;
- private DialogResult result;
-
- #endregion 字段
-
- /// <summary>
- /// 创建微课
- /// </summary>
- public CreateAMicroLessonWindow()
- {
- InitializeComponent();
- ResizeMode = ResizeMode.NoResize;
-
- //if (!APP.CheckScreenCapturerRecorder())
- //{
- // MessageWindow.Show("首次运行需安装环境,请在确定后依次点击“English-OK-Next>-Next>Install”完成安装!");
- // //APP.InstallScreenCapturerRecorder();
- //}
- txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
- //APP.FFmpeg.GetMToFFmpeg();
-
- LoadingCarouseImg();
- }
-
- #region 轮播图
-
- /// <summary>
- /// 图片宽度,每次切换的宽度
- /// </summary>
- private double ImgWidth = 502.00;
-
- /// <summary>
- /// 轮播时移动增加的宽度
- /// </summary>
- private double ImgMove = 1;
-
- /// <summary>
- /// 当前展示的图片序号Index从0开始
- /// </summary>
- private int ImgNumIndex = 0;
-
- /// <summary>
- /// 加载录播图
- /// </summary>
- private void LoadingCarouseImg()
- {
- new Thread(new ThreadStart(new Action(() =>
- {
- Thread.Sleep(3000);
- Dispatcher.Invoke(() =>
- {
- ImgWidth = ImgCarouse1.ActualWidth;
- ImgMove = ImgWidth / 250.00;
- CarouseImg();
- //timesCarouse = new System.Timers.Timer(2000);
- //timesCarouse.Elapsed += TimesCarouse_Elapsed; ;
- //timesCarouse.Start();
- });
- }))).Start();
- }
-
- /// <summary>
- /// 轮播图
- /// </summary>
- private void CarouseImg()
- {
- new Thread(new ThreadStart(new Action(() =>
- {
- while (true)
- {
- for (double i = ImgMove; i < ImgWidth; i += ImgMove)
- {
- Dispatcher.Invoke(() =>
- {
- if (Math.Abs(i + ImgMove) < ImgWidth)
- {
- //图片移动轮播
- SplCarouse.Margin = new Thickness(SplCarouse.Margin.Left - ImgMove, 0, 0, 0);
- }
- else
- {
- if (ImgNumIndex >= 2)
- {
- ImgNumIndex = 0;
- SplCarouse.Margin = new Thickness(0, 0, 0, 0);
- }
- else
- {
- ImgNumIndex++;
- SplCarouse.Margin = new Thickness(-(ImgNumIndex * ImgWidth), 0, 0, 0);
- }
- }
- });
- Thread.Sleep(3);
- }
- bool IsBreak = false;
- Dispatcher.Invoke(() =>
- {
- if (this.Visibility != Visibility.Visible)
- {
- SplCarouse.Margin = new Thickness(0);
- IsBreak = true;
- }
- });
- Thread.Sleep(5000);
- if (IsBreak)
- {
- break;
- }
- }
- }))).Start();
- }
-
- /// <summary>
- /// 轮播图切换
- /// </summary>
- /// <param name="sender">
- /// </param>
- /// <param name="e">
- /// </param>
- private void TimesCarouse_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
- {
- //SplCarouse
- //ImgCarouse1
- }
-
- #endregion 轮播图
-
- #region 事件
-
- /// <summary>
- /// 关闭
- /// </summary>
- /// <param name="sender">
- /// </param>
- /// <param name="e">
- /// </param>
- private void BtnDown_Click(object sender, RoutedEventArgs e)
- {
- MessageBoxResult dr = MessageWindow.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
- if (dr == MessageBoxResult.OK)
- {
- System.Environment.Exit(0);
- }
- else
- {
- return;
- }
- }
-
- /// <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 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 bool IsPressButton = false;
-
- /// <summary>
- /// 开始
- /// </summary>
- /// <param name="sender">
- /// </param>
- /// <param name="e">
- /// </param>
- private async void BtnStart_Click(object sender, RoutedEventArgs e)
- {
- #region 防止连击
-
- if (IsPressButton)
- {
- return;
- }
- else
- {
- IsPressButton = true;
- new Thread(new ThreadStart(new Action(() =>
- {
- Thread.Sleep(500);
- IsPressButton = false;
- }))).Start();
- }
-
- #endregion 防止连击
-
- #region 合法性判断
-
- if (string.IsNullOrWhiteSpace(txbExplainName.Text.Trim()))
- {
- MessageWindow.Show("讲解名称不可为空!");
- return;
- }
- if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
- {
- MessageWindow.Show("路径不可为空!");
- return;
- }
- try
- {
- FileToolsCommon.CreateDirectory(txbStoragePath.Text.Trim());
- }
- catch (Exception ex)
- {
- MessageWindow.Show("路径无法访问,解决方案:\r\n1,检查路径是否可访问。\r\n2,关闭杀毒软件或信任软件。");
- return;
- }
-
- #endregion 合法性判断
-
- LblCreate.Visibility = Visibility.Visible;
- string wkpath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
- string StoragePath = txbStoragePath.Text;
- string WkName = txbExplainName.Text;
- await Task.Run(() =>
- {
- try
- {
- //读取微课数据
- APP.ReadWkData(wkpath);
- if (APP.WKData == null)
- {
- APP.WKData = new Model_WKData
- {
- WkPath = wkpath,
- WkName = WkName,
- WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
- };
- }
-
- try
- {
- //创建文件夹
- FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
- FileToolsCommon.DeleteDirectory(wkpath + "temp");
- FileToolsCommon.DeleteDirectory(wkpath + "temprs");
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【微课创建课程】文件夹创建删除失败:" + ex.Message, ex);
- }
-
- //存储文件
- FileToolsCommon.SetConfigValue("VideoSavePath", StoragePath);
-
- APP.ReadDrawData();
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【微课创建课程】读取课堂数据失败:" + ex.Message, ex);
- }
- });
-
- if (APP.W_XHMicroLessonSystemWindow == null)
- {
- APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
- }
- APP.W_XHMicroLessonSystemWindow.Show();
- LblCreate.Visibility = Visibility.Hidden;
- Hide();
- }
-
- private double screeHeight = SystemParameters.FullPrimaryScreenHeight;
- private double screeWidth = SystemParameters.FullPrimaryScreenWidth;
-
- /// <summary>
- /// 窗体移动
- /// </summary>
- /// <param name="sender">
- /// </param>
- /// <param name="e">
- /// </param>
- private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
- DragMove();
- }
-
- #endregion 事件
-
- /// <summary>
- /// 检测APP更新
- /// </summary>
- private void getNewApp()
- {
- new Thread(o =>
- {
- //读取本地
- APP.ReadServiceAddressData();
- int versionThis = int.Parse(FileToolsCommon.GetConfigValue("VersionCode"));
- if (versionThis < 0)
- {
- //软件是否更新,版本号小于0不更新
- return;
- }
- string url = APP.apiUrl + "/apprecord/get_new";
-
- string result = HttpHelper.PostAndRespStr(url, "{}");
- Model.ResultVo<Model_App> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_App>>(result);
- if (result != null && resultObj.code == 0)
- {
- if (resultObj.obj != null)
- {
- try
- {
- int versionCode = resultObj.obj.versioncode;
- if (versionThis < versionCode)
- {
- Dispatcher.Invoke(new Action(() =>
- {
- string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
- FileToolsCommon.CreateDirectory(pathTemp);
- appUpdateShow(resultObj.obj);
- }));
- }
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("【检查更新】(getNewApp)版本号错误:" + ex.Message, ex);
- }
- }
- }
- }).Start();
- }
-
- /// <summary>
- /// 应用更新
- /// </summary>
- /// <param name="app">
- /// </param>
- private void appUpdateShow(Model_App app)
- {
- AppUpdateWin win = new AppUpdateWin(app)
- {
- Topmost = true,
- Owner = this
- };
- win.Show();
- }
-
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- getNewApp();
- }
- }
- }
|