DetailPageView.xaml.cs 91 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243
  1. using ivf_tl_Entity.GlobalEntitys;
  2. using ivf_tl_Entity.GlobalEnums;
  3. using ivf_tl_Operate.Converts;
  4. using ivf_tl_Operate.CustomUserControls;
  5. using ivf_tl_Operate.ViewModel;
  6. using ivf_tl_Operate.Windows;
  7. using Newtonsoft.Json;
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.Diagnostics;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading;
  15. using System.Threading.Tasks;
  16. using System.Timers;
  17. using System.Windows;
  18. using System.Windows.Controls;
  19. using System.Windows.Data;
  20. using System.Windows.Documents;
  21. using System.Windows.Input;
  22. using System.Windows.Media;
  23. using System.Windows.Media.Animation;
  24. using System.Windows.Media.Imaging;
  25. using System.Windows.Navigation;
  26. using System.Windows.Shapes;
  27. using static System.Net.Mime.MediaTypeNames;
  28. namespace ivf_tl_Operate.View
  29. {
  30. /// <summary>
  31. /// DetailPageView.xaml 的交互逻辑
  32. /// </summary>
  33. public partial class DetailPageView : UserControl
  34. {
  35. DetailPageViewModel vm;
  36. string CleanVideoString { get; set; } = "-";
  37. private double newCurrentTime = -1;
  38. double beilv { get; set; } = 1;
  39. public DetailPageView()
  40. {
  41. InitializeComponent();
  42. Loaded += DetailPageView_Loaded;
  43. Unloaded += DetailPageView_Unloaded;
  44. }
  45. private void DetailPageView_Unloaded(object sender, RoutedEventArgs e)
  46. {
  47. this.Grid_Root.Children.Clear();
  48. if (vm != null) vm = null;
  49. this.DataContext = null;
  50. }
  51. int NoMarkTime = 48;
  52. private void DetailPageView_Loaded(object sender, RoutedEventArgs e)
  53. {
  54. var TLSettingModel = AppData.Instance.HttpHelper.SettingSystemApi(AppData.Instance.TlSn);
  55. if(TLSettingModel!=null) NoMarkTime = TLSettingModel.operableEmbryoTime * 24;
  56. vm = (DetailPageViewModel)this.DataContext;
  57. if (vm == null) return;
  58. if (vm.ExDish != null && vm.ExDish.id > 0)
  59. {
  60. if (vm.ExDish.state == 0 && !string.IsNullOrEmpty(vm.ExDish.endTime) && DateTime.TryParse(vm.ExDish.endTime, out DateTime endtime))
  61. {
  62. var cultivateDuration = DateTime.Now.Subtract(endtime);
  63. if (cultivateDuration.TotalHours > NoMarkTime)
  64. {
  65. disableButton(false);
  66. }
  67. else
  68. {
  69. disableButton(true);
  70. }
  71. this.Button_js.IsEnabled = false;
  72. }
  73. else
  74. {
  75. disableButton(true);
  76. this.Button_js.IsEnabled = true;
  77. }
  78. }
  79. else
  80. {
  81. disableButton(true);
  82. this.Button_js.IsEnabled = true;
  83. }
  84. Task.Run(() =>
  85. {
  86. vm.Init();
  87. if (vm == null) return;
  88. Dispatcher.InvokeAsync(() =>
  89. {
  90. _dishInfo.SetEmbryoPic(vm.DishPicAndVideoList);
  91. PlayerEvent(this._dishInfo.mediaElementPlayer);
  92. ChangeEmbryo(1);
  93. });
  94. InitAlarm();
  95. while (true)
  96. {
  97. Thread.Sleep(10000);
  98. //Thread.Sleep(3000);
  99. if (vm == null || vm.ExDish == null) return;
  100. //foreach (var item in vm.ExDish.embryoList)
  101. //{
  102. // if (item.alarm == 0)
  103. // {
  104. // item.alarm = 1;
  105. // }
  106. // else
  107. // {
  108. // item.alarm = 0;
  109. // }
  110. //}
  111. InitAlarm();
  112. }
  113. });
  114. }
  115. private void InitAlarm()
  116. {
  117. if (vm == null || vm.ExDish == null) return;
  118. HouseCropAlarmResponse houseCropAlarmResponse = new HouseCropAlarmResponse();
  119. HouseCropAlarmResult CurrentHouseCropAlarmResult;
  120. houseCropAlarmResponse.tlSn = AppData.Instance.TlSn;
  121. if (!houseCropAlarmResponse.houseList.Any())
  122. {
  123. houseCropAlarmResponse.houseList.Add(new HouseCropAlarmHouseResponse
  124. {
  125. houseSn = vm.ExDish.houseSn,
  126. startTime = vm.ExDish.startTime,
  127. });
  128. }
  129. CurrentHouseCropAlarmResult = AppData.Instance.HttpHelper.GetHouseCropAlarmApi(houseCropAlarmResponse).FirstOrDefault(x => x.houseSn == vm.ExDish.houseSn);
  130. foreach (var item in vm.ExDish.embryoList)
  131. {
  132. if (CurrentHouseCropAlarmResult == null)
  133. {
  134. item.alarm = 0;
  135. continue;
  136. }
  137. if (CurrentHouseCropAlarmResult.wellSn.Contains(item.wellSn))
  138. {
  139. item.alarm = 1;
  140. }
  141. else
  142. {
  143. item.alarm = 0;
  144. }
  145. }
  146. }
  147. public void disableButton(bool disable)
  148. {
  149. this.Button_yz.IsEnabled = disable;
  150. this.Button_ld.IsEnabled = disable;
  151. this.Button_sc.IsEnabled = disable;
  152. this.Button_zf.IsEnabled = disable;
  153. }
  154. private void ExLog(Exception ex, string name)
  155. {
  156. AppData.Instance.LogHelper.ExceptionLog(ex, $"DetailPageView.{name}", LogEnum.RunException);
  157. }
  158. private void ErrorLog(string mess, LogEnum logEnum)
  159. {
  160. AppData.Instance.LogHelper.TLLog($"DetailPageView.{mess}", logEnum);
  161. }
  162. public void ShowMessage(string mess)
  163. {
  164. new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, mess);
  165. }
  166. private void WellChangeEvent(int obj)
  167. {
  168. PlayerPause();
  169. ChangeEmbryo(obj);
  170. }
  171. public void ChangeEmbryo(int well)
  172. {
  173. try
  174. {
  175. PlayerDispose();
  176. if (vm == null) return;
  177. vm.CurrentEmbryo = null;
  178. vm.CurrentWellDishPicAndVideo = null;
  179. vm.CurrentWellLayerPicAndVideo = null;
  180. vm.CurrentPic = null;
  181. SetVideoButtonState(false);
  182. vm.CurrentFocal = 0;
  183. BigFocusIsEnabled(true);
  184. SmallFocusIsEnabled(true);
  185. if (vm.ExDish != null && vm.ExDish.id > 0) vm.CurrentEmbryo = vm.ExDish.embryoList.FirstOrDefault(x => x.wellSn == well);
  186. if (vm.CurrentEmbryo == null)
  187. {
  188. vm.VideoAllTime = 1;
  189. vm.VideoCurrentTime = 0;
  190. }
  191. if (vm.CurrentEmbryo != null) vm.CurrentWellDishPicAndVideo = vm.DishPicAndVideoList.FirstOrDefault(x => x.wellSn == vm.CurrentEmbryo.wellSn);
  192. if (vm.CurrentWellDishPicAndVideo != null) vm.CurrentWellLayerPicAndVideo = vm.CurrentWellDishPicAndVideo.videos.FirstOrDefault(x => x.pictureLayer == 0);
  193. this._dishInfo.SetPreview(vm.CurrentWellDishPicAndVideo);
  194. if (vm.MaxTotalLayer == -1) if (vm.CurrentWellLayerPicAndVideo != null) vm.MaxTotalLayer = vm.CurrentWellLayerPicAndVideo.videoPictures.Max(x => x.totalLayer);
  195. SetVideo(vm.CurrentFocal, true);
  196. if (vm.CurrentWellLayerPicAndVideo != null && vm.CurrentWellLayerPicAndVideo.videoPictures.Any())
  197. {
  198. BigFocusIsEnabled(true);
  199. SmallFocusIsEnabled(true);
  200. if (string.IsNullOrEmpty(vm.CurrentWellLayerPicAndVideo.videoUrl) || vm.CurrentWellLayerPicAndVideo.videoUrl == CleanVideoString)
  201. {
  202. vm.VideoAllTime = 1;
  203. vm.VideoCurrentTime = 0;
  204. vm.VideoAllTime = vm.CurrentWellLayerPicAndVideo.videoPictures.Count;
  205. vm.VideoCurrentTime = vm.VideoAllTime;
  206. }
  207. }
  208. else
  209. {
  210. BigFocusIsEnabled(false);
  211. SmallFocusIsEnabled(false);
  212. }
  213. }
  214. catch (Exception ex)
  215. {
  216. ExLog(ex, "ChangeEmbryo");
  217. }
  218. }
  219. private void LastEmbryo_Click(object sender, RoutedEventArgs e)
  220. {
  221. if (!this._dishInfo.IsLoaded) return;
  222. this._dishInfo.LastEmbryo();
  223. }
  224. private void NextEmbryo_Click(object sender, RoutedEventArgs e)
  225. {
  226. if (!this._dishInfo.IsLoaded) return;
  227. this._dishInfo.NextEmbryo();
  228. }
  229. /// <summary>
  230. /// 返回按钮
  231. /// </summary>
  232. /// <param name="sender"></param>
  233. /// <param name="e"></param>
  234. private void Return_Click(object sender, RoutedEventArgs e)
  235. {
  236. PlayerPause();
  237. PlayerDispose();
  238. if (vm != null && vm.ParentViewModel != null)
  239. {
  240. DishRecordView dishRecordView = new DishRecordView()
  241. {
  242. DataContext = vm.ParentViewModel,
  243. };
  244. AppData.Instance.MainWindow.LoadPage(dishRecordView);
  245. return;
  246. }
  247. AppData.Instance.BackMainPage();
  248. }
  249. #region 标记菜单
  250. //string s1 = "Whether or not to";
  251. //string s2 = "embryo No.";
  252. //string s3 = "Whether or not to cancel the";
  253. //string s4 = "mark of embryo No.";
  254. //string s5 = "Embryo No.";
  255. //string s6 = "has been";
  256. string s1 = KeyToStringConvert.GetLanguageStringByKey("C0307");
  257. string s2 = KeyToStringConvert.GetLanguageStringByKey("C0308");
  258. string s3 = KeyToStringConvert.GetLanguageStringByKey("C0309");
  259. string s4 = KeyToStringConvert.GetLanguageStringByKey("C0310");
  260. string s5 = KeyToStringConvert.GetLanguageStringByKey("C0311");
  261. string s6 = KeyToStringConvert.GetLanguageStringByKey("C0312");
  262. string spaceString = KeyToStringConvert.GetLanguageStringByKey("C0328");
  263. string haoString = KeyToStringConvert.GetLanguageStringByKey("C0327");
  264. /// <summary>
  265. /// 移植按钮
  266. /// </summary>
  267. /// <param name="sender"></param>
  268. /// <param name="e"></param>
  269. private void EmbryoMove_Click(object sender, RoutedEventArgs e)
  270. {
  271. PlayerPause();
  272. if (vm.CurrentEmbryo == null) return;
  273. // M8-G3-1:胚胎操作命令入口埋点。
  274. using var _op = Aivfo.OperationLog.OperationLogger.Begin("胚胎操作", "移动胚胎");
  275. _op.Input(new { embryoId = vm.CurrentEmbryo.id, wellSn = vm.CurrentEmbryo.wellSn, houseSn = vm.CurrentEmbryo.houseSn, state = vm.CurrentEmbryo.state });
  276. string tag = KeyToStringConvert.GetLanguageStringByKey("C0136");
  277. string messInfo = GetMessageInfo(tag);
  278. int stateTag = 1;
  279. if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
  280. {
  281. tag = "完成";
  282. switch (vm.CurrentEmbryo.state)
  283. {
  284. case (int)EmbryoState.Freezing:
  285. messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("C0135"));
  286. stateTag = 2;
  287. break;
  288. case (int)EmbryoState.Transplant:
  289. messInfo = GetCancelMarkMessage();
  290. tag = "取消";
  291. break;
  292. case (int)EmbryoState.Cancellation:
  293. messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("C0138"));
  294. stateTag = 4;
  295. break;
  296. case (int)EmbryoState.Delete:
  297. messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("C0137"));
  298. stateTag = 3;
  299. break;
  300. }
  301. }
  302. EmbryoOp(tag, messInfo, stateTag);
  303. _op.Success();
  304. return;
  305. }
  306. //private void EmbryoMove_Click(object sender, RoutedEventArgs e)
  307. //{
  308. // PlayerPause();
  309. // if (vm.CurrentEmbryo == null) return;
  310. // string tag = "移植";
  311. // string messInfo = $"是否确定对{vm.CurrentEmbryo.wellSn}号胚胎进行移植?";
  312. // if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
  313. // {
  314. // tag = "完成";
  315. // switch (vm.CurrentEmbryo.state)
  316. // {
  317. // case (int)EmbryoState.Freezing:
  318. // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已冷冻";
  319. // break;
  320. // case (int)EmbryoState.Transplant:
  321. // messInfo = $"是否取消{vm.CurrentEmbryo.wellSn}号胚胎的移植标记";
  322. // tag = "取消";
  323. // break;
  324. // case (int)EmbryoState.Cancellation:
  325. // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已作废";
  326. // break;
  327. // case (int)EmbryoState.Delete:
  328. // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已删除";
  329. // break;
  330. // }
  331. // }
  332. // EmbryoOp(tag, messInfo);
  333. // return;
  334. //}
  335. /// <summary>
  336. /// 冷冻按钮
  337. /// </summary>
  338. /// <param name="sender"></param>
  339. /// <param name="e"></param>
  340. private void EmbryoFree_Click(object sender, RoutedEventArgs e)
  341. {
  342. PlayerPause();
  343. if (vm.CurrentEmbryo == null) return;
  344. // M8-G3-1:胚胎操作命令入口埋点。
  345. using var _op = Aivfo.OperationLog.OperationLogger.Begin("胚胎操作", "释放胚胎");
  346. _op.Input(new { embryoId = vm.CurrentEmbryo.id, wellSn = vm.CurrentEmbryo.wellSn, houseSn = vm.CurrentEmbryo.houseSn, state = vm.CurrentEmbryo.state });
  347. string tag = KeyToStringConvert.GetLanguageStringByKey("C0135");
  348. string messInfo = GetMessageInfo(tag);
  349. int stateTag = 2;
  350. if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
  351. {
  352. tag = "完成";
  353. switch (vm.CurrentEmbryo.state)
  354. {
  355. case (int)EmbryoState.Transplant:
  356. messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("C0136"));
  357. stateTag = 1;
  358. break;
  359. case (int)EmbryoState.Freezing:
  360. messInfo = GetCancelMarkMessage();
  361. tag = "取消";
  362. break;
  363. case (int)EmbryoState.Cancellation:
  364. messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("C0138"));
  365. stateTag = 4;
  366. break;
  367. case (int)EmbryoState.Delete:
  368. messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("C0137"));
  369. stateTag = 3;
  370. break;
  371. }
  372. }
  373. EmbryoOp(tag, messInfo, stateTag);
  374. _op.Success();
  375. return;
  376. }
  377. //private void EmbryoFree_Click(object sender, RoutedEventArgs e)
  378. //{
  379. // PlayerPause();
  380. // if (vm.CurrentEmbryo == null) return;
  381. // string tag = "冷冻";
  382. // string messInfo = $"是否确定对{vm.CurrentEmbryo.wellSn}号胚胎进行冷冻?";
  383. // if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
  384. // {
  385. // tag = "完成";
  386. // switch (vm.CurrentEmbryo.state)
  387. // {
  388. // case (int)EmbryoState.Transplant:
  389. // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已移植";
  390. // break;
  391. // case (int)EmbryoState.Freezing:
  392. // messInfo = $"是否取消{vm.CurrentEmbryo.wellSn}号胚胎的冷冻标记";
  393. // tag = "取消";
  394. // break;
  395. // case (int)EmbryoState.Cancellation:
  396. // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已作废";
  397. // break;
  398. // case (int)EmbryoState.Delete:
  399. // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已删除";
  400. // break;
  401. // }
  402. // }
  403. // EmbryoOp(tag, messInfo);
  404. // return;
  405. //}
  406. /// <summary>
  407. /// 删除按钮
  408. /// </summary>
  409. /// <param name="sender"></param>
  410. /// <param name="e"></param>
  411. private void EmbryoDel_Click(object sender, RoutedEventArgs e)
  412. {
  413. PlayerPause();
  414. if (vm.CurrentEmbryo == null) return;
  415. // M8-G3-1:胚胎操作命令入口埋点。
  416. using var _op = Aivfo.OperationLog.OperationLogger.Begin("胚胎操作", "删除胚胎");
  417. _op.Input(new { embryoId = vm.CurrentEmbryo.id, wellSn = vm.CurrentEmbryo.wellSn, houseSn = vm.CurrentEmbryo.houseSn, state = vm.CurrentEmbryo.state });
  418. string tag = KeyToStringConvert.GetLanguageStringByKey("C0137");
  419. string messInfo = GetMessageInfo(tag);
  420. int stateTag = 3;
  421. if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
  422. {
  423. tag = "完成";
  424. switch (vm.CurrentEmbryo.state)
  425. {
  426. case (int)EmbryoState.Transplant:
  427. messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("C0136"));
  428. stateTag = 1;
  429. break;
  430. case (int)EmbryoState.Freezing:
  431. messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("C0135"));
  432. stateTag = 2;
  433. break;
  434. case (int)EmbryoState.Cancellation:
  435. messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("C0138"));
  436. stateTag = 4;
  437. break;
  438. case (int)EmbryoState.Delete:
  439. messInfo = GetCancelMarkMessage();
  440. tag = "取消";
  441. break;
  442. }
  443. }
  444. EmbryoOp(tag, messInfo, stateTag);
  445. _op.Success();
  446. return;
  447. }
  448. //private void EmbryoDel_Click(object sender, RoutedEventArgs e)
  449. //{
  450. // PlayerPause();
  451. // if (vm.CurrentEmbryo == null) return;
  452. // string tag = "删除";
  453. // string messInfo = $"是否确定对{vm.CurrentEmbryo.wellSn}号胚胎进行删除?";
  454. // if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
  455. // {
  456. // tag = "完成";
  457. // switch (vm.CurrentEmbryo.state)
  458. // {
  459. // case (int)EmbryoState.Transplant:
  460. // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已移植";
  461. // break;
  462. // case (int)EmbryoState.Freezing:
  463. // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已冷冻";
  464. // break;
  465. // case (int)EmbryoState.Cancellation:
  466. // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已作废";
  467. // break;
  468. // case (int)EmbryoState.Delete:
  469. // messInfo = $"是否取消{vm.CurrentEmbryo.wellSn}号胚胎的删除标记";
  470. // tag = "取消";
  471. // break;
  472. // }
  473. // }
  474. // EmbryoOp(tag, messInfo);
  475. // return;
  476. //}
  477. /// <summary>
  478. /// 作废按钮
  479. /// </summary>
  480. /// <param name="sender"></param>
  481. /// <param name="e"></param>
  482. private void EmbryoInv_Click(object sender, RoutedEventArgs e)
  483. {
  484. PlayerPause();
  485. if (vm.CurrentEmbryo == null) return;
  486. // M8-G3-1:胚胎操作命令入口埋点。
  487. using var _op = Aivfo.OperationLog.OperationLogger.Begin("胚胎操作", "作废胚胎");
  488. _op.Input(new { embryoId = vm.CurrentEmbryo.id, wellSn = vm.CurrentEmbryo.wellSn, houseSn = vm.CurrentEmbryo.houseSn, state = vm.CurrentEmbryo.state });
  489. string tag = KeyToStringConvert.GetLanguageStringByKey("C0138");
  490. string messInfo = GetMessageInfo(tag);
  491. int stateTag = 4;
  492. if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
  493. {
  494. tag = "完成";
  495. switch (vm.CurrentEmbryo.state)
  496. {
  497. case (int)EmbryoState.Transplant:
  498. messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("C0136"));
  499. stateTag = 1;
  500. break;
  501. case (int)EmbryoState.Freezing:
  502. messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("C0135"));
  503. stateTag = 2;
  504. break;
  505. case (int)EmbryoState.Cancellation:
  506. messInfo = GetCancelMarkMessage();
  507. tag = "取消";
  508. break;
  509. case (int)EmbryoState.Delete:
  510. messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("C0137"));
  511. stateTag = 3;
  512. break;
  513. }
  514. }
  515. EmbryoOp(tag, messInfo, stateTag);
  516. _op.Success();
  517. return;
  518. }
  519. //private void EmbryoInv_Click(object sender, RoutedEventArgs e)
  520. //{
  521. // PlayerPause();
  522. // if (vm.CurrentEmbryo == null) return;
  523. // string tag = "作废";
  524. // string messInfo = $"是否确定对{vm.CurrentEmbryo.wellSn}号胚胎进行作废?";
  525. // if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
  526. // {
  527. // tag = "完成";
  528. // switch (vm.CurrentEmbryo.state)
  529. // {
  530. // case (int)EmbryoState.Transplant:
  531. // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已移植";
  532. // break;
  533. // case (int)EmbryoState.Freezing:
  534. // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已冷冻";
  535. // break;
  536. // case (int)EmbryoState.Cancellation:
  537. // messInfo = $"是否取消{vm.CurrentEmbryo.wellSn}号胚胎的作废标记";
  538. // tag = "取消";
  539. // break;
  540. // case (int)EmbryoState.Delete:
  541. // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已删除";
  542. // break;
  543. // }
  544. // }
  545. // EmbryoOp(tag, messInfo);
  546. // return;
  547. //}
  548. /// <summary>
  549. /// 结束按钮
  550. /// </summary>
  551. /// <param name="sender"></param>
  552. /// <param name="e"></param>
  553. private void EmbryoOver_Click(object sender, RoutedEventArgs e)
  554. {
  555. try
  556. {
  557. PlayerPause();
  558. if (vm.ExDish == null || vm.ExDish.id == 0) return;
  559. // M8-G3-1:胚胎操作命令入口埋点。
  560. using var _op = Aivfo.OperationLog.OperationLogger.Begin("胚胎操作", "结束胚胎培养");
  561. _op.Input(new { dishId = vm.ExDish.id, houseSn = vm.ExDish.houseSn, state = vm.ExDish.state });
  562. try
  563. {
  564. string tag = KeyToStringConvert.GetLanguageStringByKey("C0313");
  565. string messInfo = KeyToStringConvert.GetLanguageStringByKey("C0314");
  566. if (vm.ExDish.state == 0)
  567. {
  568. messInfo = KeyToStringConvert.GetLanguageStringByKey("C0315");
  569. tag = "完成";
  570. }
  571. EmbryoOp(tag, messInfo, 5);
  572. _op.Success();
  573. return;
  574. }
  575. catch (Exception)
  576. {
  577. _op.Fail("EmbryoOver_Click exception");
  578. throw;
  579. }
  580. }
  581. catch (Exception ex)
  582. {
  583. ExLog(ex, "EmbryoOver_Click");
  584. }
  585. //try
  586. //{
  587. // PlayerPause();
  588. // if (vm.ExDish == null || vm.ExDish.id == 0) return;
  589. // string tag = "结束";
  590. // string messInfo = $"是否结束培养所有胚胎?";
  591. // if (vm.ExDish.state == 0)
  592. // {
  593. // messInfo = "当前舱室已结束培养";
  594. // tag = "完成";
  595. // }
  596. // EmbryoOp(tag, messInfo,5);
  597. // return;
  598. //}
  599. //catch (Exception ex)
  600. //{
  601. // ExLog(ex, "EmbryoOver_Click");
  602. //}
  603. }
  604. /// <summary>
  605. /// 胚胎操作
  606. /// </summary>
  607. private void EmbryoOp(string tag, string infoString, int opType)
  608. {
  609. if (tag == "完成")
  610. {
  611. switch (opType)
  612. {
  613. case 1:
  614. tag = KeyToStringConvert.GetLanguageStringByKey("C0136");
  615. break;
  616. case 2:
  617. tag = KeyToStringConvert.GetLanguageStringByKey("C0135");
  618. break;
  619. case 3:
  620. tag = KeyToStringConvert.GetLanguageStringByKey("C0137");
  621. break;
  622. case 4:
  623. tag = KeyToStringConvert.GetLanguageStringByKey("C0138");
  624. break;
  625. }
  626. new MessageWindow(AppData.Instance.MainWindow, infoString, tag).ShowDialog();
  627. //new MessageWindow(AppData.Instance.MainWindow, infoString, KeyToStringConvert.GetLanguageStringByKey("C0171")).ShowDialog();
  628. return;
  629. }
  630. if (tag == "取消")
  631. {
  632. switch (opType)
  633. {
  634. case 1:
  635. tag = KeyToStringConvert.GetLanguageStringByKey("C0136");
  636. break;
  637. case 2:
  638. tag = KeyToStringConvert.GetLanguageStringByKey("C0135");
  639. break;
  640. case 3:
  641. tag = KeyToStringConvert.GetLanguageStringByKey("C0137");
  642. break;
  643. case 4:
  644. tag = KeyToStringConvert.GetLanguageStringByKey("C0138");
  645. break;
  646. }
  647. //tag = KeyToStringConvert.GetLanguageStringByKey("C0031");
  648. opType = 6;
  649. }
  650. if (tag == "结束")
  651. {
  652. tag = KeyToStringConvert.GetLanguageStringByKey("C0313");
  653. }
  654. // case "取消": EmbryoMark((int)EmbryoState.None); break;
  655. var rs = new MessageWindow(AppData.Instance.MainWindow, infoString, tag).ShowDialog();
  656. if (rs == true)
  657. {
  658. switch (opType)
  659. {
  660. case 2:
  661. EmbryoMark((int)EmbryoState.Freezing);
  662. break;
  663. case 4:
  664. EmbryoMark((int)EmbryoState.Cancellation);
  665. break;
  666. case 1:
  667. EmbryoMark((int)EmbryoState.Transplant);
  668. break;
  669. case 3:
  670. EmbryoMark((int)EmbryoState.Delete);
  671. break;
  672. case 5:
  673. Finish();
  674. break;
  675. case 6:
  676. EmbryoMark((int)EmbryoState.None);
  677. break;
  678. default:
  679. break;
  680. }
  681. }
  682. }
  683. //private void EmbryoOp(string tag, string infoString,int opType)
  684. //{
  685. // if (tag == "完成")
  686. // {
  687. // //new MessageWindow(AppData.Instance.MainWindow, infoString, "消息提示").ShowDialog();
  688. // new MessageWindow(AppData.Instance.MainWindow, infoString, KeyToStringConvert.GetLanguageStringByKey("C0171")).ShowDialog();
  689. // return;
  690. // }
  691. // var rs = new MessageWindow(AppData.Instance.MainWindow, infoString, tag).ShowDialog();
  692. // if (rs == true)
  693. // {
  694. // switch (tag)
  695. // {
  696. // case "冷冻":
  697. // EmbryoMark((int)EmbryoState.Freezing);
  698. // break;
  699. // case "作废":
  700. // EmbryoMark((int)EmbryoState.Cancellation);
  701. // break;
  702. // case "移植":
  703. // EmbryoMark((int)EmbryoState.Transplant);
  704. // break;
  705. // case "删除":
  706. // EmbryoMark((int)EmbryoState.Delete);
  707. // break;
  708. // case "结束":
  709. // Finish();
  710. // break;
  711. // case "取消":
  712. // EmbryoMark((int)EmbryoState.None);
  713. // break;
  714. // default:
  715. // break;
  716. // }
  717. // }
  718. //}
  719. /// <summary>
  720. /// 结束培养
  721. /// </summary>
  722. /// <exception cref="NotImplementedException"></exception>
  723. private void Finish()
  724. {
  725. try
  726. {
  727. if (!AppData.Instance.HttpHelper.EndCultureRecordApi(vm.ExDish.id))
  728. {
  729. //new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "结束培养失败");
  730. new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0252"));
  731. return;
  732. }
  733. AppData.Instance.MainPageView.EndDish(vm.ExDish.houseSn);
  734. vm.ExDish = new ExDish();
  735. PlayerPause();
  736. PlayerDispose();
  737. if (vm != null && vm.ParentViewModel != null)
  738. {
  739. DishRecordView dishRecordView = new DishRecordView()
  740. {
  741. DataContext = vm.ParentViewModel,
  742. };
  743. AppData.Instance.MainWindow.LoadPage(dishRecordView);
  744. return;
  745. }
  746. AppData.Instance.BackMainPage();
  747. }
  748. catch (Exception ex)
  749. {
  750. ExLog(ex, "Finish");
  751. }
  752. }
  753. private void EmbryoMark(int embryoState)
  754. {
  755. try
  756. {
  757. if (!AppData.Instance.HttpHelper.MarkEmbryoDestinationApi(vm.CurrentEmbryo.id, embryoState))
  758. {
  759. //new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, "胚胎标记失败");
  760. new MessagePrompt().ShowCenterOwnerDefeat(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0253"));
  761. return;
  762. }
  763. DateTime ct = DateTime.Now;
  764. vm.CurrentEmbryo.state = embryoState;
  765. vm.CurrentEmbryo.stateTime = ct;
  766. this._dishInfo.SetEmbryoState(vm.CurrentEmbryo.wellSn, vm.CurrentEmbryo.state, vm.CurrentEmbryo.alarm);
  767. if(string.IsNullOrEmpty(vm.ExDish.endTime)) AppData.Instance.MainPageView.SetMainEmbryoState(vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.wellSn, vm.CurrentEmbryo.state);
  768. }
  769. catch (Exception ex)
  770. {
  771. ExLog(ex, "EmbryoMark");
  772. }
  773. }
  774. private string GetMessageInfo(string stateString)
  775. {
  776. return $"{s1}{spaceString}{stateString}{spaceString}{s2}{vm.CurrentEmbryo.wellSn}{haoString}?";
  777. }
  778. private string GetMarkMessage(string stateString)
  779. {
  780. return $"{s5}{vm.CurrentEmbryo.wellSn}{spaceString}{s6}{spaceString}{stateString}";
  781. }
  782. private string GetCancelMarkMessage()
  783. {
  784. return $"{s3}{spaceString}{vm.CurrentEmbryo.wellSn}{haoString}?";
  785. }
  786. #endregion
  787. #region 视频操作
  788. /// <summary>
  789. /// 播放暂停按钮
  790. /// </summary>
  791. /// <param name="sender"></param>
  792. /// <param name="e"></param>
  793. private void Image_MouseUp_Play(object sender, MouseButtonEventArgs e)
  794. {
  795. if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
  796. {
  797. if (PlayerState == PlayerStateEnum.Playing)
  798. {
  799. PlayerPause();
  800. }
  801. else
  802. {
  803. newCurrentTime = -1;
  804. //this._dishInfo._preview.Visibility = Visibility.Hidden;
  805. this._dishInfo.Cancas_Preview.Visibility = Visibility.Hidden;
  806. if (!PlayerPlay())
  807. {
  808. this._dishInfo.SetPreviewNoVideo();
  809. }
  810. }
  811. }
  812. else
  813. {
  814. this._dishInfo.SetPreviewNoVideo();
  815. }
  816. }
  817. /// <summary>
  818. /// 上一帧按钮
  819. /// </summary>
  820. /// <param name="sender"></param>
  821. /// <param name="e"></param>
  822. private void Image_MouseUp_PreviousFrame(object sender, MouseButtonEventArgs e)
  823. {
  824. if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
  825. {
  826. PlayerPause();
  827. PlayerLastFrame(AppData.Instance.TLSettingCommon.videoFps);
  828. //this._dishInfo._preview.Visibility = Visibility.Hidden;
  829. this._dishInfo.Cancas_Preview.Visibility = Visibility.Hidden;
  830. }
  831. }
  832. /// <summary>
  833. /// 下一帧按钮
  834. /// </summary>
  835. /// <param name="sender"></param>
  836. /// <param name="e"></param>
  837. private void Image_MouseUp_NextFrame(object sender, MouseButtonEventArgs e)
  838. {
  839. if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
  840. {
  841. PlayerPause();
  842. PlayerNextFrame(AppData.Instance.TLSettingCommon.videoFps);
  843. this._dishInfo.Cancas_Preview.Visibility = Visibility.Hidden;
  844. //this._dishInfo._preview.Visibility = Visibility.Hidden;
  845. }
  846. }
  847. /// <summary>
  848. /// 播放倍速按钮
  849. /// </summary>
  850. /// <param name="sender"></param>
  851. /// <param name="e"></param>
  852. private void SpeedRatio_Click(object sender, RoutedEventArgs e)
  853. {
  854. PlayerPause();
  855. if (this._beilvwindow_Border.Height == 324)
  856. {
  857. CloseBeiLvWindow();
  858. }
  859. else
  860. {
  861. OpenBeiLvWindow();
  862. }
  863. }
  864. /// <summary>
  865. /// 关闭倍率设置按钮
  866. /// </summary>
  867. /// <param name="sender"></param>
  868. /// <param name="e"></param>
  869. private void BeiLvClose_MouseUp(object sender, MouseButtonEventArgs e)
  870. {
  871. CloseBeiLvWindow();
  872. }
  873. /// <summary>
  874. /// 设置倍率
  875. /// </summary>
  876. /// <param name="sender"></param>
  877. /// <param name="e"></param>
  878. private void BeiLv_MouseUp(object sender, MouseButtonEventArgs e)
  879. {
  880. try
  881. {
  882. PlayerPause();
  883. if (sender is TextBlock text)
  884. {
  885. int k = int.Parse(text.Tag.ToString());
  886. //var v = 362.5 * k;
  887. var v = 290 * k;
  888. this._beilv_Rectangle.Width = v;
  889. this._beilv_Ellipse.Margin = new Thickness((v - 42), 0, 0, 0);
  890. double fps = -1;
  891. switch (k)
  892. {
  893. case 0:
  894. fps = 0.25;
  895. break;
  896. case 1:
  897. fps = 0.5;
  898. break;
  899. case 2:
  900. fps = 1.0;
  901. break;
  902. case 3:
  903. fps = 1.25;
  904. break;
  905. case 4:
  906. fps = 1.5;
  907. break;
  908. case 5:
  909. fps = 2.0;
  910. break;
  911. }
  912. if (fps != -1)
  913. {
  914. beilv = fps;
  915. this._radius_Button.Content = text.Text;
  916. }
  917. }
  918. }
  919. catch (Exception ex)
  920. {
  921. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}设置倍率", LogEnum.RunException);
  922. }
  923. }
  924. /// <summary>
  925. /// 上一层
  926. /// </summary>
  927. /// <param name="sender"></param>
  928. /// <param name="e"></param>
  929. private void Image_MouseDown_BigFocus(object sender, MouseButtonEventArgs e)
  930. {
  931. PlayerPause();
  932. if (vm == null || vm.CurrentPic == null || vm.CurrentWellDishPicAndVideo == null) return;
  933. if (vm.CurrentEmbryo == null) return;
  934. if (vm.CurrentWellLayerPicAndVideo != null) ChangeFocalNoVideo(true);
  935. //PlayerPause();
  936. //if (vm == null || vm.CurrentPic == null || vm.CurrentWellDishPicAndVideo == null) return;
  937. //if (vm.CurrentEmbryo == null) return;
  938. //if (vm.CurrentWellLayerPicAndVideo != null) if (!string.IsNullOrEmpty(vm.CurrentWellLayerPicAndVideo.videoUrl)) ChangeFocal(true);
  939. // else ChangeImageFocal(true);
  940. }
  941. /// <summary>
  942. /// 下一层
  943. /// </summary>
  944. /// <param name="sender"></param>
  945. /// <param name="e"></param>
  946. private void Image_MouseDown_SmallFocus(object sender, MouseButtonEventArgs e)
  947. {
  948. PlayerPause();
  949. if (vm == null || vm.CurrentPic == null || vm.CurrentWellDishPicAndVideo == null) return;
  950. if (vm.CurrentEmbryo == null) return;
  951. if (vm.CurrentWellLayerPicAndVideo != null) ChangeFocalNoVideo(false);
  952. //PlayerPause();
  953. //ChangeFocal(false);
  954. //PlayerPause();
  955. //if (vm == null || vm.CurrentPic == null || vm.CurrentWellDishPicAndVideo == null) return;
  956. //if (vm.CurrentEmbryo == null) return;
  957. //if (vm.CurrentWellLayerPicAndVideo != null) if (!string.IsNullOrEmpty(vm.CurrentWellLayerPicAndVideo.videoUrl)) ChangeFocal(false);
  958. // else ChangeImageFocal(false);
  959. }
  960. private void CustomQuickButton_ClickQuickPositionEvent(ButtonEntity obj)
  961. {
  962. try
  963. {
  964. PlayerPause();
  965. string quickName = obj.buttonName;
  966. int minHour = obj.minHour * 60;
  967. if (vm.CurrentWellLayerPicAndVideo == null || vm.CurrentWellLayerPicAndVideo.videoPictures == null || !vm.CurrentWellLayerPicAndVideo.videoPictures.Any())
  968. {
  969. //ShowMessage($"当前胚胎还未发育到{quickName}阶段");
  970. ShowMessage($"{KeyToStringConvert.GetLanguageStringByKey("C0320")} {quickName}");
  971. return;
  972. }
  973. var lastPic = vm.CurrentWellLayerPicAndVideo.videoPictures.Last();
  974. if (minHour > lastPic.developTime)
  975. {
  976. ShowMessage($"{KeyToStringConvert.GetLanguageStringByKey("C0320")} {quickName}");
  977. return;
  978. }
  979. int picCount = vm.CurrentWellLayerPicAndVideo.videoPictures.Count;
  980. for (int i = 0; i < picCount; i++)
  981. {
  982. var item = vm.CurrentWellLayerPicAndVideo.videoPictures[i];
  983. if (item.developTime > minHour)
  984. {
  985. if (string.IsNullOrEmpty(vm.CurrentWellLayerPicAndVideo.videoUrl) || vm.CurrentWellLayerPicAndVideo.videoUrl == CleanVideoString)
  986. {
  987. this._dishInfo.Cancas_Preview.Visibility = Visibility.Visible;
  988. vm.VideoCurrentTime = i + 1;
  989. this._dishInfo._preview.Source = AppData.Instance.ConvertHelper.StringToBitmapImage($"{AppData.Instance.BaseUrl}{item.imageUrl}?token={AppData.Instance.HttpHelper.GetToken()}");
  990. }
  991. else
  992. {
  993. if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
  994. {
  995. this._dishInfo.Cancas_Preview.Visibility = Visibility.Hidden;
  996. //double pro = ((i + 1) / (double)picCount) * vm.VideoAllTime;
  997. double pro = i * (1000.00 / vm.CurrentWellLayerPicAndVideo.fps);
  998. SetTimeProgressbarProgressValue(pro);
  999. SetPlayerPosition(pro);
  1000. }
  1001. else
  1002. {
  1003. this._dishInfo.Cancas_Preview.Visibility = Visibility.Visible;
  1004. vm.VideoCurrentTime = i + 1;
  1005. this._dishInfo._preview.Source = AppData.Instance.ConvertHelper.StringToBitmapImage($"{AppData.Instance.BaseUrl}{item.imageUrl}?token={AppData.Instance.HttpHelper.GetToken()}");
  1006. }
  1007. }
  1008. break;
  1009. }
  1010. //if (item.developTime > minHour)
  1011. //{
  1012. // this._dishInfo.Cancas_Preview.Visibility = Visibility.Hidden;
  1013. // double pro = i * (1000.00 / vm.CurrentWellLayerPicAndVideo.fps);
  1014. // SetTimeProgressbarProgressValue(pro);
  1015. // SetPlayerPosition(pro);
  1016. // break;
  1017. //}
  1018. }
  1019. }
  1020. catch (Exception ex)
  1021. {
  1022. ExLog(ex, $"CustomQuickButton_ClickQuickPositionEvent");
  1023. }
  1024. }
  1025. private void BeforeInteractionEvent()
  1026. {
  1027. PlayerPause();
  1028. if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
  1029. {
  1030. //this._dishInfo._preview.Visibility = Visibility.Hidden;
  1031. this._dishInfo.Cancas_Preview.Visibility = Visibility.Hidden;
  1032. }
  1033. }
  1034. private void AfterInteractionEvent(double obj)
  1035. {
  1036. if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
  1037. {
  1038. currentMediaElement.LoadedBehavior = MediaState.Manual;
  1039. SetPlayerPosition(obj);
  1040. }
  1041. else
  1042. {
  1043. if (vm.CurrentWellLayerPicAndVideo != null && vm.CurrentWellLayerPicAndVideo.videoPictures.Any()) this._dishInfo._preview.Source = AppData.Instance.ConvertHelper.StringToBitmapImage($"{AppData.Instance.BaseUrl}{vm.CurrentWellLayerPicAndVideo.videoPictures[ProToImageIndex()].imageUrl}?token={AppData.Instance.HttpHelper.GetToken()}");
  1044. }
  1045. }
  1046. private void ProChangendEvent(double obj)
  1047. {
  1048. if (PlayerState != PlayerStateEnum.Nothing || PlayerState != PlayerStateEnum.Error) SetPlayerPosition(obj);
  1049. }
  1050. List<PictureEntity> PicList = null;
  1051. int picCount = 0;
  1052. int picIndex = 0;
  1053. private string CustomProgressbar_LengthDevelopmentEvent(double arg)
  1054. {
  1055. try
  1056. {
  1057. if (vm == null || vm.CurrentWellLayerPicAndVideo == null)
  1058. {
  1059. vm.CurrentPic = null;
  1060. return "00h:00m";
  1061. }
  1062. if (vm.CurrentWellLayerPicAndVideo == null || vm.CurrentWellLayerPicAndVideo.videoPictures == null || !vm.CurrentWellLayerPicAndVideo.videoPictures.Any())
  1063. {
  1064. vm.CurrentPic = null;
  1065. return "00h:00m";
  1066. }
  1067. if (string.IsNullOrEmpty(vm.CurrentWellLayerPicAndVideo.videoUrl) || vm.CurrentWellLayerPicAndVideo.videoUrl == CleanVideoString)
  1068. {
  1069. picIndex = ProToImageIndex();
  1070. vm.CurrentPic = vm.CurrentWellLayerPicAndVideo.videoPictures[picIndex];
  1071. //Debug.WriteLine($"proLength {picIndex} ->{vm.CurrentWellLayerPicAndVideo.videoPictures.Count}");
  1072. return $"{(vm.CurrentPic.developTime / 60).ToString("D2")}h:{(vm.CurrentPic.developTime % 60).ToString("D2")}m";
  1073. }
  1074. else
  1075. {
  1076. picCount = vm.CurrentWellLayerPicAndVideo.videoPictures.Count;
  1077. picIndex = VideoProToImageIndex();
  1078. if (picIndex < 0) picIndex = 0;
  1079. if (picIndex > (picCount - 1)) picIndex = picCount - 1;
  1080. vm.CurrentPic = vm.CurrentWellLayerPicAndVideo.videoPictures[picIndex];
  1081. return $"{(vm.CurrentPic.developTime / 60).ToString("D2")}h:{(vm.CurrentPic.developTime % 60).ToString("D2")}m";
  1082. }
  1083. }
  1084. catch (Exception ex)
  1085. {
  1086. vm.CurrentPic = null;
  1087. ExLog(ex, "获取当前帧发育时长");
  1088. return "00h:00m";
  1089. }
  1090. }
  1091. /// <summary>
  1092. /// 0- count-1
  1093. /// </summary>
  1094. /// <returns></returns>
  1095. public int VideoProToImageIndex()
  1096. {
  1097. try
  1098. {
  1099. if (vm == null || vm.CurrentWellLayerPicAndVideo == null) return 0;
  1100. return (int)(vm.VideoCurrentTime / (1000.00 / vm.CurrentWellLayerPicAndVideo.fps));
  1101. }
  1102. catch (Exception ex)
  1103. {
  1104. ExLog(ex, "VideoProToImageIndex");
  1105. return 0;
  1106. }
  1107. //try
  1108. //{
  1109. // return (int)(vm.VideoCurrentTime / (1000.00 / vm.CurrentVideoFps));
  1110. //}
  1111. //catch (Exception ex)
  1112. //{
  1113. // ExLog(ex, "VideoProToImageIndex");
  1114. // return 0;
  1115. //}
  1116. }
  1117. /// <summary>
  1118. /// 进度条换算图片下标
  1119. /// </summary>
  1120. /// <returns></returns>
  1121. public int ProToImageIndex()
  1122. {
  1123. try
  1124. {
  1125. if (vm == null || vm.CurrentWellLayerPicAndVideo == null || !vm.CurrentWellLayerPicAndVideo.videoPictures.Any()) return 0;
  1126. var imageIndex = ((int)vm.VideoCurrentTime - 1);
  1127. if (imageIndex < 0) imageIndex = 0;
  1128. if (imageIndex >= vm.CurrentWellLayerPicAndVideo.videoPictures.Count) imageIndex = vm.CurrentWellLayerPicAndVideo.videoPictures.Count - 1;
  1129. return imageIndex;
  1130. }
  1131. catch (Exception ex)
  1132. {
  1133. ExLog(ex, "ProToImageIndex");
  1134. return 0;
  1135. }
  1136. }
  1137. #endregion
  1138. #region
  1139. /// <summary>
  1140. /// 切换图层
  1141. /// </summary>
  1142. /// <param name="isMax"></param>
  1143. private void ChangeFocal(bool isMax)
  1144. {
  1145. try
  1146. {
  1147. if (vm.CurrentEmbryo == null) return;
  1148. if (vm == null || vm.CurrentPic == null || vm.CurrentWellDishPicAndVideo == null) return;
  1149. int maxFocal = (vm.CurrentPic.totalLayer - 1) / 2;
  1150. int minFocal = -maxFocal;
  1151. int newCurrentFocal = vm.CurrentFocal;
  1152. if (isMax) newCurrentFocal++;
  1153. else newCurrentFocal--;
  1154. if (newCurrentFocal < maxFocal) BigFocusIsEnabled(true);
  1155. else BigFocusIsEnabled(false);
  1156. if (newCurrentFocal > minFocal) SmallFocusIsEnabled(true);
  1157. else SmallFocusIsEnabled(false);
  1158. if (newCurrentFocal < minFocal || newCurrentFocal > maxFocal) return;
  1159. //this._dishInfo._preview.Visibility = Visibility.Hidden;
  1160. Task.Run(() =>
  1161. {
  1162. Dispatcher.Invoke(() =>
  1163. {
  1164. var a = AppData.Instance.ConvertHelper.StringToBitmapImage($"{AppData.Instance.BaseUrl}{AppData.Instance.HttpHelper.GetImageUrlApi(vm.CurrentEmbryo.tlSn, vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, newCurrentFocal, vm.CurrentPic.developTime)}?token={AppData.Instance.HttpHelper.GetToken()}");
  1165. if (a != null)
  1166. {
  1167. this._dishInfo.Cancas_Preview.Visibility = Visibility.Visible;
  1168. //this._dishInfo._preview.Visibility = Visibility.Visible;
  1169. this._dishInfo._preview.Source = a;
  1170. }
  1171. });
  1172. });
  1173. newCurrentTime = 0;
  1174. vm.CurrentFocal = newCurrentFocal;
  1175. //SetVideoButtonState(false);
  1176. //var time1 = stopwatch.Elapsed;
  1177. //DebugLog($"切换图层确定新图层:{DateTime.Now},耗时:{time1.TotalMilliseconds}");
  1178. if (vm.CurrentWellDishPicAndVideo == null) return;
  1179. vm.CurrentWellLayerPicAndVideo = vm.CurrentWellDishPicAndVideo.videos.FirstOrDefault(x => x.pictureLayer == vm.CurrentFocal);
  1180. SetVideo(vm.CurrentFocal, false);
  1181. if (vm.CurrentWellLayerPicAndVideo.videoPictures == null || !vm.CurrentWellLayerPicAndVideo.videoPictures.Any())
  1182. {
  1183. vm.CurrentWellLayerPicAndVideo.videoPictures = AppData.Instance.HttpHelper.GetVideoTimeLineApi(vm.CurrentEmbryo.tlSn, vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, vm.CurrentFocal);
  1184. }
  1185. if (vm.CurrentWellLayerPicAndVideo.videoPictures == null || !vm.CurrentWellLayerPicAndVideo.videoPictures.Any() || vm.CurrentPic == null) return;
  1186. int i = 0;
  1187. foreach (var item in vm.CurrentWellLayerPicAndVideo.videoPictures)
  1188. {
  1189. if (item.developTime >= vm.CurrentPic.developTime) break;
  1190. i++;
  1191. }
  1192. newCurrentTime = i * (1000.00 / vm.CurrentWellLayerPicAndVideo.fps);
  1193. //if (i == 0) newCurrentTime = 0;
  1194. //else newCurrentTime = (i + 1) * (1000.00 / vm.CurrentWellLayerPicAndVideo.fps);
  1195. //var time2 = stopwatch.Elapsed;
  1196. //DebugLog($"切换图层确定新图层:{DateTime.Now},耗时:{(time2 - time1).TotalMilliseconds},切换图层以及设置视频源总耗时:{time2.TotalMilliseconds}");
  1197. }
  1198. catch (Exception ex)
  1199. {
  1200. ExLog(ex, "ChangeFocal");
  1201. }
  1202. }
  1203. private void ChangeFocalNoVideo(bool isMax)
  1204. {
  1205. try
  1206. {
  1207. //DebugLog($"开始切换图层:{DateTime.Now}");
  1208. int maxFocal = (vm.CurrentPic.totalLayer - 1) / 2;
  1209. int minFocal = -maxFocal;
  1210. int newCurrentFocal = vm.CurrentFocal;
  1211. CC:
  1212. if (isMax) newCurrentFocal++;
  1213. else newCurrentFocal--;
  1214. if (newCurrentFocal < maxFocal) BigFocusIsEnabled(true);
  1215. else BigFocusIsEnabled(false);
  1216. if (newCurrentFocal > minFocal) SmallFocusIsEnabled(true);
  1217. else SmallFocusIsEnabled(false);
  1218. if (newCurrentFocal < minFocal || newCurrentFocal > maxFocal) return;
  1219. var aa = vm.CurrentWellDishPicAndVideo.videos.FirstOrDefault(x => x.pictureLayer == newCurrentFocal);
  1220. if (aa == null) goto CC;
  1221. if (aa.videoPictures == null || !aa.videoPictures.Any())
  1222. {
  1223. aa.videoPictures = AppData.Instance.HttpHelper.GetVideoTimeLineApi(vm.CurrentEmbryo.tlSn, vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, newCurrentFocal);
  1224. }
  1225. if (aa.videoPictures == null || !aa.videoPictures.Any()) goto CC;
  1226. bool b = false;
  1227. string imageUrl = null;
  1228. foreach (var item in aa.videoPictures)
  1229. {
  1230. if (item.developTime == vm.CurrentPic.developTime)
  1231. {
  1232. b = true;
  1233. imageUrl = item.imageUrl;
  1234. break;
  1235. }
  1236. }
  1237. if (!b) goto CC;
  1238. Task.Run(() =>
  1239. {
  1240. if (string.IsNullOrEmpty(imageUrl)) imageUrl = AppData.Instance.HttpHelper.GetImageUrlApi(vm.CurrentEmbryo.tlSn, vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, newCurrentFocal, vm.CurrentPic.developTime);
  1241. Dispatcher.Invoke(() =>
  1242. {
  1243. var a = AppData.Instance.ConvertHelper.StringToBitmapImage($"{AppData.Instance.BaseUrl}{imageUrl}?token={AppData.Instance.HttpHelper.GetToken()}");
  1244. if (a != null)
  1245. {
  1246. //this._dishInfo._preview.Visibility = Visibility.Visible;
  1247. this._dishInfo.Cancas_Preview.Visibility = Visibility.Visible;
  1248. this._dishInfo._preview.Source = a;
  1249. }
  1250. });
  1251. });
  1252. vm.CurrentFocal = newCurrentFocal;
  1253. }
  1254. catch (Exception ex)
  1255. {
  1256. ExLog(ex, "ChangeFocalNoVideo");
  1257. }
  1258. }
  1259. /// <summary>
  1260. /// 切换图层
  1261. /// </summary>
  1262. /// <param name="isMax"></param>
  1263. private void ChangeImageFocal(bool isMax)
  1264. {
  1265. try
  1266. {
  1267. int maxFocal = (vm.CurrentPic.totalLayer - 1) / 2;
  1268. int minFocal = -maxFocal;
  1269. int newCurrentFocal = vm.CurrentFocal;
  1270. CC:
  1271. if (isMax) newCurrentFocal++;
  1272. else newCurrentFocal--;
  1273. if (newCurrentFocal < maxFocal) BigFocusIsEnabled(true);
  1274. else BigFocusIsEnabled(false);
  1275. if (newCurrentFocal > minFocal) SmallFocusIsEnabled(true);
  1276. else SmallFocusIsEnabled(false);
  1277. if (newCurrentFocal < minFocal || newCurrentFocal > maxFocal) return;
  1278. var newCurrentWellLayerPicAndVideo = vm.CurrentWellDishPicAndVideo.videos.FirstOrDefault(x => x.pictureLayer == newCurrentFocal);
  1279. newCurrentWellLayerPicAndVideo = vm.CurrentWellDishPicAndVideo.videos.FirstOrDefault(x => x.pictureLayer == newCurrentFocal);
  1280. if (newCurrentWellLayerPicAndVideo == null)
  1281. {
  1282. goto CC;
  1283. return;
  1284. }
  1285. if (!newCurrentWellLayerPicAndVideo.videoPictures.Any())
  1286. {
  1287. goto CC;
  1288. return;
  1289. }
  1290. vm.CurrentWellLayerPicAndVideo = newCurrentWellLayerPicAndVideo;
  1291. //this._dishInfo._preview.Visibility = Visibility.Visible;
  1292. this._dishInfo.Cancas_Preview.Visibility = Visibility.Visible;
  1293. var oldDevelopTime = vm.CurrentPic.developTime;
  1294. vm.CurrentFocal = newCurrentFocal;
  1295. vm.VideoAllTime = vm.CurrentWellLayerPicAndVideo.videoPictures.Count;
  1296. int i = 0;
  1297. foreach (var item in vm.CurrentWellLayerPicAndVideo.videoPictures)
  1298. {
  1299. if (item.developTime >= oldDevelopTime) break;
  1300. i++;
  1301. }
  1302. //Debug.WriteLine($"{vm.CurrentWellLayerPicAndVideo.videoPictures[163].developTime} -> {oldDevelopTime}");
  1303. //Debug.WriteLine($"focal:{i} -》 {vm.CurrentWellLayerPicAndVideo.videoPictures.Count}");
  1304. //vm.VideoCurrentTime = vm.VideoAllTime;
  1305. this._dishInfo._preview.Source = AppData.Instance.ConvertHelper.StringToBitmapImage($"{AppData.Instance.BaseUrl}{vm.CurrentWellLayerPicAndVideo.videoPictures[i].imageUrl}?token={AppData.Instance.HttpHelper.GetToken()}");
  1306. vm.VideoCurrentTime = 0;
  1307. vm.VideoCurrentTime = i + 1;
  1308. return;
  1309. }
  1310. catch (Exception ex)
  1311. {
  1312. ExLog(ex, "ChangeImageFocal");
  1313. }
  1314. }
  1315. /// <summary>
  1316. /// 设置视频
  1317. /// </summary>
  1318. private bool SetVideo(int focal, bool isUpdate)
  1319. {
  1320. if (vm.CurrentWellLayerPicAndVideo != null && !string.IsNullOrEmpty(vm.CurrentWellLayerPicAndVideo.videoUrl) && vm.CurrentWellLayerPicAndVideo.videoUrl != CleanVideoString)
  1321. {
  1322. if (PlayerSetSource($"{AppData.Instance.BaseUrl}{vm.CurrentWellLayerPicAndVideo.videoUrl}?token={AppData.Instance.HttpHelper.GetToken()}")) return true;
  1323. }
  1324. if (!isUpdate) return false;
  1325. vm.VideoAllTime = 1;
  1326. vm.VideoCurrentTime = 0;
  1327. return true;
  1328. }
  1329. private void BigFocusIsEnabled(bool isEn)
  1330. {
  1331. if (this._bigFocus_Border.IsEnabled == isEn) return;
  1332. this._bigFocus_Border.IsEnabled = isEn;
  1333. if (isEn)
  1334. {
  1335. this._bigFocus_Border.Background = (LinearGradientBrush)this.FindResource("BuleLinear");
  1336. this._bigFocus_Image.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/prePicNum.png", UriKind.RelativeOrAbsolute));
  1337. }
  1338. else
  1339. {
  1340. this._bigFocus_Border.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8B8B8B"));
  1341. this._bigFocus_Image.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/prePicNumEnabled.png", UriKind.RelativeOrAbsolute));
  1342. }
  1343. }
  1344. private void SmallFocusIsEnabled(bool isEn)
  1345. {
  1346. if (this._smallFocus_Border.IsEnabled == isEn) return;
  1347. this._smallFocus_Border.IsEnabled = isEn;
  1348. if (isEn)
  1349. {
  1350. this._smallFocus_Border.Background = (LinearGradientBrush)this.FindResource("BuleLinear");
  1351. this._smallFocus_Image.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/nextPicNum.png", UriKind.RelativeOrAbsolute));
  1352. }
  1353. else
  1354. {
  1355. this._smallFocus_Border.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8B8B8B"));
  1356. this._smallFocus_Image.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/nextPicNumEnabled.png", UriKind.RelativeOrAbsolute));
  1357. }
  1358. }
  1359. #endregion
  1360. #region 视频基础操作
  1361. MediaElement currentMediaElement = null;
  1362. string currentViewName = "详情页面";
  1363. /// <summary>
  1364. /// 定时器
  1365. /// </summary>
  1366. public System.Timers.Timer dispatcherTimer = new System.Timers.Timer();
  1367. /// <summary>
  1368. /// 视频状态
  1369. /// </summary>
  1370. public PlayerStateEnum PlayerState { get; set; } = PlayerStateEnum.Nothing;
  1371. /// <summary>
  1372. /// 播放器事件初始化
  1373. /// </summary>
  1374. public void PlayerEvent(MediaElement mediaElement)
  1375. {
  1376. try
  1377. {
  1378. currentMediaElement = mediaElement;
  1379. currentMediaElement.MediaEnded -= MediaEndedEvent;
  1380. currentMediaElement.MediaOpened -= MediaOpenedEvent;
  1381. currentMediaElement.MediaFailed -= MediaFailedEvent;
  1382. currentMediaElement.MediaEnded += MediaEndedEvent;
  1383. currentMediaElement.MediaOpened += MediaOpenedEvent;
  1384. currentMediaElement.MediaFailed += MediaFailedEvent;
  1385. dispatcherTimer.Interval = 25;
  1386. dispatcherTimer.Elapsed -= dispatcherTimer_Elapsed;
  1387. dispatcherTimer.Elapsed += dispatcherTimer_Elapsed;
  1388. }
  1389. catch (Exception ex)
  1390. {
  1391. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}播放器事件初始化", LogEnum.RunException);
  1392. }
  1393. }
  1394. /// <summary>
  1395. /// 设置播放源
  1396. /// </summary>
  1397. /// <param name="FileName"></param>
  1398. public bool PlayerSetSource(string FileName)
  1399. {
  1400. try
  1401. {
  1402. ErrorLog($"开始加载视频,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}", LogEnum.TakeTime);
  1403. PlayerDispose();
  1404. //指定媒体文件地址
  1405. currentMediaElement.LoadedBehavior = MediaState.Manual;
  1406. currentMediaElement.SpeedRatio = 1;
  1407. beilv = 1;
  1408. ChangeBeiLvUi();
  1409. this._radius_Button.Content = "1.0x";
  1410. this._radius_Button.Tag = 1.0;
  1411. currentMediaElement.Source = new Uri(FileName, UriKind.RelativeOrAbsolute);
  1412. currentMediaElement.ScrubbingEnabled = true;
  1413. currentMediaElement.Play();
  1414. currentMediaElement.Pause();
  1415. return true;
  1416. }
  1417. catch (Exception ex)
  1418. {
  1419. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}设置播放源", LogEnum.RunException);
  1420. return false;
  1421. }
  1422. }
  1423. /// <summary>
  1424. /// 播放器加载视频完成事件
  1425. /// </summary>
  1426. /// <param name="sender"></param>
  1427. /// <param name="e"></param>
  1428. private void MediaOpenedEvent(object sender, RoutedEventArgs e)
  1429. {
  1430. try
  1431. {
  1432. if (vm == null) return;
  1433. //ErrorLog($"视频加载完成,开始设置属性,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")},[{currentMediaElement.Source}]", LogEnum.TakeTime);
  1434. ErrorLog($"视频加载完成", LogEnum.TakeTime);
  1435. currentMediaElement.ScrubbingEnabled = false;
  1436. vm.VideoAllTime = 1;
  1437. vm.VideoCurrentTime = 0;
  1438. if (currentMediaElement.NaturalDuration.HasTimeSpan)
  1439. {
  1440. currentMediaElement.LoadedBehavior = MediaState.Manual;
  1441. PlayerState = PlayerStateEnum.Paused;
  1442. currentMediaElement.Play();
  1443. currentMediaElement.Pause();
  1444. vm.VideoAllTime = currentMediaElement.NaturalDuration.TimeSpan.TotalMilliseconds;
  1445. if (newCurrentTime != -1)
  1446. {
  1447. if (newCurrentTime < 0) newCurrentTime = 0;
  1448. if (newCurrentTime > vm.VideoAllTime) newCurrentTime = vm.VideoAllTime;
  1449. SetTimeProgressbarProgressValue(newCurrentTime);
  1450. SetPlayerPosition(vm.VideoCurrentTime);
  1451. newCurrentTime = -1;
  1452. }
  1453. else
  1454. {
  1455. SetTimeProgressbarProgressValue(vm.VideoAllTime);
  1456. SetPlayerPosition(vm.VideoCurrentTime);
  1457. }
  1458. currentMediaElement.ScrubbingEnabled = true;
  1459. SetVideoButtonState(true);
  1460. }
  1461. else
  1462. {
  1463. PlayerState = PlayerStateEnum.Nothing;
  1464. }
  1465. ErrorLog($"视频加载完成,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}", LogEnum.TakeTime);
  1466. }
  1467. catch (Exception ex)
  1468. {
  1469. PlayerState = PlayerStateEnum.Error;
  1470. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}播放器加载视频完成事件", LogEnum.RunException);
  1471. }
  1472. }
  1473. /// <summary>
  1474. /// 播放完成事件
  1475. /// </summary>
  1476. /// <param name="sender"></param>
  1477. /// <param name="e"></param>
  1478. private void MediaEndedEvent(object sender, RoutedEventArgs e)
  1479. {
  1480. try
  1481. {
  1482. PlayerState = PlayerStateEnum.Paused;
  1483. dispatcherTimer_Stop();
  1484. // currentMediaElement.Stop();
  1485. currentMediaElement.Play();
  1486. currentMediaElement.Pause();
  1487. SetTimeProgressbarProgressValue(vm.VideoAllTime);
  1488. SetPlayerPosition(vm.VideoAllTime);
  1489. SetPlayButton(false);
  1490. //currentMediaElement.Position = currentMediaElement.NaturalDuration.TimeSpan;
  1491. //currentMediaElement.Play();
  1492. //currentMediaElement.Pause();
  1493. //PlayerSetPosition(1);
  1494. }
  1495. catch (Exception ex)
  1496. {
  1497. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}播放完成事件", LogEnum.RunException);
  1498. }
  1499. }
  1500. /// <summary>
  1501. /// 播放器错误事件
  1502. /// </summary>
  1503. /// <param name="sender"></param>
  1504. /// <param name="e"></param>
  1505. /// <exception cref="NotImplementedException"></exception>
  1506. private void MediaFailedEvent(object? sender, ExceptionRoutedEventArgs e)
  1507. {
  1508. try
  1509. {
  1510. PlayerState = PlayerStateEnum.Error;
  1511. vm.VideoAllTime = 1;
  1512. vm.VideoCurrentTime = 0;
  1513. string ss = "";
  1514. MediaElement med = sender as MediaElement;
  1515. if (med != null)
  1516. {
  1517. ss = med.Source.ToString();
  1518. AppData.Instance.LogHelper.TLLog($"{ss},{currentViewName}视频遇到错误", LogEnum.RunError);
  1519. }
  1520. dispatcherTimer_Stop();
  1521. AppData.Instance.LogHelper.ExceptionLog(e.ErrorException, $"{currentViewName}.MediaFailedEvent:{ss}", LogEnum.RunException);
  1522. }
  1523. catch (Exception ex)
  1524. {
  1525. AppData.Instance.LogHelper.ExceptionLog(ex, $"播放器错误事件:{JsonConvert.SerializeObject(ex)}", LogEnum.RunException);
  1526. }
  1527. }
  1528. /// <summary>
  1529. /// 播放按钮图标设置
  1530. /// </summary>
  1531. private void SetPlayButton(bool isPlaying)
  1532. {
  1533. if (isPlaying)//正在播放,设置为暂停按钮
  1534. {
  1535. _playButton.Source = new BitmapImage(new Uri("/Resources/Image/video_Pause.png", UriKind.RelativeOrAbsolute));
  1536. }
  1537. else//未播放,设置为播放按钮
  1538. {
  1539. _playButton.Source = new BitmapImage(new Uri("/Resources/Image/video_play.png", UriKind.RelativeOrAbsolute));//重置播放按钮
  1540. }
  1541. }
  1542. /// <summary>
  1543. /// 定时器事件
  1544. /// </summary>
  1545. /// <param name="sender"></param>
  1546. /// <param name="e"></param>
  1547. private void dispatcherTimer_Elapsed(object? sender, ElapsedEventArgs e)
  1548. {
  1549. try
  1550. {
  1551. Dispatcher.Invoke(() =>
  1552. {
  1553. SetTimeProgressbarProgressValue(currentMediaElement.Position.TotalMilliseconds);
  1554. });
  1555. if (PlayerState != PlayerStateEnum.Playing)
  1556. {
  1557. dispatcherTimer_Stop();
  1558. }
  1559. }
  1560. catch (Exception ex)
  1561. {
  1562. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}定时器事件", LogEnum.RunException);
  1563. }
  1564. }
  1565. /// <summary>
  1566. /// 停止定时器
  1567. /// </summary>
  1568. public void dispatcherTimer_Stop()
  1569. {
  1570. try
  1571. {
  1572. if (dispatcherTimer.Enabled)
  1573. {
  1574. dispatcherTimer.Enabled = false;
  1575. dispatcherTimer.Stop();
  1576. }
  1577. }
  1578. catch (Exception ex)
  1579. {
  1580. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}停止定时器", LogEnum.RunException);
  1581. }
  1582. }
  1583. public bool isMediaOpened = true;
  1584. /// <summary>
  1585. ///设置视频进度
  1586. /// </summary>
  1587. /// <param name="progressValue"></param>
  1588. public void SetPlayerPosition(double currentTime)
  1589. {
  1590. try
  1591. {
  1592. if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
  1593. {
  1594. //var a = currentMediaElement.NaturalDuration.TimeSpan.TotalMilliseconds;
  1595. currentMediaElement.Position = TimeSpan.FromMilliseconds(currentTime);
  1596. //var a = currentMediaElement.NaturalDuration.TimeSpan.TotalMilliseconds * progressValue;
  1597. //int k = (int)(PlayerAllTime - a);
  1598. //if (k < 0)
  1599. //{
  1600. // k = 0;
  1601. //}
  1602. //vm.PlayTimeString = RevertToTime(b);
  1603. //vm.AllTimeString = RevertToTime(TimeSpan.FromMilliseconds(k));
  1604. }
  1605. }
  1606. catch (Exception ex)
  1607. {
  1608. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}进度条变换以后设置视频进度", LogEnum.RunException);
  1609. }
  1610. }
  1611. /// <summary>
  1612. /// 设置进度条
  1613. /// </summary>
  1614. public void SetTimeProgressbarProgressValue(double newTime)
  1615. {
  1616. try
  1617. {
  1618. if (vm == null) return;
  1619. vm.VideoCurrentTime = newTime;
  1620. //var currentPosition = currentMediaElement.Position.TotalMilliseconds;
  1621. //var b = (currentPosition) / PlayerAllTime;
  1622. //if (b == 0 && PlayerState == PlayerStateEnum.Playing)
  1623. //{
  1624. // return;
  1625. //}
  1626. //vm.PlayTimeString = RevertToTime(currentMediaElement.Position);
  1627. //SetProValue(b);
  1628. //int k = (int)(PlayerAllTime - currentPosition);
  1629. //if (k < 0)
  1630. //{
  1631. // k = 0;
  1632. //}
  1633. //vm.AllTimeString = RevertToTime(TimeSpan.FromMilliseconds(k));
  1634. }
  1635. catch (Exception ex)
  1636. {
  1637. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}视频进度变换以后设置进度条", LogEnum.RunException);
  1638. }
  1639. }
  1640. /// <summary>
  1641. /// 设置进度条进度
  1642. /// </summary>
  1643. /// <param name="newValue"></param>
  1644. public void SetProValue(double newValue)
  1645. {
  1646. //if (vm.ProgressValue == newValue)
  1647. //{
  1648. // var maxNewValue = newValue + 0.01;
  1649. // if (maxNewValue > 1)
  1650. // {
  1651. // var minNewValue = newValue - 0.01;
  1652. // vm.ProgressValue = minNewValue;
  1653. // }
  1654. // else
  1655. // {
  1656. // vm.ProgressValue = maxNewValue;
  1657. // }
  1658. //}
  1659. //vm.ProgressValue = newValue;
  1660. }
  1661. /// <summary>
  1662. /// 释放播放器
  1663. /// </summary>
  1664. public void PlayerDispose()
  1665. {
  1666. try
  1667. {
  1668. dispatcherTimer_Stop();
  1669. if (PlayerState != PlayerStateEnum.Nothing)
  1670. {
  1671. currentMediaElement.Close();
  1672. currentMediaElement.LoadedBehavior = MediaState.Close;
  1673. PlayerState = PlayerStateEnum.Nothing;
  1674. }
  1675. }
  1676. catch (Exception ex)
  1677. {
  1678. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}释放播放器", LogEnum.RunException);
  1679. }
  1680. }
  1681. /// <summary>
  1682. /// 设置倍率
  1683. /// </summary>
  1684. /// <param name="newSpeedRatio"></param>
  1685. public void PlayerSetSpeedRatio(double newSpeedRatio)
  1686. {
  1687. try
  1688. {
  1689. if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
  1690. {
  1691. currentMediaElement.SpeedRatio = newSpeedRatio;
  1692. }
  1693. }
  1694. catch (Exception ex)
  1695. {
  1696. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}设置倍率", LogEnum.RunException);
  1697. }
  1698. }
  1699. /// <summary>
  1700. /// 播放操作
  1701. /// </summary>
  1702. public bool PlayerPlay()
  1703. {
  1704. try
  1705. {
  1706. bool isPlay = false;
  1707. switch (PlayerState)
  1708. {
  1709. case PlayerStateEnum.Error:
  1710. break;
  1711. case PlayerStateEnum.Nothing:
  1712. break;
  1713. case PlayerStateEnum.Opened:
  1714. isPlay = true;
  1715. break;
  1716. case PlayerStateEnum.Paused:
  1717. isPlay = true;
  1718. break;
  1719. case PlayerStateEnum.Playing:
  1720. break;
  1721. case PlayerStateEnum.Stopped:
  1722. currentMediaElement.Stop();
  1723. isPlay = true;
  1724. break;
  1725. default:
  1726. AppData.Instance.LogHelper.TLLog($"{currentViewName}.PlayerPlay,未知的视频状态:{PlayerState.ToString()}", LogEnum.RunError);
  1727. break;
  1728. }
  1729. if (isPlay)
  1730. {
  1731. PlayerState = PlayerStateEnum.Playing;
  1732. if (!dispatcherTimer.Enabled)
  1733. {
  1734. dispatcherTimer.Start();
  1735. }
  1736. if (vm.VideoCurrentTime == vm.VideoAllTime)
  1737. {
  1738. SetPlayerPosition(0);
  1739. }
  1740. //var a = currentMediaElement.Position.TotalMilliseconds;
  1741. PlayerSetSpeedRatio(beilv);
  1742. currentMediaElement.Play();
  1743. SetPlayButton(true);
  1744. return true;
  1745. }
  1746. return false;
  1747. }
  1748. catch (Exception ex)
  1749. {
  1750. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}播放操作", LogEnum.RunException);
  1751. return false;
  1752. }
  1753. }
  1754. /// <summary>
  1755. /// 暂停操作
  1756. /// </summary>
  1757. /// <param name="isSetState"></param>
  1758. public bool PlayerPause()
  1759. {
  1760. try
  1761. {
  1762. bool isPause = false;
  1763. switch (PlayerState)
  1764. {
  1765. case PlayerStateEnum.Error:
  1766. break;
  1767. case PlayerStateEnum.Nothing:
  1768. break;
  1769. case PlayerStateEnum.Opened:
  1770. break;
  1771. case PlayerStateEnum.Paused:
  1772. break;
  1773. case PlayerStateEnum.Playing:
  1774. isPause = true;
  1775. break;
  1776. case PlayerStateEnum.Stopped:
  1777. break;
  1778. }
  1779. if (isPause)
  1780. {
  1781. PlayerState = PlayerStateEnum.Paused;
  1782. currentMediaElement.Pause();
  1783. dispatcherTimer_Stop();
  1784. SetPlayButton(false);
  1785. return true;
  1786. }
  1787. return false;
  1788. }
  1789. catch (Exception ex)
  1790. {
  1791. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}暂停操作", LogEnum.RunException);
  1792. return false;
  1793. }
  1794. }
  1795. /// <summary>
  1796. /// 上一帧
  1797. /// </summary>
  1798. public void PlayerLastFrame(int zhenshu)
  1799. {
  1800. try
  1801. {
  1802. bool isOK = false;
  1803. bool isStop = false;
  1804. switch (PlayerState)
  1805. {
  1806. case PlayerStateEnum.Error:
  1807. break;
  1808. case PlayerStateEnum.Nothing:
  1809. break;
  1810. case PlayerStateEnum.Opened:
  1811. isOK = true;
  1812. break;
  1813. case PlayerStateEnum.Paused:
  1814. isOK = true;
  1815. break;
  1816. case PlayerStateEnum.Playing:
  1817. break;
  1818. case PlayerStateEnum.Stopped:
  1819. isOK = true;
  1820. break;
  1821. }
  1822. if (isOK)
  1823. {
  1824. if (vm.VideoCurrentTime == 0) return;
  1825. var c = vm.VideoCurrentTime - (1000.00 / zhenshu);
  1826. if (c < 0) c = 0;
  1827. SetPlayerPosition(c);
  1828. SetTimeProgressbarProgressValue(c);
  1829. //var zhen = (1000 / zhenshu);
  1830. //var currentPositionTime = currentMediaElement.Position.TotalMilliseconds;
  1831. //if (currentPositionTime == 0)
  1832. //{
  1833. // return;
  1834. //}
  1835. //if (currentPositionTime < zhen)
  1836. //{
  1837. // SetPlayerPosition(0);
  1838. // SetTimeProgressbarProgressValue(0);
  1839. // return;
  1840. //}
  1841. //var c = currentPositionTime - zhen;
  1842. //SetPlayerPosition(c);
  1843. //SetTimeProgressbarProgressValue(c);
  1844. //currentMediaElement.Position = c;
  1845. //SetTimeProgressbarProgressValue(1);
  1846. return;
  1847. }
  1848. else
  1849. {
  1850. }
  1851. //if (isStop)
  1852. //{
  1853. // currentMediaElement.Position = TimeSpan.FromMilliseconds(currentMediaElement.NaturalDuration.TimeSpan.TotalMilliseconds - (1000 / zhenshu));
  1854. // SetTimeProgressbarProgressValue(1);
  1855. // return;
  1856. //}
  1857. }
  1858. catch (Exception ex)
  1859. {
  1860. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}上一帧", LogEnum.RunException);
  1861. }
  1862. }
  1863. /// <summary>
  1864. /// 下一帧
  1865. /// </summary>
  1866. public void PlayerNextFrame(int zhenshu)
  1867. {
  1868. try
  1869. {
  1870. bool isOK = false;
  1871. bool isStop = false;
  1872. switch (PlayerState)
  1873. {
  1874. case PlayerStateEnum.Error:
  1875. break;
  1876. case PlayerStateEnum.Nothing:
  1877. break;
  1878. case PlayerStateEnum.Opened:
  1879. isOK = true;
  1880. break;
  1881. case PlayerStateEnum.Paused:
  1882. isOK = true;
  1883. break;
  1884. case PlayerStateEnum.Playing:
  1885. break;
  1886. case PlayerStateEnum.Stopped:
  1887. isOK = true;
  1888. break;
  1889. }
  1890. if (!isOK) return;
  1891. if (vm.VideoCurrentTime == vm.VideoAllTime) return;
  1892. var newpos = vm.VideoCurrentTime + (1000d / zhenshu);
  1893. if (newpos > vm.VideoAllTime) newpos = vm.VideoAllTime;
  1894. SetPlayerPosition(newpos);
  1895. SetTimeProgressbarProgressValue(newpos);
  1896. return;
  1897. //if (isOK)
  1898. //{
  1899. // var newpos = currentMediaElement.Position.TotalMilliseconds + (1000 / zhenshu);
  1900. // if (newpos > vm.VideoAllTime)
  1901. // {
  1902. // newpos = vm.VideoAllTime;
  1903. // }
  1904. // SetPlayerPosition(newpos);
  1905. // SetTimeProgressbarProgressValue(newpos);
  1906. // return;
  1907. //}
  1908. //else
  1909. //{
  1910. //}
  1911. //if (isStop)
  1912. //{
  1913. // return;
  1914. //}
  1915. }
  1916. catch (Exception ex)
  1917. {
  1918. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}下一帧", LogEnum.RunException);
  1919. }
  1920. }
  1921. #endregion
  1922. /// <summary>
  1923. /// 转换为时分秒格式
  1924. /// </summary>
  1925. /// <param name="timespan"></param>
  1926. /// <returns></returns>
  1927. public string RevertToTime(TimeSpan timespan)
  1928. {
  1929. return $"{(timespan.Days * 24 + timespan.Hours).ToString("D2")}:{timespan.Minutes.ToString("D2")}:{(timespan.Seconds + ((int)Math.Round(timespan.Milliseconds / 1000.00))).ToString("D2")}";
  1930. }
  1931. public void ChangeBeiLvUi()
  1932. {
  1933. int k = 1;
  1934. switch (beilv)
  1935. {
  1936. case 0.5:
  1937. k = 0;
  1938. break;
  1939. case 0.75:
  1940. k = 1;
  1941. break;
  1942. case 1.0:
  1943. k = 2;
  1944. break;
  1945. case 1.25:
  1946. k = 3;
  1947. break;
  1948. case 1.5:
  1949. k = 4;
  1950. break;
  1951. }
  1952. var v = 362.5 * k;
  1953. this._beilv_Rectangle.Width = v;
  1954. this._beilv_Ellipse.Margin = new Thickness((v - 42), 0, 0, 0);
  1955. }
  1956. /// <summary>
  1957. /// 打开倍率窗口
  1958. /// </summary>
  1959. public void OpenBeiLvWindow()
  1960. {
  1961. try
  1962. {
  1963. if (this._beilvwindow_Border.Height == 324)
  1964. {
  1965. return;
  1966. }
  1967. double width = 0;
  1968. double to = 324;
  1969. DoubleAnimation doubleAnimation = new DoubleAnimation();
  1970. doubleAnimation.From = width;
  1971. doubleAnimation.To = to;
  1972. doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.1));
  1973. this._beilvwindow_Border.BeginAnimation(FrameworkElement.HeightProperty, doubleAnimation);
  1974. int k = 1;
  1975. switch (beilv)
  1976. {
  1977. case 0.25:
  1978. k = 0;
  1979. break;
  1980. case 0.5:
  1981. k = 1;
  1982. break;
  1983. case 1.0:
  1984. k = 2;
  1985. break;
  1986. case 1.25:
  1987. k = 3;
  1988. break;
  1989. case 1.5:
  1990. k = 4;
  1991. break;
  1992. case 2.0:
  1993. k = 5;
  1994. break;
  1995. }
  1996. //var v = 362.5 * k;
  1997. var v = 290 * k;
  1998. this._beilv_Rectangle.Width = v;
  1999. this._beilv_Ellipse.Margin = new Thickness((v - 42), 0, 0, 0);
  2000. }
  2001. catch (Exception ex)
  2002. {
  2003. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}打开倍率窗口", LogEnum.RunException);
  2004. }
  2005. }
  2006. /// <summary>
  2007. /// 关闭倍率窗口
  2008. /// </summary>
  2009. public void CloseBeiLvWindow()
  2010. {
  2011. try
  2012. {
  2013. if (this._beilvwindow_Border.Height == 0)
  2014. {
  2015. return;
  2016. }
  2017. double width = 324;
  2018. double to = 0;
  2019. DoubleAnimation doubleAnimation = new DoubleAnimation();
  2020. doubleAnimation.From = width;
  2021. doubleAnimation.To = to;
  2022. doubleAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.1));
  2023. this._beilvwindow_Border.BeginAnimation(FrameworkElement.HeightProperty, doubleAnimation);
  2024. }
  2025. catch (Exception ex)
  2026. {
  2027. AppData.Instance.LogHelper.ExceptionLog(ex, $"{currentViewName}关闭倍率窗口", LogEnum.RunException);
  2028. }
  2029. }
  2030. private void Sure_Click(object sender, RoutedEventArgs e)
  2031. {
  2032. }
  2033. private void Cancel_Click(object sender, RoutedEventArgs e)
  2034. {
  2035. }
  2036. private void Grid_PreviewMouseUp(object sender, MouseButtonEventArgs e)
  2037. {
  2038. PlayerPause();
  2039. AddDishWindowView addDishWindowView = new AddDishWindowView(vm.ExDish, vm.DishPicAndVideoList);
  2040. AppData.Instance.MainWindow.Mark(true);
  2041. var a = addDishWindowView.ShowDialog();
  2042. AppData.Instance.MainWindow.Mark(false);
  2043. if (a == true)
  2044. {
  2045. //new MessagePrompt().ShowCenterOwnerSuccess(AppData.Instance.MainWindow, "保存成功");
  2046. new MessagePrompt().ShowCenterOwnerSuccess(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0242"));
  2047. AppData.Instance.MainPageView.UpdateInfo();
  2048. }
  2049. e.Handled = true;
  2050. }
  2051. private void Pic_Click(object sender, RoutedEventArgs e)
  2052. {
  2053. if (vm == null || vm.CurrentEmbryo == null) return;
  2054. PhotoPageViewModel photoPageViewModel = new PhotoPageViewModel(vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, vm.MaxTotalLayer);
  2055. PhotoPageView dishRecordView = new PhotoPageView(vm, vm.CurrentEmbryo.wellSn)
  2056. {
  2057. DataContext = photoPageViewModel,
  2058. };
  2059. AppData.Instance.MainWindow.LoadPage(dishRecordView);
  2060. }
  2061. private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
  2062. {
  2063. PlayerPause();
  2064. AddDishWindowView addDishWindowView = new AddDishWindowView(vm.ExDish, vm.DishPicAndVideoList);
  2065. AppData.Instance.MainWindow.Mark(true);
  2066. var a = addDishWindowView.ShowDialog();
  2067. AppData.Instance.MainWindow.Mark(false);
  2068. if (a == true)
  2069. {
  2070. //new MessagePrompt().ShowCenterOwnerSuccess(AppData.Instance.MainWindow, "保存成功");
  2071. new MessagePrompt().ShowCenterOwnerSuccess(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("C0242"));
  2072. AppData.Instance.MainPageView.UpdateInfo();
  2073. }
  2074. e.Handled = true;
  2075. }
  2076. private void SetVideoButtonState(bool IsEnabledVideo)
  2077. {
  2078. Task.Run(() =>
  2079. {
  2080. Dispatcher.Invoke(() =>
  2081. {
  2082. this.playButton.IsEnabled = IsEnabledVideo;
  2083. if (IsEnabledVideo)
  2084. {
  2085. this.playButton.Background = (LinearGradientBrush)this.FindResource("BuleLinear");
  2086. this.preZhenImage.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/preZhen.png", UriKind.RelativeOrAbsolute));
  2087. this._playButton.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/video_play.png", UriKind.RelativeOrAbsolute));
  2088. this.nextZhenImage.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/nextZhen.png", UriKind.RelativeOrAbsolute));
  2089. }
  2090. else
  2091. {
  2092. this.playButton.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8B8B8B"));
  2093. this.preZhenImage.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/preZhen1.png", UriKind.RelativeOrAbsolute));
  2094. this._playButton.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/video_play1.png", UriKind.RelativeOrAbsolute));
  2095. this.nextZhenImage.Source = new BitmapImage(new Uri("/ivf_tl_Operate;component/Resources/Image/nextZhen1.png", UriKind.RelativeOrAbsolute));
  2096. }
  2097. //this._lastButton.IsEnabled = IsEnabledVideo;
  2098. //this._playButton.IsEnabled = IsEnabledVideo;
  2099. //this._nextButton.IsEnabled = IsEnabledVideo;
  2100. });
  2101. });
  2102. }
  2103. private void _dishInfo_IsMaxChangedEvent(bool obj)
  2104. {
  2105. if (obj)
  2106. {
  2107. this.lastBu.Visibility = Visibility.Visible;
  2108. this.nextBu.Visibility = Visibility.Visible;
  2109. }
  2110. else
  2111. {
  2112. this.lastBu.Visibility = Visibility.Hidden;
  2113. this.nextBu.Visibility = Visibility.Hidden;
  2114. }
  2115. }
  2116. }
  2117. }