123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950 |
- using Common.system;
-
-
- using System;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics;
- using System.IO;
- using System.Threading;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Input;
- using System.Windows.Media;
-
-
- using XHZB.Desktop.Utils;
- using XHZB.Model;
-
-
- namespace XHZB.Desktop
- {
- /// <summary>
- /// 个人空间 LessonPreparationWindow.xaml 的交互逻辑
- /// </summary>
- public partial class UserCenterWindow : Window, DownloadUtil.DownloadCallback
- {
- private int serverReturnCode = 0;
- private readonly RegisterController registerController = new RegisterController();
- internal UserCenterPageData pageData = new UserCenterPageData();
- private bool isInitial = false;
- private Thread thread;
- private bool initialization = true;
- /// <summary>
- /// 下拉框数据源
- /// </summary>
- public DataTable data = new DataTable();
- /// <summary>
- /// 是否是下载状态 默认false 不是
- /// </summary>
- private bool isDownloadStatus = false;
- /// <summary>
- /// 教材关系表id
- /// </summary>
- private int Lsbid = 0;
- /// <summary>
- /// 章节id
- /// </summary>
- private int Directorid = 0;
- /// <summary>
- /// 资源分类1音频2视频3图片4文档
- /// </summary>
- private int Resourceclass = 0;
- /// <summary>
- /// 个人空间
- /// </summary>
- public UserCenterWindow()
- {
- InitializeComponent();
- DataContext = pageData;
- //初始化配置文件
- //ZJConfigUtil.init();
- isInitial = true;
- Resourceclass = 0;
- Lsbid = APP.REQStartClass.lsbid;
- Directorid = APP.REQStartClass.directorid;
- borAll.Background = new SolidColorBrush(Colors.DodgerBlue);
- borAudio.Background = new SolidColorBrush(Colors.Transparent);
- borVideo.Background = new SolidColorBrush(Colors.Transparent);
- borImage.Background = new SolidColorBrush(Colors.Transparent);
- borDoc.Background = new SolidColorBrush(Colors.Transparent);
- btnAll.Foreground = new SolidColorBrush(Colors.White);
- btnAudio.Foreground = new SolidColorBrush(Colors.Black);
- btnVideo.Foreground = new SolidColorBrush(Colors.Black);
- btnImage.Foreground = new SolidColorBrush(Colors.Black);
- btnDoc.Foreground = new SolidColorBrush(Colors.Black);
- initJiaocai();
- }
-
- private void initJiaocai()
- {
- System.Collections.Generic.List<TsubjectbookListModel> list = APP.TsubjectbookList;
- int selectIndex = 0;
- for (int i = 0; i < list.Count; i++)
- {
- TsubjectbookListModel book = list[i];
- if (book.lsbid == APP.lsbid)
- {
- selectIndex = i;
- }
- pageData.bookList.Add(new ComboBoxBeanModel()
- {
- Key = book.lsbid,
- Value = $"{book.subjectname} {book.bookname}"
- });
- }
- cmbClass.SelectedIndex = selectIndex;
- }
- /// <summary>
- /// 章节列表服务-调用
- /// </summary>
- /// <returns></returns>
- private object InvokeDirectorListServering()
- {
- APP.DirectorList = null;
- serverReturnCode = registerController.DirectorList(Lsbid,2,APP.LoginUser.userid);
- return APP.ErrorMessage;
- }
-
- /// <summary>
- /// 章节列表服务-返回结果
- /// </summary>
- /// <returns></returns>
- public void InvokeServerDirectorListCompate(object obj)
- {
- if (serverReturnCode == APP.ServerScuessCode)
- {
- if (!isInitial)
- {
- Directorid = 0;
- isInitial = false;
- }
- pageData.zhangjieList.Clear();
-
- pageData.zhangjieList.Add(new ChapterModel()
- {
- directorid = 0,
- directorname = "全部",
- level = 1,
- selected = 0
- });
- System.Collections.Generic.List<DirectorListModel> list = APP.DirectorList;
-
- for (int i = 0; i < list.Count; i++)
- {
- DirectorListModel item = APP.DirectorList[i];
-
- pageData.zhangjieList.Add(new ChapterModel()
- {
- directorid = item.directorid,
- directorname = item.directorname,
- level = item.directorlevel,
- selected = 0
- });
- addChild(item);
- }
- foreach (ChapterModel zhangjie in pageData.zhangjieList)
- {
- if (Directorid == zhangjie.directorid)
- {
- zhangjie.selected = 1;
- }
- else
- {
- zhangjie.selected = 0;
- }
- }
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
- }
- else
- {
- MessageWindow.Show(APP.ErrorMessage);
- }
- }
-
- private void addChild(DirectorListModel directorList)
- {
- if (directorList.children != null && directorList.children.Count > 0)
- {
- foreach (DirectorListModel child in directorList.children)
- {
- pageData.zhangjieList.Add(new ChapterModel()
- {
- directorid = child.directorid,
- directorname = getSpace(child.directorlevel) + child.directorname
- });
- if (child.children != null && child.children.Count > 0)
- {
- addChild(child);
- }
- }
- }
- }
-
- private string getSpace(int num)
- {
- string str = "";
- for (int i = 0; i < num; i++)
- {
- str += " ";
- }
- return str;
- }
-
- private void zhangjieClick(object sender, RoutedEventArgs e)
- {
- ChapterModel item = ((Button)sender).Tag as ChapterModel;
- foreach (ChapterModel zhangjie in pageData.zhangjieList)
- {
- if (item.directorid == zhangjie.directorid)
- {
- zhangjie.selected = 1;
- }
- else
- {
- zhangjie.selected = 0;
- }
- }
-
- Directorid = item.directorid;
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
- }
- /// <summary>
- /// 我的备课列表服务-调用
- /// </summary>
- /// <returns></returns>
- private object InvokeResourceMyListServering()
- {
- Dispatcher.Invoke(new Action(() =>
- {
- APP.myloading.Show();
- }));
-
- APP.ResourceMyList = null;
- serverReturnCode = registerController.ResourceMyList(Lsbid, Directorid, Resourceclass);
- return APP.ErrorMessage;
- }
-
- /// <summary>
- /// 我的备课列表服务-返回结果
- /// </summary>
- /// <returns></returns>
- public void InvokeServerResourceMyListCompate(object obj)
- {
- Dispatcher.Invoke(new Action(() =>
- {
- APP.myloading.Hide();
- }));
-
- if (serverReturnCode == APP.ServerScuessCode)
- {
- if (pageData.menuList.Count > 0)
- {
- pageData.menuList.Clear();
- DataContext = pageData;
- }
-
- if (APP.ResourceMyList.obj != null)
- {
- System.Collections.Generic.List<string> resource = new System.Collections.Generic.List<string>();
- for (int i = 0; i < APP.ResourceMyList.obj.Count; i++)
- {
- string imgSuffix = string.Empty;
- string visDuration = "Collapsed";
- string visButton = "Collapsed";
- string visDownload = "Visible";
- System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
- dateTime = dateTime.AddSeconds(APP.ResourceMyList.obj[i].createtime).ToLocalTime();
- if ("doc".Equals(APP.ResourceMyList.obj[i].suffix)
- || "docx".Equals(APP.ResourceMyList.obj[i].suffix))
- {
- imgSuffix = "../Images/Resource/DOC.png";
- }
- else if ("ppt".Equals(APP.ResourceMyList.obj[i].suffix)
- || "pptx".Equals(APP.ResourceMyList.obj[i].suffix))
- {
- imgSuffix = "../Images/Resource/PPT.png";
- }
- else if ("pdf".Equals(APP.ResourceMyList.obj[i].suffix))
- {
- imgSuffix = "../Images/Resource/PDF.png";
- }
- else if ("excel".Equals(APP.ResourceMyList.obj[i].suffix)
- || "xls".Equals(APP.ResourceMyList.obj[i].suffix) || "xlsx".Equals(APP.ResourceMyList.obj[i].suffix))
- {
- imgSuffix = "../Images/Resource/EXCEL.png";
- }
- else if ("class".Equals(APP.ResourceMyList.obj[i].suffix))
- {
- imgSuffix = "../Images/Resource/CLASS.png";
- }
- else if ("dsc".Equals(APP.ResourceMyList.obj[i].suffix))
- {
- imgSuffix = "../Images/Resource/DSC.png";
- }
- else if ("mp3".Equals(APP.ResourceMyList.obj[i].suffix))
- {
- visDuration = "Visible";
- imgSuffix = "../Images/Resource/MP3.png";
- }
- else if ("mp4".Equals(APP.ResourceMyList.obj[i].suffix)
- || "flv".Equals(APP.ResourceMyList.obj[i].suffix))
- {
- visDuration = "Visible";
- if (APP.ResourceMyList.obj[i].resourcecover != null)
- {
- imgSuffix = APP.showImageUrl + APP.ResourceMyList.obj[i].resourcecover.ToString();
- }
- else
- {
- imgSuffix = "../Images/Resource/MP4.png";
- }
- }
- else if ("png".Equals(APP.ResourceMyList.obj[i].suffix)
- || "jpg".Equals(APP.ResourceMyList.obj[i].suffix)
- || "jpeg".Equals(APP.ResourceMyList.obj[i].suffix))
- {
- imgSuffix = "../Images/Resource/PNG.png";
- }
- else if ("txt".Equals(APP.ResourceMyList.obj[i].suffix))
- {
- imgSuffix = "../Images/Resource/TXT.png";
- }
- else if ("txt".Equals(APP.ResourceMyList.obj[i].suffix))
- {
- imgSuffix = "../Images/Resource/FLV.png";
- }
- else if ("wav".Equals(APP.ResourceMyList.obj[i].suffix))
- {
- imgSuffix = "../Images/Resource/WAV.png";
- }
- string resourcesSuffix = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + APP.LoginUser.username + "\\" + APP.ResourceMyList.obj[i].resourcename + "." + APP.ResourceMyList.obj[i].suffix;
- if (!string.IsNullOrWhiteSpace(APP.fileStorageAddress))
- {
- resourcesSuffix = APP.fileStorageAddress + "\\" + APP.ResourceMyList.obj[i].resourcename + "." + APP.ResourceMyList.obj[i].suffix;
- }
- if (File.Exists(resourcesSuffix))//检查资源是否已经存在
- {
- visButton = "Visible";
- visDownload = "Collapsed";
- }
- string resourcesize;
- if (APP.ResourceMyList.obj[i].resourcesize > 1024)
- {
- if (APP.ResourceMyList.obj[i].resourcesize / 1024 > 1024)
- {
- resourcesize = (APP.ResourceMyList.obj[i].resourcesize / 1024 / 1024).ToString() + "MB";
- }
- else
- {
- resourcesize = (APP.ResourceMyList.obj[i].resourcesize / 1024).ToString() + "KB";
- }
- }
- else
- {
- resourcesize = (APP.ResourceMyList.obj[i].resourcesize).ToString() + "B";
- }
- string duration = string.Empty;
- if (APP.ResourceMyList.obj[i].duration > 59)
- {
- if (APP.ResourceMyList.obj[i].duration > 3599)
- {
- if (APP.ResourceMyList.obj[i].duration % 3600 == 0)
- {
- duration = (APP.ResourceMyList.obj[i].duration / 3600).ToString() + "时";
- }
- else
- {
- duration = (APP.ResourceMyList.obj[i].duration / 3600).ToString() + "时" + (APP.ResourceMyList.obj[i].duration % 3600).ToString() + "分";
- }
- }
- else
- {
- if (APP.ResourceMyList.obj[i].duration % 60 == 0)
- {
- duration = (APP.ResourceMyList.obj[i].duration / 60).ToString() + "分";
- }
- else
- {
- duration = (APP.ResourceMyList.obj[i].duration / 60).ToString() + "分" + (APP.ResourceMyList.obj[i].duration % 60).ToString() + "秒";
- }
- }
- }
- else
- {
- duration = APP.ResourceMyList.obj[i].duration.ToString() + "秒";
- }
- pageData.menuList.Add(new ToolbarMenuTwo()
- {
- Resourcesize = resourcesize,
- ResourceName = APP.ResourceMyList.obj[i].resourcename,
- Times = dateTime.ToString("yyy-MM-dd HH:mm:ss"),
- Pic = imgSuffix,
- VisDuration = visDuration,
- Duration = duration,
- VisButton = visButton,
- VisDownload = visDownload,
- Resourceid = APP.ResourceMyList.obj[i].resourceid
- });
- }
- }
- DataContext = pageData;
- }
- else
- {
- MessageWindow.Show(APP.ErrorMessage);
- }
- }
- private void DownLoadTwo(string httpurls, int position, string savepath)
- {
- thread = DownloadUtil.downloadFileWithCallback(
- httpurls,
- position,
- savepath,
- Dispatcher,
- this
- );
- }
-
- /// <summary>
- /// 下载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnDownload_Click(object sender, RoutedEventArgs e)
- {
- if (!isDownloadStatus)
- {
- int clickindex = 0;
- Button btn = (Button)sender;
- for (int i = 0; i < APP.ResourceMyList.obj.Count; i++)
- {
-
- if (APP.ResourceMyList.obj[i].resourceid == Convert.ToInt32(btn.Tag))
- {
- clickindex = i;
- break;
- }
- }
- string fileAddress = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + APP.LoginUser.username + "\\" + APP.ResourceMyList.obj[clickindex].resourcename + "." + APP.ResourceMyList.obj[clickindex].suffix;
- if (!string.IsNullOrWhiteSpace(APP.fileStorageAddress))
- {
- fileAddress = APP.fileStorageAddress + "\\" + APP.ResourceMyList.obj[clickindex].resourcename + "." + APP.ResourceMyList.obj[clickindex].suffix;
- }
- //if (APP.outputInforLog)
- //{
- // LogHelper.WriteInfoLog("UserCenterWindow(btnDownload_Click 下载)" + fileAddress);
- //}
- if (Directory.Exists(fileAddress))//存在就打开 不存在就下载
- {
- ProcessStartInfo psi = new ProcessStartInfo(fileAddress);
- Process pro = new Process
- {
- StartInfo = psi
- };
- pro.Start();
- }
- else
- {
- if (!string.IsNullOrWhiteSpace(APP.fileStorageAddress))
- {
- fileAddress = APP.fileStorageAddress;
- }
- if (!Directory.Exists(fileAddress))
- {
- Directory.CreateDirectory(fileAddress);
- }
- string userHeadPic = APP.showImageUrl + APP.ResourceMyList.obj[clickindex].resourceurl.ToString();
- DownLoadTwo(userHeadPic, 9999 + clickindex, fileAddress + "\\");
- }
- }
- }
-
- /// <summary>
- /// 打开
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnTurnOn_Click(object sender, RoutedEventArgs e)
- {
- if (!isDownloadStatus)
- {
- int clickindex = 0;
- Button btn = (Button)sender;
- for (int i = 0; i < APP.ResourceMyList.obj.Count; i++)
- {
-
- if (APP.ResourceMyList.obj[i].resourceid == Convert.ToInt32(btn.Tag))
- {
- clickindex = i;
- break;
- }
- }
-
- string fileAddress = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\" + APP.LoginUser.username + "\\" + APP.ResourceMyList.obj[clickindex].resourcename + "." + APP.ResourceMyList.obj[clickindex].suffix;
- if (!string.IsNullOrWhiteSpace(APP.fileStorageAddress))
- {
- fileAddress = APP.fileStorageAddress + "\\" + APP.ResourceMyList.obj[clickindex].resourcename + "." + APP.ResourceMyList.obj[clickindex].suffix;
- }
- //if (APP.outputInforLog)
- //{
- // LogHelper.WriteInfoLog("UserCenterWindow(btnTurnOn_Click 打开)" + fileAddress);
- //}
- if (Directory.Exists(fileAddress))//存在就打开 不存在就下载
- {
- try
- {
- ProcessStartInfo psi = new ProcessStartInfo(fileAddress);
- Process pro = new Process
- {
- StartInfo = psi
- };
- pro.Start();
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("UserCenterWindow【btnTurnOn_Click】" + ex.Message, ex);
- MessageWindow.Show(ex.Message);
- return;
- }
- }
- else
- {
- if (!string.IsNullOrWhiteSpace(APP.fileStorageAddress))
- {
- fileAddress = APP.fileStorageAddress;
- }
- if (!Directory.Exists(fileAddress))
- {
- Directory.CreateDirectory(fileAddress);
- }
- string userHeadPic = APP.showImageUrl + APP.ResourceMyList.obj[clickindex].resourceurl.ToString();
- DownLoadTwo(userHeadPic, 9999 + clickindex, fileAddress + "\\");
- }
- }
- }
-
- /// <summary>
- /// 全部
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnAll_Click(object sender, RoutedEventArgs e)
- {
- pageData.menuList.Clear();
- DataContext = pageData;
- Resourceclass = 0;
- borAll.Background = new SolidColorBrush(Colors.DodgerBlue);
- borAudio.Background = new SolidColorBrush(Colors.Transparent);
- borVideo.Background = new SolidColorBrush(Colors.Transparent);
- borImage.Background = new SolidColorBrush(Colors.Transparent);
- borDoc.Background = new SolidColorBrush(Colors.Transparent);
- btnAll.Foreground = new SolidColorBrush(Colors.White);
- btnAudio.Foreground = new SolidColorBrush(Colors.Black);
- btnVideo.Foreground = new SolidColorBrush(Colors.Black);
- btnImage.Foreground = new SolidColorBrush(Colors.Black);
- btnDoc.Foreground = new SolidColorBrush(Colors.Black);
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
- }
-
- private void Window_Closing(object sender, CancelEventArgs e)
- {
- if (pageData.menuList.Count > 0)
- {
- pageData.menuList.Clear();
- DataContext = null;
- }
- }
-
- /// <summary>
- /// 音频
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnAudio_Click(object sender, RoutedEventArgs e)
- {
- pageData.menuList.Clear();
- DataContext = pageData;
- Resourceclass = 1;
- borAll.Background = new SolidColorBrush(Colors.Transparent);
- borAudio.Background = new SolidColorBrush(Colors.DodgerBlue);
- borVideo.Background = new SolidColorBrush(Colors.Transparent);
- borImage.Background = new SolidColorBrush(Colors.Transparent);
- borDoc.Background = new SolidColorBrush(Colors.Transparent);
- btnAll.Foreground = new SolidColorBrush(Colors.Black);
- btnAudio.Foreground = new SolidColorBrush(Colors.White);
- btnVideo.Foreground = new SolidColorBrush(Colors.Black);
- btnImage.Foreground = new SolidColorBrush(Colors.Black);
- btnDoc.Foreground = new SolidColorBrush(Colors.Black);
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
- }
-
- /// <summary>
- /// 视频
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnVideo_Click(object sender, RoutedEventArgs e)
- {
- pageData.menuList.Clear();
- DataContext = pageData;
- Resourceclass = 2;
- borAll.Background = new SolidColorBrush(Colors.Transparent);
- borAudio.Background = new SolidColorBrush(Colors.Transparent);
- borVideo.Background = new SolidColorBrush(Colors.DodgerBlue);
- borImage.Background = new SolidColorBrush(Colors.Transparent);
- borDoc.Background = new SolidColorBrush(Colors.Transparent);
- btnAll.Foreground = new SolidColorBrush(Colors.Black);
- btnAudio.Foreground = new SolidColorBrush(Colors.Black);
- btnVideo.Foreground = new SolidColorBrush(Colors.White);
- btnImage.Foreground = new SolidColorBrush(Colors.Black);
- btnDoc.Foreground = new SolidColorBrush(Colors.Black);
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
- }
-
- /// <summary>
- /// 图片
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnImage_Click(object sender, RoutedEventArgs e)
- {
- pageData.menuList.Clear();
- DataContext = pageData;
- Resourceclass = 3;
- borAll.Background = new SolidColorBrush(Colors.Transparent);
- borAudio.Background = new SolidColorBrush(Colors.Transparent);
- borVideo.Background = new SolidColorBrush(Colors.Transparent);
- borImage.Background = new SolidColorBrush(Colors.DodgerBlue);
- borDoc.Background = new SolidColorBrush(Colors.Transparent);
- btnAll.Foreground = new SolidColorBrush(Colors.Black);
- btnAudio.Foreground = new SolidColorBrush(Colors.Black);
- btnVideo.Foreground = new SolidColorBrush(Colors.Black);
- btnImage.Foreground = new SolidColorBrush(Colors.White);
- btnDoc.Foreground = new SolidColorBrush(Colors.Black);
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
- }
-
- /// <summary>
- /// 文档
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnDoc_Click(object sender, RoutedEventArgs e)
- {
- pageData.menuList.Clear();
- DataContext = pageData;
- Resourceclass = 4;
- borAll.Background = new SolidColorBrush(Colors.Transparent);
- borAudio.Background = new SolidColorBrush(Colors.Transparent);
- borVideo.Background = new SolidColorBrush(Colors.Transparent);
- borImage.Background = new SolidColorBrush(Colors.Transparent);
- borDoc.Background = new SolidColorBrush(Colors.DodgerBlue);
- btnAll.Foreground = new SolidColorBrush(Colors.Black);
- btnAudio.Foreground = new SolidColorBrush(Colors.Black);
- btnVideo.Foreground = new SolidColorBrush(Colors.Black);
- btnImage.Foreground = new SolidColorBrush(Colors.Black);
- btnDoc.Foreground = new SolidColorBrush(Colors.White);
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeResourceMyListServering, InvokeServerResourceMyListCompate);
- }
-
- private void Refresh()
- {
- pageData.menuList.Clear();
- }
- /// <summary>
- /// 科目教材选择改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void cmbClass_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (initialization)
- {
- initialization = false;
- }
- else
- {
- Directorid = 0;
- borAll.Background = new SolidColorBrush(Colors.DodgerBlue);
- borAudio.Background = new SolidColorBrush(Colors.Transparent);
- borVideo.Background = new SolidColorBrush(Colors.Transparent);
- borImage.Background = new SolidColorBrush(Colors.Transparent);
- borDoc.Background = new SolidColorBrush(Colors.Transparent);
- btnAll.Foreground = new SolidColorBrush(Colors.White);
- btnAudio.Foreground = new SolidColorBrush(Colors.Black);
- btnVideo.Foreground = new SolidColorBrush(Colors.Black);
- btnImage.Foreground = new SolidColorBrush(Colors.Black);
- btnDoc.Foreground = new SolidColorBrush(Colors.Black);
- }
-
- if (cmbClass.SelectedValue != null)
- {
- Lsbid = Convert.ToInt32(cmbClass.SelectedValue.ToString());
- Refresh();
- APP.BackgroundWorkerHelper.RunWorkerAsync(InvokeDirectorListServering, InvokeServerDirectorListCompate);
- }
- else
- {
- Refresh();
- }
- }
-
- private void Window_MouseMove(object sender, MouseEventArgs e)
- {
- if (e.LeftButton == MouseButtonState.Pressed)
- {
- //执行移动方法
- DragMove();
- }
- }
-
- private void btnDown_Click(object sender, RoutedEventArgs e)
- {
- if (thread != null)
- {
- thread.Abort();
- }
- APP.myloading.Hide();
- Close();
- //ToolbarWindow.IsOpenUserCenterWindow = false;
- }
-
- public void downloadBegin(int position)
- {
- isDownloadStatus = true;
- if (position >= 9999)
- {
- tip_outer.Visibility = Visibility.Visible;
- }
- }
-
- public void downloadProgress(int position, int progress)
- {
- if (position >= 9999)
- {
- pgbProcess.Value = progress * 100 / 100;
- lbProcess.Content = string.Format("{0}% / {1}%", progress, 100);
- }
- }
-
- public void downloadEnd(int position, string filepath)
- {
- isDownloadStatus = false;
- thread = null;
- if (pageData.menuList.Count > 0)
- {
- //if (APP.outputInforLog)
- //{
- // LogHelper.WriteInfoLog("UserCenterWindow(downloadEnd 下载完成)" + filepath);
- //}
- if (position < 9999)
- {
- if (pageData.menuList.Count < position)
- {
- pageData.menuList[position].Pic = filepath;
- }
- }
- else if (filepath.Contains(pageData.menuList[position - 9999].ResourceName))
- {
- pageData.menuList[position - 9999].VisDownload = "Collapsed";
- pageData.menuList[position - 9999].VisButton = "Visible";
- tip_outer.Visibility = Visibility.Hidden;
- try
- {
- ProcessStartInfo psi = new ProcessStartInfo(filepath);
- Process pro = new Process
- {
- StartInfo = psi
- };
- pro.Start();
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("UserCenterWindow【downloadEnd】" + ex.Message, ex);
- MessageWindow.Show(ex.Message);
- return;
- }
- }
- else
- {
- tip_outer.Visibility = Visibility.Hidden;
- try
- {
- ProcessStartInfo psi = new ProcessStartInfo(filepath);
- Process pro = new Process
- {
- StartInfo = psi
- };
- pro.Start();
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("UserCenterWindow【downloadEnd】" + ex.Message, ex);
- MessageWindow.Show(ex.Message);
- return;
- }
- }
- }
- else
- {
- tip_outer.Visibility = Visibility.Hidden;
-
- try
- {
- ProcessStartInfo psi = new ProcessStartInfo(filepath);
- Process pro = new Process
- {
- StartInfo = psi
- };
- pro.Start();
- }
- catch (Exception ex)
- {
- LogHelper.WriteErrLog("UserCenterWindow【downloadEnd】" + ex.Message, ex);
- MessageWindow.Show(ex.Message);
- return;
- }
- }
- }
-
- public void downloadError(int position, string msg)
- {
- Dispatcher.Invoke(new Action(() =>
- {
- tip_outer.Visibility = Visibility.Collapsed;
- }));
- isDownloadStatus = false;
- if (!msg.Equals("远程服务器返回错误: (404) 未找到。") && !msg.Equals("正在中止线程。"))
- {
- MessageWindow.Show(msg);
- }
- }
-
- public class ButtonBrush
- {
- public static readonly DependencyProperty ButtonPressBackgroundProperty = DependencyProperty.RegisterAttached(
- "ButtonPressBackground", typeof(Brush), typeof(ButtonBrush), new PropertyMetadata(default(Brush)));
-
- public static void SetButtonPressBackground(DependencyObject element, Brush value)
- {
- element.SetValue(ButtonPressBackgroundProperty, value);
- }
-
- public static Brush GetButtonPressBackground(DependencyObject element)
- {
- return (Brush)element.GetValue(ButtonPressBackgroundProperty);
- }
- }
- }
-
- public class ToolbarMenuTwo : NotifyModel
- {
- internal string _resourceName;
-
- public string ResourceName
- {
- get => _resourceName;
- set { _resourceName = value; OnPropertyChanged("ResourceName"); }
- }
-
- internal string _times;
-
- public string Times
- {
- get => _times;
- set { _times = value; OnPropertyChanged("Times"); }
- }
-
- internal string _Pic;
-
- public string Pic
- {
- get => _Pic;
- set { _Pic = value; OnPropertyChanged("Pic"); }
- }
-
- /// <summary>
- /// 视频时长秒
- /// </summary>
- public string Duration { get; set; }
-
- /// <summary>
- /// 视频时长是否显示
- /// </summary>
- public string VisDuration { get; set; }
-
- /// <summary>
- /// 文件大小
- /// </summary>
- public string Resourcesize { get; set; }
-
- internal string _VisButton;
-
- /// <summary>
- /// 打开按钮是否显示
- /// </summary>
- public string VisButton
- {
- get => _VisButton;
- set { _VisButton = value; OnPropertyChanged("VisButton"); }
- }
-
- internal string _VisDownload;
-
- /// <summary>
- /// 下载按钮是否显示
- /// </summary>
- public string VisDownload
- {
- get => _VisDownload;
- set { _VisDownload = value; OnPropertyChanged("VisDownload"); }
- }
-
- internal int _Resourceid;
-
- /// <summary>
- /// 资源id
- /// </summary>
- public int Resourceid
- {
- get => _Resourceid;
- set { _Resourceid = value; OnPropertyChanged("Resourceid"); }
- }
- }
-
- public class UserCenterPageData : NotifyModel
- {
- public ObservableCollection<ComboBoxBeanModel> bookList { get; set; }
-
- public ObservableCollection<ChapterModel> zhangjieList { get; set; }
- public ObservableCollection<ToolbarMenuTwo> menuList { get; set; }
-
- public UserCenterPageData()
- {
- bookList = new ObservableCollection<ComboBoxBeanModel>();
- zhangjieList = new ObservableCollection<ChapterModel>();
- menuList = new ObservableCollection<ToolbarMenuTwo>();
- }
- }
-
- public class ChapterModel : NotifyModel
- {
- public int directorid { get; set; }
- public string directorname { get; set; }
- public int level { get; set; }
-
- private int _selected;
-
- public int selected
- {
- get => _selected;
- set
- {
- _selected = value;
- OnPropertyChanged("selected");
- }
- }
- }
- }
|