星火微课系统客户端
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

XHMicroLessonSystemWindow.xaml.cs 113KB

4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
4年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640
  1. using Aspose.Words;
  2. using Aspose.Words.Saving;
  3. using Common.system;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Drawing.Imaging;
  7. using System.IO;
  8. using System.Threading;
  9. using System.Windows;
  10. using System.Windows.Forms;
  11. using System.Windows.Ink;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using XHWK.Model;
  16. using System.Windows.Controls;
  17. using ComeCapture;
  18. using Aspose.Slides;
  19. using static Common.system.PdfTrunImage;
  20. using TStudyDigitalPen.HID;
  21. using System.Drawing;
  22. using XHWK.WKTool.DAL;
  23. using System.Text;
  24. using System.Collections.Specialized;
  25. using XHWK.WKTool.Config;
  26. using System.Windows.Threading;
  27. namespace XHWK.WKTool
  28. {
  29. /// <summary>
  30. /// 主页面
  31. /// </summary>
  32. public partial class XHMicroLessonSystemWindow : Window
  33. {
  34. #region 字段
  35. /// <summary>
  36. /// 文件目录窗口
  37. /// </summary>
  38. //private CountdownWindow FileDirectoryWindows = null;
  39. private FolderBrowserDialog Ofd;
  40. private DialogResult Result;
  41. public readonly BlackboardNew myblackboard;
  42. private System.Windows.Forms.DialogResult result;
  43. private System.Windows.Forms.OpenFileDialog ofd;
  44. //声明一个 DrawingAttributes 类型的变量
  45. DrawingAttributes drawingAttributes;
  46. Model_Video VideoInfo = null;
  47. //定义事件
  48. public event ChangeTextHandler ChangeTextEvent;
  49. //定义委托
  50. public delegate void ChangeTextHandler(string text);
  51. /// <summary>
  52. /// 图片
  53. /// </summary>
  54. string[] ImgPDFPath = new string[300];
  55. /// <summary>
  56. /// 当前颜色
  57. /// </summary>
  58. private System.Windows.Media.Color Color = System.Windows.Media.Colors.Red;
  59. /// <summary>
  60. /// 笔迹粗细
  61. /// </summary>
  62. private int PenSize = 2;
  63. private DispatcherTimer t = null;
  64. /// <summary>
  65. /// 计时器状态
  66. /// </summary>
  67. private enum State
  68. {
  69. Start,
  70. Pause,
  71. End
  72. }
  73. /// <summary>
  74. /// 状态
  75. /// </summary>
  76. private State _state = State.End;
  77. /// <summary>
  78. /// 计时用
  79. /// </summary>
  80. private TimeSpan _timeSpan = new TimeSpan(0, 0, 0, 0, 0);
  81. #endregion
  82. #region 初始化
  83. /// <summary>
  84. /// 主页面
  85. /// </summary>
  86. public XHMicroLessonSystemWindow()
  87. {
  88. new Aspose.Pdf.License().SetLicense(new MemoryStream(Convert.FromBase64String("PExpY2Vuc2U+CiAgPERhdGE+CiAgICA8TGljZW5zZWRUbz5TdXpob3UgQXVuYm94IFNvZnR3YXJlIENvLiwgTHRkLjwvTGljZW5zZWRUbz4KICAgIDxFbWFpbFRvPnNhbGVzQGF1bnRlYy5jb208L0VtYWlsVG8+CiAgICA8TGljZW5zZVR5cGU+RGV2ZWxvcGVyIE9FTTwvTGljZW5zZVR5cGU+CiAgICA8TGljZW5zZU5vdGU+TGltaXRlZCB0byAxIGRldmVsb3BlciwgdW5saW1pdGVkIHBoeXNpY2FsIGxvY2F0aW9uczwvTGljZW5zZU5vdGU+CiAgICA8T3JkZXJJRD4xOTA4MjYwODA3NTM8L09yZGVySUQ+CiAgICA8VXNlcklEPjEzNDk3NjAwNjwvVXNlcklEPgogICAgPE9FTT5UaGlzIGlzIGEgcmVkaXN0cmlidXRhYmxlIGxpY2Vuc2U8L09FTT4KICAgIDxQcm9kdWN0cz4KICAgICAgPFByb2R1Y3Q+QXNwb3NlLlRvdGFsIGZvciAuTkVUPC9Qcm9kdWN0PgogICAgPC9Qcm9kdWN0cz4KICAgIDxFZGl0aW9uVHlwZT5FbnRlcnByaXNlPC9FZGl0aW9uVHlwZT4KICAgIDxTZXJpYWxOdW1iZXI+M2U0NGRlMzAtZmNkMi00MTA2LWIzNWQtNDZjNmEzNzE1ZmMyPC9TZXJpYWxOdW1iZXI+CiAgICA8U3Vic2NyaXB0aW9uRXhwaXJ5PjIwMjAwODI3PC9TdWJzY3JpcHRpb25FeHBpcnk+CiAgICA8TGljZW5zZVZlcnNpb24+My4wPC9MaWNlbnNlVmVyc2lvbj4KICAgIDxMaWNlbnNlSW5zdHJ1Y3Rpb25zPmh0dHBzOi8vcHVyY2hhc2UuYXNwb3NlLmNvbS9wb2xpY2llcy91c2UtbGljZW5zZTwvTGljZW5zZUluc3RydWN0aW9ucz4KICA8L0RhdGE+CiAgPFNpZ25hdHVyZT53UGJtNUt3ZTYvRFZXWFNIY1o4d2FiVEFQQXlSR0pEOGI3L00zVkV4YWZpQnd5U2h3YWtrNGI5N2c2eGtnTjhtbUFGY3J0c0cwd1ZDcnp6MytVYk9iQjRYUndTZWxsTFdXeXNDL0haTDNpN01SMC9jZUFxaVZFOU0rWndOQkR4RnlRbE9uYTFQajhQMzhzR1grQ3ZsemJLZFZPZXk1S3A2dDN5c0dqYWtaL1E9PC9TaWduYXR1cmU+CjwvTGljZW5zZT4=")));
  89. InitializeComponent();
  90. this.ResizeMode = System.Windows.ResizeMode.CanMinimize;
  91. btnPrint.IsEnabled = false;
  92. myblackboard = new BlackboardNew(blackboard_canvas);
  93. APP.pageData.pagenum = 0;
  94. APP.pageData.currpage = 0;
  95. DataContext = APP.pageData;
  96. //APP.SaveDraw();//画板模型第一页初始化
  97. APP.PageDrawList = new List<Model_DrawData>();
  98. Model_DrawData model_DrawData = new Model_DrawData();
  99. model_DrawData.PageNum = APP.pageData.currpage;
  100. APP.PageDrawList.Add(model_DrawData);
  101. txbv.Text = "v"+ZConfig.versionName;
  102. txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoType");
  103. if (FileToolsCommon.GetConfigValue("IsSound").Equals("true"))
  104. {
  105. rbnY.IsChecked = true;
  106. }
  107. else
  108. {
  109. rbnN.IsChecked = true;
  110. }
  111. txbStoragePath.Content = FileToolsCommon.GetConfigValue("VideoSavePath");
  112. Initialize();
  113. InitPen();
  114. }
  115. /// <summary>
  116. /// 初始化
  117. /// </summary>
  118. public void Initialize()
  119. {
  120. #region 数据初始化
  121. APP.pageData.pagenum = 0;
  122. APP.pageData.currpage = APP.pageData.pagenum;
  123. btnStop.IsEnabled = false;//停止录制按钮不可点击
  124. #endregion
  125. APP.CameraPosition = FileToolsCommon.GetConfigValue("CameraPosition");
  126. //创建 DrawingAttributes 类的一个实例
  127. drawingAttributes = new DrawingAttributes();
  128. //将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  129. //InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  130. blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  131. blackboard_canvas.UseCustomCursor = true;
  132. drawingAttributes.FitToCurve = true;
  133. drawingAttributes.IgnorePressure = false;
  134. drawingAttributes.Width = PenSize;
  135. drawingAttributes.Height = PenSize;
  136. drawingAttributes.Color = Color;
  137. blackboard_canvas.Cursor = System.Windows.Input.Cursors.Pen;
  138. //wfhCamera.Visibility = Visibility.Hidden;
  139. ImgPDFPath = null;
  140. ImgPDFPath = new string[300];
  141. }
  142. /// <summary>
  143. /// 开始
  144. /// </summary>
  145. /// <param name="sender"></param>
  146. /// <param name="e"></param>
  147. private void Stack()
  148. {
  149. _state = State.Start;
  150. }
  151. /// <summary>
  152. /// 暂停
  153. /// </summary>
  154. private void TimeOut()
  155. {
  156. _state = State.Pause;
  157. }
  158. /// <summary>
  159. /// 结束
  160. /// </summary>
  161. /// <param name="sender"></param>
  162. /// <param name="e"></param>
  163. private void End()
  164. {
  165. _state = State.End;
  166. }
  167. /// <summary>
  168. /// 时钟回调
  169. /// </summary>
  170. /// <param name="sender"></param>
  171. /// <param name="e"></param>
  172. private void OnTimer(object sender, EventArgs e)
  173. {
  174. switch (_state)
  175. {
  176. case State.Start:
  177. {
  178. _timeSpan += new TimeSpan(0, 0, 0, 1);
  179. }
  180. break;
  181. case State.Pause:
  182. {
  183. }
  184. break;
  185. case State.End:
  186. {
  187. _timeSpan = new TimeSpan();
  188. //_timeSpan = new TimeSpan(0, 23, 12, 45, 54);
  189. }
  190. break;
  191. }
  192. string time = string.Format("{0:D2}:{1:D2}",/* _timeSpan.Hours,*/ _timeSpan.Minutes, _timeSpan.Seconds);
  193. txbTime.Text = time;
  194. //txbTime.Text = time;
  195. }
  196. /// <summary>
  197. /// 修改布局
  198. /// </summary>
  199. public void SetUpLayout()
  200. {
  201. //宽高比1276,1040
  202. //double AspectRatio = 1276.0 / 1040.0;
  203. ////System.Drawing.Size des = PrimaryScreen.DESKTOP;
  204. //System.Drawing.Size workingArea = PrimaryScreen.WorkingArea;
  205. //this.Height = workingArea.Height;
  206. }
  207. #endregion
  208. #region 事件
  209. /// <summary>
  210. /// 窗体移动
  211. /// </summary>
  212. /// <param name="sender"></param>
  213. /// <param name="e"></param>
  214. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  215. {
  216. DragMove();
  217. }
  218. #region 摄像头
  219. System.Timers.Timer times;
  220. List<string> RbnOpen;
  221. bool IsRbnOpen = false;
  222. /// <summary>
  223. /// 摄像头打开事件
  224. /// </summary>
  225. /// <param name="sender"></param>
  226. /// <param name="e"></param>
  227. private void RbnOpen_Click(object sender, RoutedEventArgs e)
  228. {
  229. //UCCamera win = new UCCamera();
  230. ////win.Topmost = true;
  231. //win.ShowDialog();
  232. //wfhCamera.Visibility = Visibility.Visible;
  233. //CameraHelper.IsDisplay = true;
  234. //CameraHelper.SourcePlayer = player;
  235. CameraHelper.UpdateCameraDevices();
  236. if (CameraHelper.CameraDevices.Count > 0)
  237. {
  238. CameraHelper.SetCameraDevice(0);
  239. RbnOpen = new List<string>();
  240. times = new System.Timers.Timer(300);//设置执行一次(false)还是一直执行(true)
  241. times.AutoReset = true;//设置是否执行System.Timers.Timer.Elapsed事件
  242. times.Elapsed += new System.Timers.ElapsedEventHandler(Times_Elapsed);
  243. times.Enabled = true; //启动计时器
  244. IsRbnOpen = true;
  245. string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
  246. FileToolsCommon.CreateDirectory(imgPath);
  247. }
  248. }
  249. int I = 9999;
  250. private void Times_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  251. {
  252. if (IsRbnOpen)
  253. {
  254. try
  255. {
  256. Dispatcher.Invoke(() =>
  257. {
  258. if (I > 10010)
  259. {
  260. long time = Timestamp();
  261. string imgPath = FileToolsCommon.GetFileAbsolutePath("Temp/imgplayer");
  262. //string FilePathName = ImgPath + RsImgName.Count + ".png";
  263. string path = CameraHelper.CaptureImage(imgPath, time.ToString());
  264. if (!string.IsNullOrWhiteSpace(path))
  265. {
  266. RbnOpen.Add(path);
  267. imgPlayerRight.Visibility = Visibility.Visible;
  268. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  269. if ("1".Equals(APP.CameraPosition))
  270. {
  271. imgPlayerRight.Visibility = Visibility.Visible;
  272. imgPlayerLeft.Visibility = Visibility.Collapsed;
  273. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  274. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  275. imgPlayerRight.Source = new BitmapImage(new Uri(path));
  276. }
  277. else if ("2".Equals(APP.CameraPosition))
  278. {
  279. imgPlayerRight.Visibility = Visibility.Collapsed;
  280. imgPlayerLeft.Visibility = Visibility.Visible;
  281. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  282. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  283. imgPlayerLeft.Source = new BitmapImage(new Uri(path));
  284. }
  285. else if ("3".Equals(APP.CameraPosition))
  286. {
  287. imgPlayerRight.Visibility = Visibility.Collapsed;
  288. imgPlayerLeft.Visibility = Visibility.Collapsed;
  289. imgPlayerRightUnder.Visibility = Visibility.Visible;
  290. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  291. imgPlayerRightUnder.Source = new BitmapImage(new Uri(path));
  292. }
  293. else if ("4".Equals(APP.CameraPosition))
  294. {
  295. imgPlayerRight.Visibility = Visibility.Collapsed;
  296. imgPlayerLeft.Visibility = Visibility.Collapsed;
  297. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  298. imgPlayerLeftUnder.Visibility = Visibility.Visible;
  299. imgPlayerLeftUnder.Source = new BitmapImage(new Uri(path));
  300. }
  301. else
  302. {
  303. imgPlayerLeft.Visibility = Visibility.Collapsed;
  304. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  305. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  306. imgPlayerRight.Source = new BitmapImage(new Uri(path));
  307. }
  308. }
  309. }
  310. I++;
  311. });
  312. }
  313. catch (Exception ex)
  314. {
  315. LogHelper.WriteErrLog("【摄像】(Times_Elapsed)生成图片错误:" + ex.Message, ex);
  316. }
  317. }
  318. }
  319. /// <summary>
  320. /// 摄像头关闭事件
  321. /// </summary>
  322. /// <param name="sender"></param>
  323. /// <param name="e"></param>
  324. private void RbnTurnOff_Click(object sender, RoutedEventArgs e)
  325. {
  326. IsRbnOpen = false;
  327. imgPlayerRight.Visibility = Visibility.Collapsed;
  328. imgPlayerLeft.Visibility = Visibility.Collapsed;
  329. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  330. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  331. CameraHelper.CloseDevice();
  332. I = 9999;
  333. }
  334. #endregion
  335. #endregion
  336. /// <summary>
  337. /// 录屏事件
  338. /// </summary>
  339. /// <param name="sender"></param>
  340. /// <param name="e"></param>
  341. private void BtnScreenRecording_Click(object sender, RoutedEventArgs e)
  342. {
  343. #region 限制只允许录制一个录屏 废弃
  344. //string RecordScreenPathName = APP.WKData.WkPath + APP.WKData.WkName + "_录屏." + ((Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"))).ToString();
  345. //if (FileToolsCommon.IsExistFile(RecordScreenPathName))
  346. //{
  347. // MessageBoxResult dr = System.Windows.MessageBox.Show("已存在录屏,是否覆盖?", "提示", MessageBoxButton.OKCancel);
  348. // if (dr == MessageBoxResult.OK)
  349. // {
  350. // try
  351. // {
  352. // FileToolsCommon.DeleteFile(RecordScreenPathName);
  353. // APP.VideoList.RemoveAll(x => x.VideoPath == RecordScreenPathName);
  354. // }
  355. // catch (Exception ex)
  356. // {
  357. // LogHelper.WriteErrLog("【录屏】(BtnRecordingScreen_Click)无法移除视频," + ex.Message, ex);
  358. // }
  359. // }
  360. // else
  361. // {
  362. // return;
  363. // }
  364. //}
  365. #endregion
  366. if (APP.W_ScreenRecordingToolbarWindow == null)
  367. {
  368. APP.W_ScreenRecordingToolbarWindow = new ScreenRecordingToolbarWindow
  369. {
  370. Topmost = true
  371. };
  372. APP.W_ScreenRecordingToolbarWindow.Initialize();
  373. }
  374. else
  375. {
  376. APP.W_ScreenRecordingToolbarWindow.Initialize();
  377. }
  378. APP.W_ScreenRecordingToolbarWindow.Click_stopRecordingScreen += W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen;
  379. //显示在右下角
  380. APP.W_ScreenRecordingToolbarWindow.WindowStartupLocation = WindowStartupLocation.Manual;
  381. APP.W_ScreenRecordingToolbarWindow.Left = PrimaryScreen.DESKTOP.Width - APP.W_ScreenRecordingToolbarWindow.Width - 60;
  382. APP.W_ScreenRecordingToolbarWindow.Top = PrimaryScreen.DESKTOP.Height - APP.W_ScreenRecordingToolbarWindow.Height - 30;
  383. APP.W_ScreenRecordingToolbarWindow.Topmost = true;
  384. APP.W_ScreenRecordingToolbarWindow.Show();
  385. Hide();
  386. }
  387. /// <summary>
  388. /// 保存录屏中
  389. /// </summary>
  390. private void W_ScreenRecordingToolbarWindow_Click_stopRecordingScreen()
  391. {
  392. TxbRecordScreenWord.Text = "保存中";//
  393. btnScreenRecording.IsEnabled = false;
  394. new Thread(new ThreadStart(new Action(() =>
  395. {
  396. while (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath + "temprs/"))
  397. {
  398. Thread.Sleep(100);
  399. }
  400. Dispatcher.Invoke(() =>
  401. {
  402. btnScreenRecording.IsEnabled = true;
  403. TxbRecordScreenWord.Text = "录屏";
  404. });
  405. }))).Start();
  406. }
  407. /// <summary>
  408. /// 上传事件
  409. /// </summary>
  410. /// <param name="sender"></param>
  411. /// <param name="e"></param>
  412. private void BtnUpload_Click(object sender, RoutedEventArgs e)
  413. {
  414. if (APP.IsLoginType == false)
  415. {
  416. Login();
  417. return;
  418. }
  419. if (APP.fileDirectoryWindow == null)
  420. {
  421. APP.fileDirectoryWindow = new FileDirectoryWindow();
  422. //APP.fileDirectoryWindow.Topmost = true;
  423. APP.fileDirectoryWindow.Owner = this;
  424. }
  425. else
  426. {
  427. APP.fileDirectoryWindow.Initialize();
  428. }
  429. APP.fileDirectoryWindow.ShowDialog();
  430. }
  431. /// <summary>
  432. /// 关闭事件
  433. /// </summary>
  434. /// <param name="sender"></param>
  435. /// <param name="e"></param>
  436. private void BtnDown_Click(object sender, RoutedEventArgs e)
  437. {
  438. if (IsFirstR)
  439. {
  440. APP.Killffmpeg();
  441. APP.SaveWkData();
  442. APP.SaveDraw();
  443. Thread.Sleep(100);
  444. System.Environment.Exit(0);
  445. }
  446. else
  447. {
  448. System.Windows.MessageBox.Show("当前正在录制,请先停止录制。");
  449. return;
  450. //MessageBoxResult dr = System.Windows.MessageBox.Show("当前正在录制,是否停止录制?", "提示", MessageBoxButton.OKCancel);
  451. //if (dr == MessageBoxResult.OK)
  452. //{
  453. // APP.SaveWkData();
  454. // APP.SaveDraw();
  455. // BtnStop_Click(null, null);
  456. // while (!IsFirstR)
  457. // {
  458. // Thread.Sleep(100);
  459. // }
  460. // System.Environment.Exit(0);
  461. //}
  462. //else
  463. //{
  464. // return;
  465. //}
  466. }
  467. }
  468. /// <summary>
  469. /// 设置 保存事件
  470. /// </summary>
  471. /// <param name="sender"></param>
  472. /// <param name="e"></param>
  473. private void BtnSave_Click(object sender, RoutedEventArgs e)
  474. {
  475. #region 合法性判断
  476. //if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
  477. //{
  478. // System.Windows.MessageBox.Show("路径不可为空!");
  479. // return;
  480. //}
  481. //string temp = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + APP.WKData.WkName.Trim() + "/";
  482. //if (!APP.WKData.WkPath.Equals(temp))
  483. //{
  484. // APP.WKData.WkPath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + APP.WKData.WkName.Trim() + "/";
  485. // if (FileToolsCommon.IsExistDirectory(APP.WKData.WkPath))
  486. // {
  487. // //微课已存在
  488. // MessageBoxResult dr = System.Windows.MessageBox.Show("讲解已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
  489. // if (dr == MessageBoxResult.OK)
  490. // {
  491. // FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
  492. // }
  493. // else
  494. // {
  495. // return;
  496. // }
  497. // }
  498. // //创建文件夹
  499. // FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  500. //}
  501. #endregion
  502. ImgRecord.Visibility = Visibility.Visible;//设置结束时可录制
  503. ImgRecordTwo.Visibility = Visibility.Collapsed;//设置结束时可录制
  504. BtnRecord.IsEnabled = true;//设置结束时可录制
  505. if (rbnMP4.IsChecked == true)
  506. {
  507. //存储文件
  508. FileToolsCommon.SetConfigValue("VideoType", "1");
  509. }
  510. else if (rbnFLV.IsChecked == true)
  511. {
  512. FileToolsCommon.SetConfigValue("VideoType", "2");
  513. }
  514. else
  515. {
  516. FileToolsCommon.SetConfigValue("VideoType", "3");
  517. }
  518. if (rbnY.IsChecked == true)
  519. {
  520. FileToolsCommon.SetConfigValue("IsSound", "true");
  521. }
  522. else
  523. {
  524. FileToolsCommon.SetConfigValue("IsSound", "false");
  525. }
  526. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  527. if (rbnRight.IsChecked == true)
  528. {
  529. FileToolsCommon.SetConfigValue("CameraPosition", "1");
  530. }
  531. else if (rbnLeft.IsChecked == true)
  532. {
  533. FileToolsCommon.SetConfigValue("CameraPosition", "2");
  534. }
  535. else if (rbnRightUnder.IsChecked == true)
  536. {
  537. FileToolsCommon.SetConfigValue("CameraPosition", "3");
  538. }
  539. else if (rbnLeftUnder.IsChecked == true)
  540. {
  541. FileToolsCommon.SetConfigValue("CameraPosition", "4");
  542. }
  543. APP.CameraPosition = FileToolsCommon.GetConfigValue("CameraPosition");
  544. GridMain.Visibility = Visibility.Visible;
  545. gridSetUp.Visibility = Visibility.Collapsed;
  546. imgPlayerRight.Visibility = Visibility.Collapsed;
  547. imgPlayerLeft.Visibility = Visibility.Collapsed;
  548. imgPlayerRightUnder.Visibility = Visibility.Collapsed;
  549. imgPlayerLeftUnder.Visibility = Visibility.Collapsed;
  550. }
  551. /// <summary>
  552. /// 设置事件
  553. /// </summary>
  554. /// <param name="sender"></param>
  555. /// <param name="e"></param>
  556. private void BtnSetUp_Click(object sender, RoutedEventArgs e)
  557. {
  558. if (!TxbRecordingWord.Text.Equals("暂停"))
  559. {
  560. GridMain.Visibility = Visibility.Collapsed;
  561. gridSetUp.Visibility = Visibility.Visible;
  562. txbStoragePath.Content = APP.WKData.WkPath;
  563. ImgRecord.Visibility = Visibility.Collapsed;//设置时不可录制
  564. ImgRecordTwo.Visibility = Visibility.Visible;//设置时不可录制
  565. BtnRecord.IsEnabled = false;//设置时不可录制
  566. /// < !--摄像头位置 1.右上 2.左上 3.右下 4.左下-- >
  567. if ("1".Equals(APP.CameraPosition))
  568. {
  569. rbnRight.IsChecked = true;
  570. }
  571. else if ("2".Equals(APP.CameraPosition))
  572. {
  573. rbnLeft.IsChecked = true;
  574. }
  575. else if ("3".Equals(APP.CameraPosition))
  576. {
  577. rbnRightUnder.IsChecked = true;
  578. }
  579. else if ("4".Equals(APP.CameraPosition))
  580. {
  581. rbnLeftUnder.IsChecked = true;
  582. }
  583. }
  584. }
  585. /// <summary>
  586. /// 设置 浏览事件
  587. /// </summary>
  588. /// <param name="sender"></param>
  589. /// <param name="e"></param>
  590. private void BtnBrowse_Click(object sender, RoutedEventArgs e)
  591. {
  592. System.Diagnostics.Process.Start(APP.WKData.WkPath);
  593. //string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  594. //Ofd = new System.Windows.Forms.FolderBrowserDialog();
  595. //Result = Ofd.ShowDialog();
  596. //if (Result == System.Windows.Forms.DialogResult.OK)
  597. //{
  598. // if (Ofd.SelectedPath != "")
  599. // {
  600. // //txbStoragePath.Text = Ofd.SelectedPath;
  601. // //string ApplicationData = ZConfig.dataPath + "fileStorageAddress.txt";
  602. // //string temp = ofd.SelectedPath;
  603. // //System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  604. // }
  605. //}
  606. }
  607. /// <summary>
  608. /// 画笔颜色事件 白色
  609. /// </summary>
  610. /// <param name="sender"></param>
  611. /// <param name="e"></param>
  612. private void BtnWhite_Click(object sender, RoutedEventArgs e)
  613. {
  614. ////创建 DrawingAttributes 类的一个实例
  615. //drawingAttributes = new DrawingAttributes();
  616. ////将 InkCanvas 的 DefaultDrawingAttributes 属性的值赋成创建的 DrawingAttributes 类的对象的引用
  617. ////InkCanvas 通过 DefaultDrawingAttributes 属性来获取墨迹的各种设置,该属性的类型为 DrawingAttributes 型
  618. //blackboard_canvas.DefaultDrawingAttributes = drawingAttributes;
  619. ////设置 DrawingAttributes 的 Color 属性设置颜色
  620. drawingAttributes.Color = Colors.White;
  621. Color = Colors.White;
  622. }
  623. /// <summary>
  624. /// 画笔颜色事件 红色
  625. /// </summary>
  626. /// <param name="sender"></param>
  627. /// <param name="e"></param>
  628. private void BtnRed_Click(object sender, RoutedEventArgs e)
  629. {
  630. //设置 DrawingAttributes 的 Color 属性设置颜色
  631. drawingAttributes.Color = Colors.Red;
  632. Color = Colors.Red;
  633. imgRed.Visibility = Visibility.Visible;
  634. imgGray.Visibility = Visibility.Collapsed;
  635. imgCyanBlue.Visibility = Visibility.Collapsed;
  636. imgYellow.Visibility = Visibility.Collapsed;
  637. imgBlue.Visibility = Visibility.Collapsed;
  638. }
  639. /// <summary>
  640. /// 画笔颜色事件 黑色
  641. /// </summary>
  642. /// <param name="sender"></param>
  643. /// <param name="e"></param>
  644. private void BtnGray_Click(object sender, RoutedEventArgs e)
  645. {
  646. drawingAttributes.Color = Colors.Black;
  647. Color = Colors.Black;
  648. imgRed.Visibility = Visibility.Collapsed;
  649. imgGray.Visibility = Visibility.Visible;
  650. imgCyanBlue.Visibility = Visibility.Collapsed;
  651. imgYellow.Visibility = Visibility.Collapsed;
  652. imgBlue.Visibility = Visibility.Collapsed;
  653. }
  654. /// <summary>
  655. /// 画笔颜色事件 青色
  656. /// </summary>
  657. /// <param name="sender"></param>
  658. /// <param name="e"></param>
  659. private void BtnCyanBlue_Click(object sender, RoutedEventArgs e)
  660. {
  661. drawingAttributes.Color = Colors.LimeGreen;
  662. Color = Colors.LimeGreen;
  663. imgRed.Visibility = Visibility.Collapsed;
  664. imgGray.Visibility = Visibility.Collapsed;
  665. imgCyanBlue.Visibility = Visibility.Visible;
  666. imgYellow.Visibility = Visibility.Collapsed;
  667. imgBlue.Visibility = Visibility.Collapsed;
  668. }
  669. /// <summary>
  670. /// 画笔颜色事件 黄色
  671. /// </summary>
  672. /// <param name="sender"></param>
  673. /// <param name="e"></param>
  674. private void BtnYellow_Click(object sender, RoutedEventArgs e)
  675. {
  676. drawingAttributes.Color = Colors.Gold;
  677. Color = Colors.Gold;
  678. imgRed.Visibility = Visibility.Collapsed;
  679. imgGray.Visibility = Visibility.Collapsed;
  680. imgCyanBlue.Visibility = Visibility.Collapsed;
  681. imgYellow.Visibility = Visibility.Visible;
  682. imgBlue.Visibility = Visibility.Collapsed;
  683. }
  684. /// <summary>
  685. /// 画笔颜色事件 蓝色
  686. /// </summary>
  687. /// <param name="sender"></param>
  688. /// <param name="e"></param>
  689. private void BtnBlue_Click(object sender, RoutedEventArgs e)
  690. {
  691. drawingAttributes.Color = Colors.DeepSkyBlue;
  692. Color = Colors.DeepSkyBlue;
  693. imgRed.Visibility = Visibility.Collapsed;
  694. imgGray.Visibility = Visibility.Collapsed;
  695. imgCyanBlue.Visibility = Visibility.Collapsed;
  696. imgYellow.Visibility = Visibility.Collapsed;
  697. imgBlue.Visibility = Visibility.Visible;
  698. }
  699. /// <summary>
  700. /// 画笔粗细事件 细
  701. /// </summary>
  702. /// <param name="sender"></param>
  703. /// <param name="e"></param>
  704. private void RbnFine_Click(object sender, RoutedEventArgs e)
  705. {
  706. drawingAttributes.Width = 1;
  707. drawingAttributes.Height = 1;
  708. PenSize = 1;
  709. }
  710. /// <summary>
  711. /// 画笔粗细事件 中
  712. /// </summary>
  713. /// <param name="sender"></param>
  714. /// <param name="e"></param>
  715. private void RbnIn_Click(object sender, RoutedEventArgs e)
  716. {
  717. drawingAttributes.Width = 3;
  718. drawingAttributes.Height = 3;
  719. PenSize = 3;
  720. }
  721. /// <summary>
  722. /// 画笔粗细事件 粗
  723. /// </summary>
  724. /// <param name="sender"></param>
  725. /// <param name="e"></param>
  726. private void RbnCrude_Click(object sender, RoutedEventArgs e)
  727. {
  728. drawingAttributes.Width = 5;
  729. drawingAttributes.Height = 5;
  730. PenSize = 5;
  731. }
  732. /// <summary>
  733. /// 登陆事件
  734. /// </summary>
  735. /// <param name="sender"></param>
  736. /// <param name="e"></param>
  737. private void BtnLoginType_Click(object sender, RoutedEventArgs e)
  738. {
  739. Login();
  740. }
  741. /// <summary>
  742. /// 登陆
  743. /// </summary>
  744. private void Login()
  745. {
  746. if (APP.W_LoginWindow == null)
  747. {
  748. APP.W_LoginWindow = new LoginWindow();
  749. APP.W_LoginWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
  750. APP.W_LoginWindow.Owner = this;
  751. }
  752. else
  753. {
  754. APP.W_LoginWindow.Initialize();
  755. }
  756. APP.W_LoginWindow.ShowDialog();
  757. if (APP.IsLoginType)
  758. {
  759. txbLoginType.Text = APP.UserInfo.Username;
  760. ImgUpload.Visibility = Visibility.Visible;
  761. ImgUploadTwo.Visibility = Visibility.Collapsed;
  762. }
  763. else
  764. {
  765. txbLoginType.Text = "未登录";
  766. ImgUpload.Visibility = Visibility.Collapsed;
  767. ImgUploadTwo.Visibility = Visibility.Visible;
  768. }
  769. }
  770. /// <summary>
  771. /// 截图事件
  772. /// </summary>
  773. /// <param name="sender"></param>
  774. /// <param name="e"></param>
  775. private void BtnScreenshot_Click(object sender, RoutedEventArgs e)
  776. {
  777. string time = GetTimeStamp();
  778. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + time + ".jpg";
  779. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), desktopPath,false,out BitmapImage bitmap);
  780. if (this.WindowState == WindowState.Normal)//截图隐藏窗口
  781. {
  782. this.WindowState = WindowState.Minimized;
  783. }
  784. if (APP.W_JieTuWindow != null)
  785. {
  786. APP.W_JieTuWindow.initialization();
  787. APP.W_JieTuWindow.Screenshot();
  788. APP.W_JieTuWindow.WindowState = WindowState.Maximized;
  789. APP.W_JieTuWindow.Visibility = Visibility.Visible;
  790. }
  791. else
  792. {
  793. APP.W_JieTuWindow = new JieTuWindow();
  794. // 订阅事件
  795. APP.W_JieTuWindow.ChangeTextEvent += new ChangeTextHandler(frm_ChangeTextEvent);
  796. APP.W_JieTuWindow.click_closeJietuWindowClick += JietuWindow_click_closeJietuWindowClick;
  797. APP.W_JieTuWindow.Show();
  798. }
  799. //imgCanvas.Source = new BitmapImage(new Uri(desktopPath));
  800. }
  801. /// <summary>
  802. /// 截图关闭窗口
  803. /// </summary>
  804. /// <param name="text"></param>
  805. private void frm_ChangeTextEvent(string text)
  806. {
  807. if ("关闭窗口".Equals(text))
  808. {
  809. if (this.WindowState == WindowState.Minimized)//截图完恢复窗口
  810. {
  811. this.WindowState = WindowState.Normal;
  812. }
  813. if (!string.IsNullOrWhiteSpace(APP.ImgPath) && File.Exists(APP.ImgPath))
  814. {
  815. if (APP.pageData.currpage == 0)
  816. {
  817. APP.pageData.pagenum += 1;
  818. APP.pageData.currpage = APP.pageData.pagenum;
  819. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  820. }
  821. if (APP.PageDrawList.Count >= APP.pageData.currpage)
  822. {
  823. APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath = APP.ImgPath;//zxycs
  824. APP.PageDrawList[APP.pageData.currpage - 1].PdfImagePath = APP.ImgPath;
  825. }
  826. else
  827. {
  828. Model_DrawData model_DrawData = new Model_DrawData();
  829. model_DrawData.PageImagePath = APP.ImgPath;
  830. model_DrawData.PdfImagePath = APP.ImgPath;
  831. APP.PageDrawList.Add(model_DrawData);
  832. }
  833. if (APP.PageDrawList.Count >= APP.pageData.currpage && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  834. {
  835. imgDocumentation.Source = null;
  836. imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  837. APP.PageDrawList[APP.pageData.currpage - 1].ImgDocumentation = false;
  838. ImgPrint.Visibility = Visibility.Visible;//截图成功可打印
  839. ImgPrintTwo.Visibility = Visibility.Collapsed;
  840. btnPrint.IsEnabled = true;
  841. }
  842. }
  843. }
  844. }
  845. /// <summary>
  846. /// 截图关闭 非正常关闭截图时,截图清空
  847. /// </summary>
  848. private void JietuWindow_click_closeJietuWindowClick()
  849. {
  850. if (this.WindowState == WindowState.Minimized)//截图完恢复窗口
  851. {
  852. this.WindowState = WindowState.Normal;
  853. }
  854. APP.W_JieTuWindow = null;
  855. }
  856. /// <summary>
  857. /// 获取时间戳
  858. /// </summary>
  859. /// <returns></returns>
  860. public string GetTimeStamp()
  861. {
  862. TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  863. return Convert.ToInt64(ts.TotalSeconds).ToString();
  864. }
  865. /// <summary>
  866. /// 导入事件
  867. /// </summary>
  868. /// <param name="sender"></param>
  869. /// <param name="e"></param>
  870. private void BtnImport_Click(object sender, RoutedEventArgs e)
  871. {
  872. try
  873. {
  874. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  875. ofd = new System.Windows.Forms.OpenFileDialog
  876. {
  877. Filter = "文档|*.docx;*.doc;*ppt",
  878. InitialDirectory = desktopPath,
  879. Multiselect = false,
  880. AddExtension = true,
  881. DereferenceLinks = true
  882. };
  883. new Thread(
  884. o =>
  885. {
  886. Thread.Sleep(400);
  887. Dispatcher.Invoke(new Action(() =>
  888. {
  889. OpenDialog();
  890. }
  891. ));
  892. })
  893. {
  894. IsBackground = true
  895. }.Start();
  896. }
  897. catch (Exception ex)
  898. {
  899. LogHelper.WriteErrLog("【导入(BtnImport_Click)" + ex.Message, ex);
  900. }
  901. }
  902. /// <summary>
  903. /// 导入文档
  904. /// </summary>
  905. private void OpenDialog()
  906. {
  907. result = ofd.ShowDialog();
  908. if (result == System.Windows.Forms.DialogResult.OK)
  909. {
  910. if (ofd.FileName != "")
  911. {
  912. APP.myloading.Show();
  913. #region PPT转PDF
  914. string filepath = ofd.FileName;
  915. string path = ofd.SafeFileName.Replace(".ppt", "").Trim();
  916. string type = ofd.SafeFileName.Replace(".ppt", "typezsygppt").Trim();
  917. if (type.Contains("typezsygppt"))//ppt
  918. {
  919. try
  920. {
  921. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  922. path = pathTemp + path + ".pdf";
  923. //PPT转PDF
  924. Presentation ppt = new Presentation(filepath);
  925. ppt.Save(path, Aspose.Slides.Export.SaveFormat.Pdf);
  926. #endregion
  927. #region PDF转图片
  928. // 图片绝对路径集合
  929. List<string> images = new List<string>();
  930. string directoryPath = pathTemp;
  931. //aspose许可证
  932. //Aspose.Pdf.License l = new Aspose.Pdf.License();
  933. //string licenseName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Aspose.Total.Product.Family.lic");
  934. //l.SetLicense(licenseName);
  935. //定义Jpeg转换设备
  936. Aspose.Pdf.Document document = new Aspose.Pdf.Document(path);
  937. var device = new Aspose.Pdf.Devices.JpegDevice();
  938. //int quality = int.Parse(this.comboBox1.SelectedItem.ToString());
  939. //directoryPath += quality;
  940. Directory.CreateDirectory(directoryPath);
  941. //默认质量为100,设置质量的好坏与处理速度不成正比,甚至是设置的质量越低反而花的时间越长,怀疑处理过程是先生成高质量的再压缩
  942. device = new Aspose.Pdf.Devices.JpegDevice(100);
  943. //遍历每一页转为jpg
  944. for (var i = 1; i <= document.Pages.Count; i++)
  945. {
  946. long ii = Timestamp();
  947. string filePathOutPut = Path.Combine(directoryPath, string.Format("{0}{1}.jpg", ii, i));
  948. images.Add(filePathOutPut);
  949. FileStream fs = new FileStream(filePathOutPut, FileMode.OpenOrCreate);
  950. try
  951. {
  952. device.Process(document.Pages[i], fs);
  953. fs.Close();
  954. }
  955. catch (Exception ex)
  956. {
  957. fs.Close();
  958. File.Delete(filePathOutPut);
  959. }
  960. }
  961. #endregion
  962. string[] page = images.ToArray();
  963. int num = 0;
  964. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  965. {
  966. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  967. {
  968. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  969. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  970. APP.PageDrawList[i].PageNum = i + 1;
  971. APP.PageDrawList[i].ImgDocumentation = true;
  972. }
  973. else
  974. {
  975. Model_DrawData model_DrawData = new Model_DrawData();
  976. model_DrawData.PageImagePath = page[i - APP.pageData.pagenum];
  977. model_DrawData.PdfImagePath = page[i - APP.pageData.pagenum];
  978. model_DrawData.PageNum = i + 1;
  979. model_DrawData.ImgDocumentation = true;
  980. APP.PageDrawList.Add(model_DrawData);
  981. }
  982. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  983. ImgPrintTwo.Visibility = Visibility.Collapsed;
  984. btnPrint.IsEnabled = true;
  985. APP.SaveDraw();
  986. num++;
  987. }
  988. if (num > 0)
  989. {
  990. APP.pageData.currpage = APP.pageData.pagenum + 1;
  991. APP.pageData.pagenum += num;
  992. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  993. }
  994. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  995. {
  996. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  997. imgCanvas.Source = null;
  998. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  999. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1000. btnScreenshot.IsEnabled = false;
  1001. }
  1002. else
  1003. {
  1004. imgDocumentation.Source = null;
  1005. imgCanvas.Source = null;
  1006. ///截图可用
  1007. ImgScreenshot.Visibility = Visibility.Visible;
  1008. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1009. btnScreenshot.IsEnabled = true;
  1010. }
  1011. APP.myloading.Hide();
  1012. }
  1013. catch (Exception ex)
  1014. {
  1015. APP.myloading.Hide();
  1016. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog PPT)" + ex.Message, ex);
  1017. }
  1018. }
  1019. else//word
  1020. {
  1021. try
  1022. {
  1023. string paths = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1024. string[] page = ConvertWordToImage(filepath, paths, "", 0, 0, null, 0).ToArray();
  1025. int num = 0;
  1026. for (int i = 0 + APP.pageData.pagenum; i < page.Length + APP.pageData.pagenum; i++)//给画板模型加图片路径
  1027. {
  1028. if (APP.PageDrawList != null && APP.PageDrawList.Count > i)
  1029. {
  1030. APP.PageDrawList[i].PageImagePath = page[i - APP.pageData.pagenum]; //zxycs
  1031. APP.PageDrawList[i].PdfImagePath = page[i - APP.pageData.pagenum];
  1032. APP.PageDrawList[i].PageNum = i + 1;
  1033. APP.PageDrawList[i].ImgDocumentation = true;
  1034. }
  1035. else
  1036. {
  1037. Model_DrawData model_DrawData = new Model_DrawData();
  1038. model_DrawData.PageImagePath = page[i - APP.pageData.pagenum];
  1039. model_DrawData.PdfImagePath = page[i - APP.pageData.pagenum];
  1040. model_DrawData.PageNum = i + 1;
  1041. model_DrawData.ImgDocumentation = true;
  1042. APP.PageDrawList.Add(model_DrawData);
  1043. }
  1044. ImgPrint.Visibility = Visibility.Visible;//导入成功可打印
  1045. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1046. btnPrint.IsEnabled = true;
  1047. APP.SaveDraw();
  1048. num++;
  1049. }
  1050. if (num > 0)
  1051. {
  1052. APP.pageData.currpage = APP.pageData.pagenum + 1;
  1053. APP.pageData.pagenum += num;
  1054. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1055. }
  1056. if (APP.pageData.currpage > 0 && APP.pageData.currpage < APP.PageDrawList.Count)
  1057. {
  1058. imgCanvas.Source = null;
  1059. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1060. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1061. btnScreenshot.IsEnabled = false;
  1062. imgDocumentation.Visibility = Visibility.Visible;
  1063. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));//给当前页面展示图片
  1064. }
  1065. else
  1066. {
  1067. imgDocumentation.Source = null;
  1068. imgCanvas.Source = null;
  1069. ///截图可用
  1070. ImgScreenshot.Visibility = Visibility.Visible;
  1071. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1072. btnScreenshot.IsEnabled = true;
  1073. }
  1074. APP.myloading.Hide();
  1075. }
  1076. catch (Exception ex)
  1077. {
  1078. APP.myloading.Hide();
  1079. LogHelper.WriteErrLog("【XHMicroLessonSystemWindow】(OpenDialog 导入文档)" + ex.Message, ex);
  1080. }
  1081. }
  1082. }
  1083. }
  1084. }
  1085. /// <summary>
  1086. /// 返回一个时间戳到毫秒
  1087. /// </summary>
  1088. /// <returns></returns>
  1089. public static long Timestamp()
  1090. {
  1091. TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  1092. long timestr = Convert.ToInt64(ts.TotalMilliseconds);
  1093. return timestr;
  1094. }
  1095. #region 录制窗口
  1096. #region 变量
  1097. /// <summary>
  1098. /// 视频保存路径
  1099. /// </summary>
  1100. //string RecordingPath;
  1101. /// <summary>
  1102. /// 图片保存路径
  1103. /// </summary>
  1104. string ImgPath;
  1105. /// <summary>
  1106. /// 音频保存路径名
  1107. /// </summary>
  1108. string AudioPathName;
  1109. /// <summary>
  1110. /// 视频保存路径名
  1111. /// </summary>
  1112. string VideoSavePathName;
  1113. /// <summary>
  1114. /// 暂停录制
  1115. /// </summary>
  1116. bool IsSuspendR = true;
  1117. /// <summary>
  1118. /// 录制是否已停止
  1119. /// </summary>
  1120. bool IsFirstR = true;
  1121. /// <summary>
  1122. /// 图片
  1123. /// </summary>
  1124. List<string> RsImgName = null;
  1125. /// <summary>
  1126. /// 是否开始截图计数
  1127. /// </summary>
  1128. bool IsStartCount = false;
  1129. #endregion
  1130. /// <summary>
  1131. /// 录制窗口内容
  1132. /// </summary>
  1133. /// <param name="sender"></param>
  1134. /// <param name="e"></param>
  1135. private void BtnRecord_Click(object sender, RoutedEventArgs e)
  1136. {
  1137. if (APP.pageData.currpage > 0)
  1138. {
  1139. blackboard_canvas.Visibility = Visibility.Visible;
  1140. }
  1141. else
  1142. {
  1143. System.Windows.MessageBox.Show("请先导入文档或截图!");
  1144. return;
  1145. }
  1146. //btnStop.IsEnabled = true;//停止录制按钮可点击
  1147. StartRecord();
  1148. }
  1149. /// <summary>
  1150. /// 停止录制窗口内容
  1151. /// </summary>
  1152. /// <param name="sender"></param>
  1153. /// <param name="e"></param>
  1154. private void BtnStop_Click(object sender, RoutedEventArgs e)
  1155. {
  1156. blackboard_canvas.Visibility = Visibility.Collapsed;
  1157. EndRecord();
  1158. }
  1159. System.Timers.Timer timer;
  1160. /// <summary>
  1161. /// 设置录屏文件地址
  1162. /// </summary>
  1163. void SetUpVideoPathName()
  1164. {
  1165. }
  1166. /// <summary>
  1167. /// 开始录制和暂停录制
  1168. /// </summary>
  1169. void StartRecord()
  1170. {
  1171. if (IsSuspendR)
  1172. {
  1173. if (IsFirstR)//是否第一次录制 初始化录制
  1174. {
  1175. #region 计时器初始化
  1176. if (t == null)
  1177. {
  1178. t = new DispatcherTimer();
  1179. t.Tick += OnTimer;
  1180. t.Interval = new TimeSpan(0, 0, 0, 1);
  1181. t.IsEnabled = true;
  1182. t.Start();
  1183. }
  1184. t.Interval = new TimeSpan(0, 0, 0, 1);
  1185. txbTime.Visibility = Visibility.Visible;
  1186. Stack();
  1187. #endregion
  1188. VideoInfo = new Model_Video();
  1189. VideoInfo.VideoType = (Enum_VideoType)int.Parse(FileToolsCommon.GetConfigValue("VideoType"));
  1190. VideoInfo.WkType = Enum_WKVidetype.RecordingLessons;
  1191. ImgPath = APP.WKData.WkPath + "temp/Image/";
  1192. AudioPathName = APP.WKData.WkPath + "temp/audio/";
  1193. FileToolsCommon.DeleteDirectory(APP.WKData.WkPath + "temp/");
  1194. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  1195. FileToolsCommon.CreateDirectory(ImgPath);
  1196. FileToolsCommon.CreateDirectory(AudioPathName);
  1197. AudioPathName += APP.WKData.WkName + ".MP3";
  1198. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制." + VideoInfo.VideoType.ToString();
  1199. int num = 1;
  1200. while (FileToolsCommon.IsExistFile(VideoSavePathName))
  1201. {
  1202. VideoSavePathName = APP.WKData.WkPath + APP.WKData.WkName + "_录制_" + num + "." + VideoInfo.VideoType.ToString();
  1203. num++;
  1204. }
  1205. #region 设置录屏唯一 废弃
  1206. //if (FileToolsCommon.IsExistFile(VideoSavePathName))
  1207. //{
  1208. // MessageBoxResult dr = System.Windows.MessageBox.Show("课程已录制,是否覆盖?", "提示", MessageBoxButton.OKCancel);
  1209. // if (dr == MessageBoxResult.OK)
  1210. // {
  1211. // try
  1212. // {
  1213. // FileToolsCommon.DeleteFile(VideoSavePathName);
  1214. // APP.VideoList.RemoveAll(x => x.VideoPath == VideoSavePathName);
  1215. // }
  1216. // catch (Exception ex)
  1217. // {
  1218. // LogHelper.WriteErrLog("【录制】(StartRecord)无法移除视频," + ex.Message, ex);
  1219. // }
  1220. // }
  1221. // else
  1222. // {
  1223. // return;
  1224. // }
  1225. //}
  1226. #endregion
  1227. #region 禁用按钮
  1228. ImgPrint.Visibility = Visibility.Collapsed;//录制中不可打印
  1229. ImgPrintTwo.Visibility = Visibility.Visible;
  1230. btnPrint.IsEnabled = false;
  1231. ImgScreenshot.Visibility = Visibility.Collapsed;//录制中不可截图
  1232. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1233. btnScreenshot.IsEnabled = false;
  1234. ImgImport.Visibility = Visibility.Collapsed;//录制中不可导入文档
  1235. ImgImportTwo.Visibility = Visibility.Visible;
  1236. btnImport.IsEnabled = false;
  1237. ImgScreenRecording.Visibility = Visibility.Collapsed;//录制中不可录屏
  1238. ImgScreenRecordingTwo.Visibility = Visibility.Visible;
  1239. btnScreenRecording.IsEnabled = false;
  1240. ImgUpload.Visibility = Visibility.Collapsed;//录制中不可上传
  1241. ImgUploadTwo.Visibility = Visibility.Visible;
  1242. btnUpload.IsEnabled = false;
  1243. ImgSetUp.Visibility = Visibility.Collapsed;//录制中不可设置
  1244. ImgSetUpTwo.Visibility = Visibility.Visible;
  1245. btnSetUp.IsEnabled = false;
  1246. btnLoginType.IsEnabled = false;
  1247. #endregion
  1248. #region 录像倒计时
  1249. if (APP.W_CountdownWindow == null)
  1250. {
  1251. APP.W_CountdownWindow = new CountdownWindow();
  1252. //APP.W_CountdownWindow.Topmost = true;
  1253. }
  1254. else
  1255. {
  1256. APP.W_CountdownWindow.Initialize();
  1257. //APP.W_CountdownWindow.Topmost = true;
  1258. }
  1259. APP.W_CountdownWindow.Show();
  1260. #endregion
  1261. IsFirstR = false;
  1262. RsImgName = new List<string>();
  1263. timer = new System.Timers.Timer(200);//设置执行一次(false)还是一直执行(true)
  1264. timer.AutoReset = true;//设置是否执行System.Timers.Timer.Elapsed事件
  1265. timer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
  1266. timer.Enabled = true; //启动计时器
  1267. }
  1268. //继续录制
  1269. IsSuspendR = false;
  1270. //BtnRecording.Content = "暂停录制";
  1271. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_23.png"));
  1272. ImgStop.Visibility = Visibility.Collapsed;
  1273. ImgStopTwo.Visibility = Visibility.Visible;
  1274. TxbRecordingWord.Text = "暂停";
  1275. Stack();
  1276. #region 2秒内不可点击
  1277. new Thread(new ThreadStart(new Action(() =>
  1278. {
  1279. Dispatcher.Invoke(() =>
  1280. {
  1281. BtnRecord.IsEnabled = false;
  1282. btnStop.IsEnabled = false;
  1283. });
  1284. Thread.Sleep(2000);
  1285. Dispatcher.Invoke(() =>
  1286. {
  1287. BtnRecord.IsEnabled = true;
  1288. btnStop.IsEnabled = true;
  1289. });
  1290. }))).Start();
  1291. #endregion
  1292. try
  1293. {
  1294. APP.FFmpeg.StartRecordingAudio(AudioPathName);
  1295. new Thread(new ThreadStart(new Action(() =>
  1296. {
  1297. Thread.Sleep(1000);
  1298. Dispatcher.Invoke(() =>
  1299. {
  1300. IsStartCount = true;
  1301. //timer.Start();
  1302. });
  1303. }))).Start();
  1304. }
  1305. catch (Exception ex)
  1306. {
  1307. System.Windows.MessageBox.Show(ex.Message);
  1308. }
  1309. }
  1310. else
  1311. {
  1312. //暂停
  1313. IsSuspendR = true;
  1314. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
  1315. ImgStop.Visibility = Visibility.Visible;
  1316. ImgStopTwo.Visibility = Visibility.Collapsed;
  1317. TxbRecordingWord.Text = "继续";
  1318. TimeOut();
  1319. #region 2秒内不可点击
  1320. new Thread(new ThreadStart(new Action(() =>
  1321. {
  1322. Dispatcher.Invoke(() =>
  1323. {
  1324. BtnRecord.IsEnabled = false;
  1325. btnStop.IsEnabled = false;
  1326. });
  1327. Thread.Sleep(2000);
  1328. Dispatcher.Invoke(() =>
  1329. {
  1330. BtnRecord.IsEnabled = true;
  1331. btnStop.IsEnabled = true;
  1332. });
  1333. }))).Start();
  1334. #endregion
  1335. try
  1336. {
  1337. APP.FFmpeg.SuspendFFmpeg();
  1338. new Thread(new ThreadStart(new Action(() =>
  1339. {
  1340. while (APP.FFmpeg.myProcess != null)
  1341. {
  1342. Thread.Sleep(100);
  1343. }
  1344. IsStartCount = false;
  1345. }))).Start();
  1346. }
  1347. catch (Exception ex)
  1348. {
  1349. System.Windows.MessageBox.Show(ex.Message);
  1350. }
  1351. }
  1352. }
  1353. /// <summary>
  1354. /// 录制保存图片
  1355. /// </summary>
  1356. /// <param name="sender"></param>
  1357. /// <param name="e"></param>
  1358. private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  1359. {
  1360. if (IsStartCount)
  1361. {
  1362. try
  1363. {
  1364. Dispatcher.Invoke(() =>
  1365. {
  1366. string FilePathName = ImgPath + RsImgName.Count + ".png";
  1367. ImageHelper.SaveUIToImage(GridMain, FilePathName, (int)this.ActualWidth, (int)this.ActualHeight);
  1368. RsImgName.Add(FilePathName);
  1369. });
  1370. }
  1371. catch (Exception ex)
  1372. {
  1373. LogHelper.WriteErrLog("【录制】(Timer_Elapsed)生成图片错误:" + ex.Message, ex);
  1374. }
  1375. }
  1376. }
  1377. /// <summary>
  1378. /// 停止录制并生成录制文件
  1379. /// </summary>
  1380. void EndRecord()
  1381. {
  1382. if (!IsFirstR)
  1383. {
  1384. #region 恢复被禁用的按钮
  1385. ImgPrint.Visibility = Visibility.Visible;
  1386. ImgPrintTwo.Visibility = Visibility.Collapsed;
  1387. btnPrint.IsEnabled = true;
  1388. ImgScreenshot.Visibility = Visibility.Visible;
  1389. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1390. btnScreenshot.IsEnabled = true;
  1391. ImgImport.Visibility = Visibility.Visible;
  1392. ImgImportTwo.Visibility = Visibility.Collapsed;
  1393. btnImport.IsEnabled = true;
  1394. ImgScreenRecording.Visibility = Visibility.Visible;
  1395. ImgScreenRecordingTwo.Visibility = Visibility.Collapsed;
  1396. btnScreenRecording.IsEnabled = true;
  1397. ImgUpload.Visibility = Visibility.Visible;
  1398. ImgUploadTwo.Visibility = Visibility.Collapsed;
  1399. btnUpload.IsEnabled = true;
  1400. ImgSetUp.Visibility = Visibility.Visible;
  1401. ImgSetUpTwo.Visibility = Visibility.Collapsed;
  1402. btnSetUp.IsEnabled = true;
  1403. btnLoginType.IsEnabled = true;
  1404. //btnStop.IsEnabled = false;//停止录制按钮不可点击
  1405. #endregion
  1406. IsSuspendR = true;
  1407. ImgRecord.Source = new BitmapImage(new Uri("pack://application:,,,/Images/microLessonSystem_14.png"));
  1408. ImgStop.Visibility = Visibility.Visible;
  1409. ImgStopTwo.Visibility = Visibility.Collapsed;
  1410. TimeOut();
  1411. txbType.Text = "保存中";
  1412. #region 2秒内不可点击
  1413. new Thread(new ThreadStart(new Action(() =>
  1414. {
  1415. Dispatcher.Invoke(() =>
  1416. {
  1417. BtnRecord.IsEnabled = false;
  1418. btnStop.IsEnabled = false;
  1419. });
  1420. }))).Start();
  1421. #endregion
  1422. try
  1423. {
  1424. #region 清空画板数据
  1425. APP.pageData.currpage = 0;
  1426. APP.pageData.pagenum = 0;
  1427. myblackboard.clear();
  1428. APP.PageDrawList.Clear();
  1429. imgCanvas.Source = null;
  1430. imgDocumentation.Source = null;
  1431. #endregion
  1432. //缩略图
  1433. string ThumbnailPath = FileToolsCommon.GetDirectoryName(VideoSavePathName) + "ThumbnailPath/";
  1434. FileToolsCommon.CreateDirectory(ThumbnailPath);
  1435. //缩略图存储位置
  1436. string ThumbnailPathName = ThumbnailPath + FileToolsCommon.GetIOFileNameNoExtension(VideoSavePathName) + ".JPG";
  1437. int gridActWidth = (int)GridMain.ActualWidth;
  1438. int gridActHeight = (int)GridMain.ActualHeight;
  1439. APP.FFmpeg.StopFFmpeg(AudioPathName);
  1440. new Thread(new ThreadStart(new Action(() =>
  1441. {
  1442. //停止截图
  1443. while (APP.FFmpeg.myProcess != null)
  1444. {
  1445. Thread.Sleep(100);
  1446. }
  1447. Dispatcher.Invoke(() =>
  1448. {
  1449. IsStartCount = false;
  1450. timer.Stop();
  1451. });
  1452. //}))).Start();
  1453. //new Thread(new ThreadStart(new Action(() =>
  1454. //{
  1455. //判断音频是否存在 判断音频临时文件夹是否存在
  1456. if (!FileToolsCommon.IsExistFile(AudioPathName))
  1457. {
  1458. Thread.Sleep(100);
  1459. }
  1460. if (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(AudioPathName) + "temp/"))
  1461. {
  1462. Thread.Sleep(100);
  1463. }
  1464. APP.FFmpeg.SynthesisVideo(ImgPath, AudioPathName, VideoSavePathName, 5, gridActWidth, gridActHeight);
  1465. //}))).Start();
  1466. //new Thread(new ThreadStart(new Action(() =>
  1467. //{
  1468. while (!FileToolsCommon.IsExistFile(VideoSavePathName))
  1469. {
  1470. Thread.Sleep(100);
  1471. }
  1472. while (FileToolsCommon.IsExistDirectory(FileToolsCommon.GetDirectoryName(VideoSavePathName) + "temp/"))
  1473. {
  1474. Thread.Sleep(100);
  1475. }
  1476. Dispatcher.Invoke(() =>
  1477. {
  1478. BtnRecord.IsEnabled = true;
  1479. btnStop.IsEnabled = true;
  1480. TxbRecordingWord.Text = "录制";
  1481. End();
  1482. txbTime.Text = "";
  1483. txbTime.Visibility = Visibility.Hidden;
  1484. txbType.Text = "";
  1485. });
  1486. FileToolsCommon.DeleteFile(ThumbnailPathName);
  1487. VideoInfo.RSTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  1488. Thread.Sleep(500);
  1489. //VideoInfo.VideoSize = FileToolsCommon.GetFileSizeByMB(VideoSavePathName).ToString() + " MB";
  1490. VideoInfo.VideoPath = VideoSavePathName;
  1491. VideoInfo.ThumbnailPath = ThumbnailPathName;
  1492. APP.FFmpeg.GenerateThumbnails(VideoSavePathName, ThumbnailPathName);
  1493. VideoInfo.FileGuid = Guid.NewGuid().ToString();
  1494. VideoInfo.IsUpload = false;
  1495. VideoInfo.Uploaded = 0;
  1496. VideoInfo.Savefolder = APP.UserInfo.Schoolid + "/resource";
  1497. APP.VideoList.Add(VideoInfo);
  1498. //保存数据
  1499. APP.SaveWkData();
  1500. IsFirstR = true;
  1501. }))).Start();
  1502. //List<Model_Video> VideoList
  1503. }
  1504. catch (Exception ex)
  1505. {
  1506. System.Windows.MessageBox.Show(ex.Message);
  1507. }
  1508. }
  1509. }
  1510. #endregion
  1511. /// <summary>
  1512. /// 增加事件
  1513. /// </summary>
  1514. /// <param name="sender"></param>
  1515. /// <param name="e"></param>
  1516. private void BtnAdd_Click(object sender, RoutedEventArgs e)
  1517. {
  1518. if (APP.pageData.currpage > 0)
  1519. {
  1520. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  1521. }
  1522. if (IsStartCount && blackboard_canvas.Visibility == Visibility.Collapsed)
  1523. {
  1524. blackboard_canvas.Visibility = Visibility.Visible;
  1525. }
  1526. APP.pageData.pagenum += 1;
  1527. gridPage.Visibility = Visibility.Visible;//页码大于0 显示
  1528. APP.pageData.currpage = APP.pageData.pagenum;
  1529. //myblackboard.changepage(APP.pageData.currpage - 1);
  1530. ///清空页面图片UI
  1531. imgCanvas.Source = null;
  1532. imgDocumentation.Source = null;
  1533. ///画板模型增加一页
  1534. Model_DrawData model_DrawData = new Model_DrawData();
  1535. model_DrawData.PageNum = APP.pageData.currpage;
  1536. APP.PageDrawList.Add(model_DrawData);
  1537. //APP.SaveDraw();
  1538. if (btnImport.IsEnabled == true)
  1539. {
  1540. ///截图可用
  1541. ImgScreenshot.Visibility = Visibility.Visible;
  1542. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1543. btnScreenshot.IsEnabled = true;
  1544. }
  1545. }
  1546. /// <summary>
  1547. /// 打印事件
  1548. /// </summary>
  1549. /// <param name="sender"></param>
  1550. /// <param name="e"></param>
  1551. private void BtnPrint_Click(object sender, RoutedEventArgs e)
  1552. {
  1553. try
  1554. {
  1555. //3种情况 1.文档图片 2.截图图片 3.没有图片
  1556. iTextSharp.text.Document document = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 25, 25, 25, 25);
  1557. //iTextSharp.text.Rectangle page = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4., 250f);//cs
  1558. ////设置纸张横向
  1559. //document.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());
  1560. string imgPath = FileToolsCommon.GetFileAbsolutePath("temp");
  1561. FileToolsCommon.CreateFile(imgPath);
  1562. imgPath += "\\101.pdf";
  1563. iTextSharp.text.pdf.PdfWriter.GetInstance(document, new FileStream(imgPath, FileMode.Create, FileAccess.ReadWrite));
  1564. document.Open();
  1565. iTextSharp.text.Image image;
  1566. for (int i = 0; i < APP.PageDrawList.Count; i++)
  1567. {
  1568. long ii = Timestamp();
  1569. string directoryPath = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  1570. string filePathOutPut = Path.Combine(directoryPath, string.Format("print{0}{1}.jpg", ii, i));
  1571. RectangleF rectangleFs = new RectangleF();
  1572. MergerImg("", filePathOutPut, rectangleFs, out string errmsg);
  1573. image = iTextSharp.text.Image.GetInstance(filePathOutPut);
  1574. if (String.IsNullOrEmpty(APP.PageDrawList[i].PageImagePath))//没有图片
  1575. {
  1576. }
  1577. else if (APP.PageDrawList[i].ImgDocumentation == true)
  1578. {
  1579. image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
  1580. }
  1581. else
  1582. {
  1583. RectangleF rectangleF = new RectangleF();
  1584. rectangleF.Width = (float)APP.PageDrawList[i].ImageSizes.CenterX;
  1585. rectangleF.Height = (float)APP.PageDrawList[i].ImageSizes.CenterY;
  1586. rectangleF.X = (float)APP.PageDrawList[i].ImageLocation.X;
  1587. rectangleF.Y = (float)APP.PageDrawList[i].ImageLocation.Y;
  1588. string msg = string.Empty;
  1589. bool isImg = MergerImg(APP.PageDrawList[i].PageImagePath, filePathOutPut, rectangleF, out msg);
  1590. if (isImg)
  1591. {
  1592. image = iTextSharp.text.Image.GetInstance(filePathOutPut);
  1593. }
  1594. else
  1595. {
  1596. image = iTextSharp.text.Image.GetInstance(APP.PageDrawList[i].PageImagePath);
  1597. }
  1598. }
  1599. if (image.Height > iTextSharp.text.PageSize.A4.Height - 25)
  1600. {
  1601. image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
  1602. }
  1603. else if (image.Width > iTextSharp.text.PageSize.A4.Width - 25)
  1604. {
  1605. image.ScaleToFit(iTextSharp.text.PageSize.A4.Width - 25, iTextSharp.text.PageSize.A4.Height - 25);
  1606. }
  1607. image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
  1608. document.NewPage();
  1609. document.Add(image);
  1610. //iTextSharp.text.Chunk c1 = new iTextSharp.text.Chunk("Hello World");
  1611. //iTextSharp.text.Phrase p1 = new iTextSharp.text.Phrase();
  1612. //p1.Leading = 150; //行间距
  1613. //document.Add(p1);
  1614. }
  1615. Console.WriteLine("转换成功!");
  1616. document.Close();
  1617. }
  1618. catch (Exception ex)
  1619. {
  1620. Console.WriteLine("转换失败,原因:" + ex.Message);
  1621. }
  1622. //document.Close();
  1623. ////Console.ReadKey();
  1624. if (APP.W_PrintWindow == null)
  1625. {
  1626. APP.W_PrintWindow = new PrintWindow();
  1627. //APP.W_PrintWindow.Topmost = true;
  1628. APP.W_PrintWindow.Owner = this;
  1629. }
  1630. if (APP.PageDrawList.Count > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[0].PageImagePath))
  1631. {
  1632. APP.W_PrintWindow.Initialize(APP.PageDrawList[0].PageImagePath);
  1633. }
  1634. else
  1635. {
  1636. APP.W_PrintWindow.Initialize("");
  1637. }
  1638. APP.W_PrintWindow.ShowDialog();
  1639. //int pr = 1;
  1640. //string msg = string.Empty;
  1641. //string outPut = string.Empty;
  1642. //LatticeFileHelper.GeneratingPDF(@"G:\101.pdf", @"G:\102.TPF",out pr, out msg, out outPut);
  1643. //if(pr==0)
  1644. //{
  1645. // outPut = outPut.Replace("[", "").Replace("]","").Replace("\"","").Trim();
  1646. // APP.OutPut = outPut.Split(',');
  1647. // string defa = string.Empty;
  1648. // List<string>defaList= LatticeFileHelper.GetPrinterList(out defa);
  1649. // int printResult = 1;
  1650. // string standardError = string.Empty;
  1651. // string standardOutput = string.Empty;
  1652. // LatticeFileHelper.PrinterTPFFile(@"G:\102.TPF",1, /*defa*/"导出为WPS PDF", out printResult,out standardError,out standardOutput);
  1653. //}
  1654. }
  1655. /// 上一页
  1656. /// </summary>
  1657. /// <param name="sender"></param>
  1658. /// <param name="e"></param>
  1659. private void last_button_Click(object sender, RoutedEventArgs e)
  1660. {
  1661. if (APP.pageData.currpage > 1)
  1662. {
  1663. APP.pageData.currpage -= 1;
  1664. myblackboard.changepage(APP.pageData.currpage - 1);
  1665. if (btnImport.IsEnabled == true)
  1666. {
  1667. ///截图可用
  1668. ImgScreenshot.Visibility = Visibility.Visible;
  1669. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1670. btnScreenshot.IsEnabled = true;
  1671. }
  1672. if (APP.pageData.currpage <= APP.PageDrawList.Count)
  1673. {
  1674. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null)
  1675. {
  1676. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  1677. }
  1678. if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && APP.pageData.currpage > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  1679. {
  1680. //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));//cs
  1681. if (APP.PageDrawList[APP.pageData.currpage - 1].ImgDocumentation)
  1682. {
  1683. imgCanvas.Source = null;
  1684. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  1685. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1686. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1687. btnScreenshot.IsEnabled = false;
  1688. }
  1689. else
  1690. {
  1691. imgDocumentation.Source = null;
  1692. imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  1693. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  1694. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X > 0)
  1695. {
  1696. var group = IMG.FindResource("Imageview") as TransformGroup;
  1697. var transform = group.Children[1] as TranslateTransform;
  1698. #region 高低 缩放比例
  1699. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageSize != null)
  1700. {
  1701. var transform1 = group.Children[0] as ScaleTransform;
  1702. transform1.ScaleX = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX;
  1703. transform1.ScaleY = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY;
  1704. imgCanvas.Width = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterX;
  1705. imgCanvas.Height = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterY;
  1706. }
  1707. #endregion
  1708. #region XY轴
  1709. transform.X = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X;
  1710. transform.Y = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y;
  1711. #endregion
  1712. mouseDown = false;
  1713. }
  1714. }
  1715. }
  1716. else
  1717. {
  1718. imgCanvas.Source = null;
  1719. imgDocumentation.Source = null;
  1720. }
  1721. }
  1722. }
  1723. }
  1724. /// <summary>
  1725. /// 下一页
  1726. /// </summary>
  1727. /// <param name="sender"></param>
  1728. /// <param name="e"></param>
  1729. private void next_btn_Click(object sender, RoutedEventArgs e)
  1730. {
  1731. if (APP.pageData.currpage < APP.pageData.pagenum)
  1732. {
  1733. APP.pageData.currpage += 1;
  1734. myblackboard.changepage(APP.pageData.currpage - 1);
  1735. if (btnImport.IsEnabled == true)
  1736. {
  1737. ///截图可用
  1738. ImgScreenshot.Visibility = Visibility.Visible;
  1739. ImgScreenshotTwo.Visibility = Visibility.Collapsed;
  1740. btnScreenshot.IsEnabled = true;
  1741. }
  1742. if (APP.pageData.currpage <= APP.PageDrawList.Count)
  1743. {
  1744. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null)
  1745. {
  1746. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  1747. }
  1748. if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  1749. {
  1750. if (APP.PageDrawList[APP.pageData.currpage - 1].ImgDocumentation)
  1751. {
  1752. imgCanvas.Source = null;
  1753. imgDocumentation.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  1754. ImgScreenshot.Visibility = Visibility.Collapsed;//当前页为导入时不可截图
  1755. ImgScreenshotTwo.Visibility = Visibility.Visible;
  1756. btnScreenshot.IsEnabled = false;
  1757. }
  1758. else
  1759. {
  1760. imgDocumentation.Source = null;
  1761. imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  1762. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  1763. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X > 0)
  1764. {
  1765. var group = IMG.FindResource("Imageview") as TransformGroup;
  1766. #region 高低 缩放比例
  1767. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageSize != null)
  1768. {
  1769. var transform1 = group.Children[0] as ScaleTransform;
  1770. transform1.ScaleX = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX;
  1771. transform1.ScaleY = APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY;
  1772. imgCanvas.Width = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterX;
  1773. imgCanvas.Height = APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterY;
  1774. }
  1775. #endregion
  1776. #region 坐标XY轴
  1777. var transform = group.Children[1] as TranslateTransform;
  1778. transform.X = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X;
  1779. transform.Y = APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y;
  1780. #endregion
  1781. mouseDown = false;
  1782. }
  1783. }
  1784. }
  1785. else
  1786. {
  1787. imgCanvas.Source = null;
  1788. imgDocumentation.Source = null;
  1789. }
  1790. }
  1791. }
  1792. }
  1793. /// <summary>
  1794. /// 生成图片
  1795. /// </summary>
  1796. /// <param name="_path">图片地址</param>
  1797. /// <param name="_saveimg">保存位置</param>
  1798. /// <param name="_rectangle">图片位置</param>
  1799. /// <param name="errmsg">错误消息</param>
  1800. /// <returns></returns>
  1801. private bool MergerImg(string _path, string _saveimg, RectangleF _rectangle, out string errmsg)
  1802. {
  1803. errmsg = null;
  1804. try
  1805. {
  1806. Bitmap bitmap = null;
  1807. //创建要显示的图片对象,根据参数的个数设置宽度
  1808. Bitmap backgroudImg = new Bitmap((int)gridM.ActualWidth, (int)gridM.ActualHeight);
  1809. Graphics g = Graphics.FromImage(backgroudImg);
  1810. //清除画布,背景设置为白色
  1811. g.Clear(System.Drawing.Color.White);
  1812. if (!string.IsNullOrWhiteSpace(_path))
  1813. {
  1814. bitmap = ImageHelper.ReadBitmapFile(_path);
  1815. g.DrawImage(bitmap, _rectangle);
  1816. }
  1817. backgroudImg.Save(_saveimg);
  1818. g.Dispose();
  1819. backgroudImg.Dispose();
  1820. if (bitmap != null)
  1821. {
  1822. bitmap.Dispose();
  1823. }
  1824. GC.Collect();
  1825. return true;
  1826. }
  1827. catch (Exception ex)
  1828. {
  1829. errmsg = ex.Message;
  1830. LogHelper.WriteErrLog("【截图合成】(MergerImg)图片合成失败:" + ex.Message, ex);
  1831. return false;
  1832. }
  1833. }
  1834. /// <summary>
  1835. /// 将Word文档转换为图片的方法(该方法基于第三方DLL),你可以像这样调用该方法: ConvertPDF2Image("F:\\PdfFile.doc", "F:\\",
  1836. /// "ImageFile", 1, 20, ImageFormat.Png, 256);
  1837. /// </summary>
  1838. /// <param name="pdfInputPath">Word文件路径</param>
  1839. /// <param name="imageOutputPath">图片输出路径,如果为空,默认值为Word所在路径</param>
  1840. /// <param name="imageName">图片的名字,不需要带扩展名,如果为空,默认值为Word的名称</param>
  1841. /// <param name="startPageNum">从PDF文档的第几页开始转换,如果为0,默认值为1</param>
  1842. /// <param name="endPageNum">从PDF文档的第几页开始停止转换,如果为0,默认值为Word总页数</param>
  1843. /// <param name="imageFormat">设置所需图片格式,如果为null,默认格式为PNG</param>
  1844. /// <param name="resolution">设置图片的像素,数字越大越清晰,如果为0,默认值为128,建议最大值不要超过1024</param>
  1845. public List<string> ConvertWordToImage(string wordInputPath, string imageOutputPath,
  1846. string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, float resolution)
  1847. {
  1848. // 返回的图片绝对路径集合
  1849. List<string> images = new List<string>();
  1850. try
  1851. {
  1852. // open word file
  1853. Aspose.Words.Document doc = new Aspose.Words.Document(wordInputPath);
  1854. // validate parameter
  1855. if (doc == null) { throw new Exception("Word文件无效或者Word文件被加密!"); }
  1856. if (imageOutputPath.Trim().Length == 0) { imageOutputPath = System.IO.Path.GetDirectoryName(wordInputPath); }
  1857. if (!Directory.Exists(imageOutputPath)) { Directory.CreateDirectory(imageOutputPath); }
  1858. if (imageName.Trim().Length == 0) { imageName = System.IO.Path.GetFileNameWithoutExtension(wordInputPath); }
  1859. if (startPageNum <= 0) { startPageNum = 1; }
  1860. if (endPageNum > doc.PageCount || endPageNum <= 0) { endPageNum = doc.PageCount; }
  1861. if (startPageNum > endPageNum) { int tempPageNum = startPageNum; startPageNum = endPageNum; endPageNum = startPageNum; }
  1862. if (imageFormat == null) { imageFormat = ImageFormat.Png; }
  1863. if (resolution <= 0) { resolution = 128; }
  1864. ImageSaveOptions imageSaveOptions = new ImageSaveOptions(GetSaveFormat(imageFormat))
  1865. {
  1866. Resolution = resolution
  1867. };
  1868. // start to convert each page
  1869. for (int i = startPageNum; i <= endPageNum; i++)
  1870. {
  1871. imageSaveOptions.PageIndex = i - 1;
  1872. doc.Save(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString(), imageSaveOptions);
  1873. images.Add(System.IO.Path.Combine(imageOutputPath, imageName) + "_" + APP.num.ToString() + "." + imageFormat.ToString());
  1874. APP.num++;
  1875. }
  1876. imageSaveOptions = null;
  1877. doc = null;
  1878. }
  1879. catch (Exception ex)
  1880. {
  1881. System.Windows.MessageBox.Show("文档已打开,请关闭后重试!");
  1882. LogHelper.WriteErrLog("【课堂考试(ExamWindow)】错误日志:" + ex.Message, ex);
  1883. }
  1884. return images;
  1885. }
  1886. private static SaveFormat GetSaveFormat(ImageFormat imageFormat)
  1887. {
  1888. SaveFormat sf;// = SaveFormat.Unknown;
  1889. if (imageFormat.Equals(ImageFormat.Png))
  1890. {
  1891. sf = SaveFormat.Png;
  1892. }
  1893. else if (imageFormat.Equals(ImageFormat.Jpeg))
  1894. {
  1895. sf = SaveFormat.Jpeg;
  1896. }
  1897. else if (imageFormat.Equals(ImageFormat.Tiff))
  1898. {
  1899. sf = SaveFormat.Tiff;
  1900. }
  1901. else if (imageFormat.Equals(ImageFormat.Bmp))
  1902. {
  1903. sf = SaveFormat.Bmp;
  1904. }
  1905. else
  1906. {
  1907. sf = SaveFormat.Unknown;
  1908. }
  1909. return sf;
  1910. }
  1911. #region 图像缩放,移动
  1912. private bool mouseDown;
  1913. private System.Windows.Point mouseXY;
  1914. private void IMG1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  1915. {
  1916. var img = sender as ContentControl;
  1917. if (img == null)
  1918. {
  1919. return;
  1920. }
  1921. img.CaptureMouse();
  1922. mouseDown = true;
  1923. mouseXY = e.GetPosition(img);
  1924. Console.WriteLine("mouseXY.X = " + mouseXY.X + "; mouseXY.Y = " + mouseXY.Y);
  1925. }
  1926. private void PicEMap_MouseDown(object sender, MouseButtonEventArgs e)
  1927. {
  1928. System.Windows.Point point = e.GetPosition(imgCanvas);
  1929. //Console.WriteLine("PicEmap.X = " + point.X + "; PicEmap.Y = " + point.Y);
  1930. //if ((point.X - 304) * (point.X - 304) + (point.Y - 86) * (point.Y - 86) < 100)
  1931. //{
  1932. // Console.WriteLine("在范围内");
  1933. //}
  1934. }
  1935. private void IMG1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  1936. {
  1937. var img = sender as ContentControl;
  1938. if (img == null)
  1939. {
  1940. return;
  1941. }
  1942. img.ReleaseMouseCapture();
  1943. mouseDown = false;
  1944. }
  1945. private void IMG1_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
  1946. {
  1947. var img = sender as ContentControl;
  1948. if (img == null)
  1949. {
  1950. return;
  1951. }
  1952. if (mouseDown)
  1953. {
  1954. Domousemove(img, e);
  1955. }
  1956. }
  1957. /// <summary>
  1958. /// x y轴
  1959. /// </summary>
  1960. /// <param name="img"></param>
  1961. /// <param name="e"></param>
  1962. private void Domousemove(ContentControl img, System.Windows.Input.MouseEventArgs e)
  1963. {
  1964. if (e.LeftButton != MouseButtonState.Pressed)
  1965. {
  1966. return;
  1967. }
  1968. if (APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation != null && APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation)
  1969. {
  1970. return;
  1971. }
  1972. var group = IMG.FindResource("Imageview") as TransformGroup;
  1973. var transform = group.Children[1] as TranslateTransform;
  1974. var position = e.GetPosition(img);
  1975. transform.X -= mouseXY.X - position.X;
  1976. transform.Y -= mouseXY.Y - position.Y;
  1977. mouseXY = position;
  1978. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform();
  1979. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X = transform.X;
  1980. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y = transform.Y;
  1981. //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  1982. }
  1983. private void IMG1_MouseWheel(object sender, MouseWheelEventArgs e)
  1984. {
  1985. var img = sender as ContentControl;
  1986. if (img == null)
  1987. {
  1988. return;
  1989. }
  1990. var point = e.GetPosition(img);
  1991. Console.WriteLine("point.X = " + point.X + "; point.Y=" + point.Y);
  1992. var PicLocate = e.GetPosition(imgCanvas);
  1993. Console.WriteLine("PicEmap.X = " + PicLocate.X + "; PicEmap.Y=" + PicLocate.Y);
  1994. var group = IMG.FindResource("Imageview") as TransformGroup;
  1995. var delta = e.Delta * 0.001;
  1996. DowheelZoom(group, point, delta);
  1997. }
  1998. private void DowheelZoom(TransformGroup group, System.Windows.Point point, double delta)
  1999. {
  2000. var pointToContent = group.Inverse.Transform(point);
  2001. var transform = group.Children[0] as ScaleTransform;
  2002. if (transform.ScaleX + delta < 0.1) return;
  2003. transform.ScaleX += delta;
  2004. transform.ScaleY += delta;
  2005. var transform1 = group.Children[1] as TranslateTransform;
  2006. transform1.X = -1 * ((pointToContent.X * transform.ScaleX) - point.X);
  2007. transform1.Y = -1 * ((pointToContent.Y * transform.ScaleY) - point.Y);
  2008. LogHelper.WriteInfoLog("【img宽高】" + imgCanvas.ActualWidth.ToString() + ":"
  2009. + imgCanvas.ActualHeight.ToString() + "百分比:" + transform.ScaleX.ToString() + ":" + transform.ScaleY.ToString()
  2010. );
  2011. //Console.WriteLine("transform.ScaleX = " + transform.ScaleX + "; transform.ScaleY = " + transform.ScaleY);
  2012. APP.PageDrawList[APP.pageData.currpage - 1].ImageSize = new ScaleTransform();
  2013. APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleX = transform.ScaleX;
  2014. APP.PageDrawList[APP.pageData.currpage - 1].ImageSize.ScaleY = transform.ScaleY;
  2015. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation = new TranslateTransform();
  2016. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.X = transform1.X;
  2017. APP.PageDrawList[APP.pageData.currpage - 1].ImageLocation.Y = transform1.Y;
  2018. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes = new ScaleTransform();
  2019. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterX = imgCanvas.ActualWidth;
  2020. APP.PageDrawList[APP.pageData.currpage - 1].ImageSizes.CenterY = imgCanvas.ActualHeight;
  2021. APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = false;
  2022. }
  2023. #endregion
  2024. #region 点阵笔相关
  2025. #region 值初始化
  2026. // 不同尺寸点阵纸点阵宽高尺寸计算方法为:纸张物理尺寸(毫米)/0.3 *8,详见 开发必读.pdf 文档
  2027. /// <summary>
  2028. /// A4点阵纸点阵宽度
  2029. /// </summary>
  2030. private const int A4_WIDTH = 5600;
  2031. /// <summary>
  2032. /// A4点阵纸点阵高度
  2033. /// </summary>
  2034. private const int A4_HEIGHT = 7920;
  2035. /// <summary>
  2036. /// 画板
  2037. /// </summary>
  2038. private Graphics graphics;
  2039. /// <summary>
  2040. /// 笔画坐标数组
  2041. /// </summary>
  2042. private List<System.Drawing.Point> stroke;
  2043. /// <summary>
  2044. /// 笔序列号
  2045. /// </summary>
  2046. private string penSerial;
  2047. /// <summary>
  2048. /// 笔是否在点
  2049. /// </summary>
  2050. private bool isPenDown;
  2051. //当前点阵地址
  2052. private string currentPageSerial = string.Empty;
  2053. //不同点阵地址对应的笔迹绘制图片,用于实现在不同点阵地址书写切换时,显示书写内容自动切换
  2054. //本例图片放在内存中存储,对于大量或者需要在多个点阵地址对应图片进行切换演示,建议将图片存储到文件,以免内存溢出
  2055. private Dictionary<string, System.Drawing.Image> pagesDic = new Dictionary<string, System.Drawing.Image>();
  2056. #endregion
  2057. public void InitPen()
  2058. {
  2059. stroke = new List<System.Drawing.Point>();
  2060. //获取点阵笔实例,并绑定点阵笔事件
  2061. //将授权文件内容传入,获取点阵笔对象实例
  2062. APP.digitalPen = DigitalPenHID.GetInstance(certificates.MyLicense.Bytes);
  2063. //绑定笔连接事件
  2064. APP.digitalPen.PenConnected += OnPenConnect;
  2065. //绑定笔断开事件
  2066. APP.digitalPen.PenDisconnect += OnPenDisconnect;
  2067. //绑定笔书写输出坐标事件
  2068. APP.digitalPen.PenCoordinate += OnPenCoordinate;
  2069. //绑定抬笔事件
  2070. APP.digitalPen.PenUp += OnPenUp;
  2071. //绑定落笔事件
  2072. APP.digitalPen.PenDown += OnPenDown;
  2073. APP.digitalPen.PenBatteryCapacity += OnBatteryCapacity;
  2074. APP.digitalPen.PenMemoryFillLevel += OnMemoryFillLevel;
  2075. //完成初始化点阵笔,开始与点阵笔通信
  2076. ERROR_CODE ER = APP.digitalPen.Start();
  2077. ////绑定笔在新的点阵地址页面书写事件
  2078. //APP.digitalPen.PenNewPage += APP.digitalPen_OnPenNewPage;
  2079. ////绑定笔信息事件
  2080. //APP.digitalPen.PenInfo += APP.digitalPen_OnPenInfo;
  2081. //启动接收笔数据,完成初始化工作
  2082. ERROR_CODE rc = APP.digitalPen.Start();
  2083. //判断是否成功
  2084. if (ER != ERROR_CODE.ERROR_OK)
  2085. {
  2086. System.Windows.MessageBox.Show("初始化失败,授权过期,返回值:" + ER.ToString());
  2087. }
  2088. }
  2089. /// <summary>
  2090. /// 落笔
  2091. /// </summary>
  2092. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  2093. /// <param name="penSerial">点阵笔序列号</param>
  2094. /// <param name="penType">点阵笔型号编号</param>
  2095. private void OnPenDown(ulong time, string penSerial, int penType)
  2096. {
  2097. if (this.CheckAccess())
  2098. {
  2099. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDown);
  2100. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  2101. }
  2102. else
  2103. {
  2104. //labPenSerial.Text = penSerial;
  2105. //labPenStatus.Text = "PenDown";
  2106. isPenDown = true;
  2107. //Dispatcher.Invoke(new Action(() =>
  2108. //{
  2109. // for (int i = 0; i < APP.PageDrawList.Count; i++)
  2110. // {
  2111. // if (APP.PageDrawList[i].PageCode == penSerial)
  2112. // {
  2113. // if (i < APP.pageData.pagenum)
  2114. // {
  2115. // if (i < APP.pageData.currpage)
  2116. // {
  2117. // int num = APP.pageData.currpage - i;
  2118. // APP.pageData.currpage -= num;
  2119. // myblackboard.changepage(APP.pageData.currpage - 1);
  2120. // if (APP.PageDrawList.Count > 0)
  2121. // {
  2122. // if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && APP.pageData.currpage > 0 && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  2123. // {
  2124. // //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage - 1]));//cs
  2125. // imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  2126. // }
  2127. // else
  2128. // {
  2129. // imgCanvas.Source = null;
  2130. // }
  2131. // }
  2132. // }
  2133. // else
  2134. // {
  2135. // int num = i - APP.pageData.currpage;
  2136. // APP.pageData.currpage += num;
  2137. // myblackboard.changepage(APP.pageData.currpage - 1);
  2138. // if (APP.PageDrawList.Count > 0)
  2139. // {
  2140. // if (!string.IsNullOrWhiteSpace(txbCurrpage.Text) && APP.pageData.currpage <= APP.PageDrawList.Count && !string.IsNullOrWhiteSpace(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath))
  2141. // {
  2142. // //imgCanvas.Source = new BitmapImage(new Uri(APP.Paths[APP.pageData.currpage-1]));
  2143. // imgCanvas.Source = new BitmapImage(new Uri(APP.PageDrawList[APP.pageData.currpage - 1].PageImagePath));
  2144. // }
  2145. // else
  2146. // {
  2147. // imgCanvas.Source = null;
  2148. // }
  2149. // }
  2150. // }
  2151. // }
  2152. // return;
  2153. // }
  2154. // }
  2155. // //myblackboard.changepages(0, 0, true);
  2156. // //myblackboard.changepaget(0, 0, true, blackboard_canvas);
  2157. //}));
  2158. }
  2159. //myblackboard.changepages(0, 0, true);
  2160. }
  2161. /// <summary>
  2162. /// 抬笔
  2163. /// </summary>
  2164. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  2165. /// <param name="penSerial">点阵笔序列号</param>
  2166. /// <param name="penType">点阵笔型号编号</param>
  2167. private void OnPenUp(ulong time, string penSerial, int penType)
  2168. {
  2169. if (this.CheckAccess())
  2170. {
  2171. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenUp);
  2172. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  2173. }
  2174. else
  2175. {
  2176. isPenDown = false;
  2177. APP.PenSerial = penSerial;
  2178. //int leftPoints = stroke.Count % 3;
  2179. //if (0 != leftPoints)
  2180. //{
  2181. // int from = stroke.Count - leftPoints - 1;
  2182. // if (from < 0)
  2183. // from = 0;
  2184. // int to = stroke.Count - 1;
  2185. // DrawCoordinates(from, to);
  2186. //}
  2187. stroke.Clear();
  2188. }
  2189. if (APP.pageData.currpage > 0)
  2190. {
  2191. Dispatcher.Invoke(new Action(() =>
  2192. {
  2193. myblackboard.changepages(0, 0, true, Color, PenSize, APP.pageData.currpage - 1);
  2194. }));
  2195. }
  2196. }
  2197. /// <summary>
  2198. /// 笔断开
  2199. /// </summary>
  2200. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  2201. /// <param name="penSerial">点阵笔序列号</param>
  2202. /// <param name="penType">点阵笔型号编号</param>
  2203. private void OnPenDisconnect(ulong time, string penSerial, int penType)
  2204. {
  2205. if (this.CheckAccess())
  2206. {
  2207. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenDisconnect);
  2208. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  2209. }
  2210. else
  2211. {
  2212. APP.PenSerial = penSerial;
  2213. APP.PenStatus = false;
  2214. Dispatcher.Invoke(new Action(() =>
  2215. {
  2216. txbNotConnected.Text = "未连接";
  2217. txbNotConnecteds.Text = "未连接";
  2218. }));
  2219. }
  2220. }
  2221. /// <summary>
  2222. /// 笔连接
  2223. /// </summary>
  2224. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  2225. /// <param name="penSerial">点阵笔序列号</param>
  2226. /// <param name="penType">点阵笔型号编号</param>
  2227. private void OnPenConnect(ulong time, string penSerial, int penType)
  2228. {
  2229. if (this.CheckAccess())
  2230. {
  2231. Action<ulong, string, int> action = new Action<ulong, string, int>(OnPenConnect);
  2232. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType });
  2233. }
  2234. else
  2235. {
  2236. APP.PenSerial = penSerial;
  2237. APP.PenStatus = true;
  2238. this.penSerial = penSerial;
  2239. //连接后,在获取笔数据前,可以清除笔内的历史数据
  2240. //APP.digitalPen.ClearMemory(penSerial);
  2241. //开始接收笔数据
  2242. APP.digitalPen.GetPenData(penSerial);
  2243. Dispatcher.Invoke(new Action(() =>
  2244. {
  2245. txbNotConnected.Text = "已连接";
  2246. txbNotConnecteds.Text = "已连接";
  2247. }));
  2248. }
  2249. }
  2250. /// <summary>
  2251. /// 电池电量
  2252. /// </summary>
  2253. /// <param name="time"></param>
  2254. /// <param name="penSerial"></param>
  2255. /// <param name="penType"></param>
  2256. /// <param name="capacity"></param>
  2257. private void OnBatteryCapacity(ulong time, string penSerial, int penType, byte capacity)
  2258. {
  2259. if (this.CheckAccess())
  2260. {
  2261. Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnBatteryCapacity);
  2262. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType, capacity });
  2263. }
  2264. else
  2265. {
  2266. //System.Windows.MessageBox.Show("电池电量:" + capacity.ToString());
  2267. }
  2268. }
  2269. /// <summary>
  2270. /// 已用存储
  2271. /// </summary>
  2272. /// <param name="time"></param>
  2273. /// <param name="penSerial"></param>
  2274. /// <param name="penType"></param>
  2275. /// <param name="fillLevel"></param>
  2276. private void OnMemoryFillLevel(ulong time, string penSerial, int penType, byte fillLevel)
  2277. {
  2278. if (this.CheckAccess())
  2279. {
  2280. Action<ulong, string, int, byte> action = new Action<ulong, string, int, byte>(OnMemoryFillLevel);
  2281. this.Dispatcher.Invoke(action, new object[] { time, penSerial, penType, fillLevel });
  2282. }
  2283. else
  2284. {
  2285. //System.Windows.MessageBox.Show("存储:" + fillLevel.ToString());
  2286. }
  2287. }
  2288. /// <summary>
  2289. /// 笔书写,收到坐标
  2290. /// </summary>
  2291. /// <param name="time">时间戳,1970年1月1日到现在的总毫秒数</param>
  2292. /// <param name="penSerial">点阵笔序列号</param>
  2293. /// <param name="penType">点阵笔型号编号</param>
  2294. /// <param name="pageSerial">点阵地址</param>
  2295. /// <param name="cx">x坐标</param>
  2296. /// <param name="cy">y坐标</param>
  2297. /// <param name="force">压力值</param>
  2298. private void OnPenCoordinate(ulong time, string penSerial, int penType, string pageSerial, int cx, int cy, byte force)
  2299. {
  2300. if (this.CheckAccess())
  2301. {
  2302. Action<ulong, string, int, string, int, int, byte> ac = new Action<ulong, string, int, string, int, int, byte>(OnPenCoordinate);
  2303. this.Dispatcher.Invoke(ac, new object[] { time, pageSerial, penType, pageSerial, cx, cy, force });
  2304. }
  2305. else
  2306. {
  2307. //判断是否是落笔后输出的坐标,在设置悬浮模式下,落笔前的悬浮坐标不绘制
  2308. if (!isPenDown)
  2309. {
  2310. return;
  2311. }
  2312. stroke.Add(new System.Drawing.Point(cx, cy));
  2313. double PropW = blackboard_canvas.ActualWidth / A4_WIDTH;
  2314. double PropH = blackboard_canvas.ActualHeight / A4_HEIGHT;
  2315. //点
  2316. double testX = (double)cx * PropW;
  2317. double testY = (double)cy * PropH;
  2318. //pageSerial //点阵IP地址 与打印的页面关联
  2319. if (APP.pageData.currpage > 0)
  2320. {
  2321. Dispatcher.Invoke(new Action(() =>
  2322. {
  2323. //myblackboard.changepages(testX, testY,false);
  2324. myblackboard.changepages(testX, testY, false, Color, PenSize, APP.pageData.currpage - 1);
  2325. #region 设置滚动条位置
  2326. //点在显示页面上方
  2327. if (testY < scroMain.VerticalOffset)
  2328. {
  2329. //滚动条当前位置
  2330. double RollCurrentLocation = scroMain.VerticalOffset;
  2331. //向上滚动至以点为中心需要滚动的距离
  2332. double UpRoll = (RollCurrentLocation - testY) + (scroMain.ActualHeight / 2);
  2333. //如果小于0则等于0
  2334. double RollLocation = RollCurrentLocation - UpRoll;
  2335. if (RollLocation < 0)
  2336. {
  2337. RollLocation = 0;
  2338. }
  2339. ////滚动条实际偏移量
  2340. //double RollOffset = RollCurrentLocation - RollLocation;
  2341. scroMain.ScrollToVerticalOffset(RollLocation);
  2342. }
  2343. //点在显示页面下方
  2344. if (testY > scroMain.VerticalOffset + scroMain.ActualHeight)
  2345. {
  2346. //滚动条当前位置
  2347. double RollCurrentLocation = scroMain.VerticalOffset;
  2348. //向下滚动至以点为中心需要滚动的距离
  2349. double DownRoll = (testY - RollCurrentLocation) - (scroMain.ActualHeight / 2);
  2350. //如果小于0则等于0
  2351. double RollLocation = RollCurrentLocation + DownRoll;
  2352. //滚动条最大滚动值
  2353. double ScrollbarMaxNum = gridM.ActualHeight - scroMain.ActualHeight;
  2354. if (RollLocation > ScrollbarMaxNum)
  2355. {
  2356. RollLocation = ScrollbarMaxNum;
  2357. }
  2358. ////滚动条实际偏移量
  2359. //double RollOffset = RollLocation-RollCurrentLocation;
  2360. scroMain.ScrollToVerticalOffset(RollLocation);
  2361. }
  2362. #endregion
  2363. //gridM.Height //A4高度
  2364. //scroMain.VerticalOffset;//获取滚动条位置
  2365. //scroMain.ActualHeight//A4纸显示高度
  2366. //scroMain.ScrollToHorizontalOffset()//设置滚动条位置
  2367. //Mouse.GetPosition(this)
  2368. if (testX > 0 && testY > 0)
  2369. {
  2370. //System.Windows.Point getP = blackboard_canvas.PointToScreen(new System.Windows.Point(testX, testY));
  2371. System.Windows.Point getP = scroMain.PointToScreen(new System.Windows.Point(testX, testY - scroMain.VerticalOffset));
  2372. SetCursorPos((int)getP.X, (int)getP.Y);
  2373. }
  2374. }));
  2375. }
  2376. ////每3个点画一条曲线
  2377. //if (stroke.Count % 3 == 0)
  2378. //{
  2379. // int from = stroke.Count - 3 - 1;
  2380. // if (from < 0)
  2381. // from = 0;
  2382. // int to = stroke.Count - 1;
  2383. // DrawCoordinates(from, to);
  2384. //}
  2385. }
  2386. }
  2387. /// <summary>
  2388. /// 停止笔
  2389. /// </summary>
  2390. public void StopDigitalPen()
  2391. {
  2392. //停止,释放资源
  2393. APP.digitalPen.Stop();
  2394. }
  2395. /// <summary>
  2396. /// 清空笔内存储
  2397. /// </summary>
  2398. public void ClearPenStorage()
  2399. {
  2400. if (!string.IsNullOrEmpty(penSerial))
  2401. APP.digitalPen.ClearMemory(penSerial);
  2402. }
  2403. /// <summary>
  2404. /// 获取剩余电量
  2405. /// </summary>
  2406. public void GetPenElectricityQuantity()
  2407. {
  2408. if (!string.IsNullOrEmpty(penSerial))
  2409. APP.digitalPen.GetBatteryCapacity(penSerial);
  2410. }
  2411. /// <summary>
  2412. /// 获取存储空间
  2413. /// </summary>
  2414. public void GetUsedStorage()
  2415. {
  2416. if (!string.IsNullOrEmpty(penSerial))
  2417. APP.digitalPen.GetMemoryFillLevel(penSerial);
  2418. }
  2419. /// <summary>
  2420. /// 开启悬浮
  2421. /// </summary>
  2422. public void 开启悬浮()
  2423. {
  2424. if (!string.IsNullOrEmpty(penSerial))
  2425. APP.digitalPen.SetPenHoverMode(true, penSerial);
  2426. }
  2427. /// <summary>
  2428. /// 关闭悬浮
  2429. /// </summary>
  2430. public void 关闭悬浮()
  2431. {
  2432. if (!string.IsNullOrEmpty(penSerial))
  2433. APP.digitalPen.SetPenHoverMode(false, penSerial);
  2434. }
  2435. #endregion
  2436. /// <summary>
  2437. /// 最小化
  2438. /// </summary>
  2439. /// <param name="sender"></param>
  2440. /// <param name="e"></param>
  2441. private void BtnShrink_Click(object sender, RoutedEventArgs e)
  2442. {
  2443. if (this.WindowState == WindowState.Minimized)
  2444. {
  2445. this.WindowState = WindowState.Normal;
  2446. }
  2447. else
  2448. {
  2449. this.WindowState = WindowState.Minimized;
  2450. }
  2451. }
  2452. /// <summary>
  2453. /// 位置确定
  2454. /// </summary>
  2455. /// <param name="sender"></param>
  2456. /// <param name="e"></param>
  2457. private void BtnOk_Click(object sender, RoutedEventArgs e)
  2458. {
  2459. //APP.PageDrawList[APP.pageData.currpage - 1].IsImageLocation = true;
  2460. //btnOk.Visibility = Visibility.Collapsed;
  2461. //blackboard_canvas.Visibility = Visibility.Visible;
  2462. }
  2463. /// <summary>
  2464. /// 引用user32.dll动态链接库(windows api),
  2465. /// 使用库中定义 API:SetCursorPos
  2466. /// 设置光标位置
  2467. /// </summary>
  2468. [System.Runtime.InteropServices.DllImport("user32.dll")]
  2469. private static extern int SetCursorPos(int x, int y);
  2470. /// 截图的图片鼠标右键事件
  2471. /// </summary>
  2472. /// <param name="sender"></param>
  2473. /// <param name="e"></param>
  2474. private void imgCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
  2475. {
  2476. imgCanvas.Source = null;
  2477. }
  2478. private void Button_Click(object sender, RoutedEventArgs e)
  2479. {
  2480. //System.Windows.SplashScreen(LoadDialog);
  2481. //Common.system.SplashScreen.Show(typeof(LoadDialog));
  2482. //Thread.Sleep(5000);
  2483. //Common.system.SplashScreen.Close();
  2484. APP.myloading.Show();
  2485. Thread.Sleep(1000);
  2486. APP.myloading.Hide();
  2487. }
  2488. }
  2489. }