| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087 |
- using ivf_tl_CustomControls;
- using ivf_tl_Entity.Entity;
- using ivf_tl_Entity.Entity.balance;
- using ivf_tl_Entity.Entity.Result;
- using ivf_tl_Entity.Enums;
- using ivf_tl_Entity.Response;
- using ivf_tl_Manage.Converts;
- using ivf_tl_Manage.ViewModels;
- using ivf_tl_Manage.Win;
- using ivf_tl_Service;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Numerics;
- using System.Reflection;
- using System.Reflection.Metadata;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Timers;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- namespace ivf_tl_Manage.Views
- {
- /// <summary>
- /// DetailView.xaml 的交互逻辑
- /// </summary>
- public partial class DetailView : UserControl
- {
- string paiShe, peitai, shiping;
- private DetailViewModel vm;
- private Brush deaeatForeground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D75AC"));
- private Brush noEmbryoForeground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9B9B9B"));
- private Brush noPicForeground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D"));
- private double centerX, centerY;
- private double angle;
- private double angleOffset = 90;
- private int ellipseCount = 16;
- private int backImageRadius = 50;
- private int backImageBigRadius = 248;
- private int imageRadius = 40;
- private int imageBigRadius = 248;
- private int textBigRadius = 193;
- private int operRaius = 13;
- private int operBigRadius = 288;
- private int selectedIndex;
- private List<TextBlock> TextBlockList = new List<TextBlock>();
- private List<Image> ImageList = new List<Image>();
- private List<Image> PicImageList = new List<Image>();
- private List<Image> OperImageList = new List<Image>();
- public bool IsCleanVideo = false;
- public DetailView()
- {
- //DebugLog($"详情界面初始化开始:{DateTime.Now}");
- InitializeComponent();
- //paiShe = "拍摄中,请耐心等待";
- //shiping = "暂无视频,请耐心等待";
- //peitai = "暂无胚胎";
- paiShe = KeyToStringConvert.GetLanguageStringByKey("0509");
- shiping = KeyToStringConvert.GetLanguageStringByKey("0510");
- peitai = KeyToStringConvert.GetLanguageStringByKey("0511");
- object value = App.Current.TryFindResource("0511");
- centerX = 710 / 2.0;
- centerY = 710 / 2.0;
- angle = 360.00 / 16;
- Loaded += DetailView_Loaded;
- Unloaded += (s, e) =>
- {
- CloseCeLiang();
- PlayerDispose();
- Canvas_Root.Children.Clear();
- TextBlockList.Clear();
- ImageList.Clear();
- PicImageList.Clear();
- OperImageList.Clear();
- if (vm != null)
- {
- foreach (var item in vm.CurrentDish.embryoList)
- {
- item.AlarmChangedEvent -= EmbryoAlarmEvent;
- }
- }
- vm = null;
- DataContext = null;
- };
- //DebugLog($"详情界面初始化完成:{DateTime.Now}");
- }
- private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
- {
- string ss = "";
- }
- private void DetailView_Loaded(object sender, RoutedEventArgs e)
- {
- vm = (DetailViewModel)this.DataContext;
- if (vm == null) return;
- InitNav();
- InitCustomNew();
- foreach (var item in vm.CurrentDish.embryoList)
- {
- item.AlarmChangedEvent -= EmbryoAlarmEvent;
- item.AlarmChangedEvent += EmbryoAlarmEvent;
- }
- InitAlarm();
- Task.Run(() =>
- {
- vm.Init();
- if (vm == null) return;
- Dispatcher.InvokeAsync(() =>
- {
- //Stopwatch stopwatch = Stopwatch.StartNew();
- //DebugLog($"开始设置详情界面默认值:{DateTime.Now}");
- //var time1 = stopwatch.Elapsed;
- IsCleanVideo = false;
- if (vm == null) return;
- if (vm.DishPicAndVideoList.Any())
- {
- var a = vm.DishPicAndVideoList.First();
- if (a.videos != null && a.videos.Any())
- {
- var b = a.videos.FirstOrDefault(x => x.pictureLayer == 0);
- if (b != null && b.videoUrl == AppData.Instance.CleanVideoString)
- {
- IsCleanVideo = true;
- }
- }
- }
- InitQuickButton();
- SetEmbryoPic();
- PlayerEvent(this.mediaElementPlayer);
- //var time2 = stopwatch.Elapsed;
- //DebugLog($"详情界面默认值设置完成,开始设置视频:{DateTime.Now},耗时:{(time2 - time1).TotalMilliseconds}");
- ChangeEmbryo(1);
- //time1 = stopwatch.Elapsed;
- //DebugLog($"所有设置完成:{DateTime.Now},耗时:{(time1 - time2).TotalMilliseconds},总耗时:{stopwatch.Elapsed.TotalMilliseconds}");
- //stopwatch.Stop();
- });
- while (true)
- {
- Thread.Sleep(10000);
- if (vm == null || vm.CurrentDish == null || AppData.Instance.CurrentTlInfo == null) return;
- //foreach (var item in vm.CurrentDish.embryoList)
- //{
- // if (item.alarm == 0) item.alarm = 1;
- // else item.alarm = 0;
- //}
- InitAlarm();
- }
- });
- }
- private void InitAlarm()
- {
- if (vm == null || vm.CurrentDish == null || AppData.Instance.CurrentTlInfo == null) return;
- HouseCropAlarmResponse houseCropAlarmResponse = new HouseCropAlarmResponse();
- HouseCropAlarmResult CurrentHouseCropAlarmResult;
- houseCropAlarmResponse.tlSn = AppData.Instance.CurrentTlInfo.tlSn;
- if (!houseCropAlarmResponse.houseList.Any())
- {
- houseCropAlarmResponse.houseList.Add(new HouseCropAlarmHouseResponse
- {
- houseSn = vm.CurrentDish.houseSn,
- startTime = vm.CurrentDish.startTime,
- });
- }
- CurrentHouseCropAlarmResult = vm.detailProvider.GetHouseCropAlarmApi(houseCropAlarmResponse).FirstOrDefault(x => x.houseSn == vm.CurrentDish.houseSn);
- if (vm == null || vm.CurrentDish == null || AppData.Instance.CurrentTlInfo == null) return;
- foreach (var item in vm.CurrentDish.embryoList)
- {
- if (CurrentHouseCropAlarmResult == null)
- {
- item.alarm = 0;
- continue;
- }
- if (CurrentHouseCropAlarmResult.wellSn == null)
- {
- item.alarm = 0;
- continue;
- }
- if (CurrentHouseCropAlarmResult.wellSn.Contains(item.wellSn))
- {
- item.alarm = 1;
- }
- else
- {
- item.alarm = 0;
- }
- }
- }
- private void InitNav()
- {
- _nav_StackPanel.Children.Clear();
- for (int i = 0; i < vm.NavList.Count; i++)
- {
- var item = vm.NavList[i];
- if (i == vm.NavList.Count - 1)
- {
- TextBlock textBlock1 = new TextBlock();
- textBlock1.Margin = new Thickness(8, 0, 0, 0);
- textBlock1.FontWeight = FontWeights.Bold;
- textBlock1.Foreground = new SolidColorBrush(Colors.Black);
- textBlock1.FontSize = 32d;
- textBlock1.VerticalAlignment = VerticalAlignment.Center;
- textBlock1.Text = item.NavName;
- _nav_StackPanel.Children.Add(textBlock1);
- return;
- }
- Button button = new Button();
- //button.SetResourceReference(Button.ContentProperty, "0002");
- button.Content = item.NavName;
- button.FontWeight = FontWeights.Bold;
- button.FontSize = 28d;
- button.BorderThickness = new Thickness(0);
- button.Background = new SolidColorBrush(Colors.Transparent);
- button.Style = App.Current.FindResource("ButtonStyle1") as Style;
- if (i == 0)
- {
- button.Margin = new Thickness(0, 0, 0, 0);
- }
- else
- {
- button.Margin = new Thickness(8, 0, 0, 0);
- }
- button.Click += (s, e) =>
- {
- PlayerDispose();
- if (vm != null) vm.NavList.Clear();
- if (item is PatientManageViewModel patient)
- {
- patient.SetTLInfo(AppData.Instance.CurrentTlInfo);
- AppData.Instance.MainWindowViewModel.CurrentViewModle = patient;
- return;
- }
- AppData.Instance.MainWindowViewModel.CurrentViewModle = item;
- };
- TextBlock textBlock = new TextBlock();
- textBlock.Margin = new Thickness(8, 0, 0, 0);
- textBlock.VerticalAlignment = VerticalAlignment.Center;
- textBlock.FontWeight = FontWeights.Bold;
- textBlock.FontSize = 28d;
- textBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9B9B9B"));
- textBlock.Text = ">";
- _nav_StackPanel.Children.Add(button);
- _nav_StackPanel.Children.Add(textBlock);
- }
- }
- private void ExLog(Exception ex, string name)
- {
- AppData.Instance.LogService.ExceptionLog(ex, $"DetailView.{name}", LogEnum.RunException);
- }
- private void ErrorLog(string message, LogEnum logType)
- {
- AppData.Instance.LogService.TLLog($"DetailView.{message}", logType);
- }
- private void TimeLog(string message)
- {
- AppData.Instance.LogService.TLLog($"DetailView.{message}", LogEnum.TakeTime);
- }
- private void MessageShow(string message)
- {
- new ToastMessageWindow(AppData.Instance.MainWindow, 1920, 65, message).Show();
- }
- private void Toast(bool success)
- {
- new ToastWindow(AppData.Instance.MainWindow, 1920, 65, success).Show();
- }
- /// <summary>
- /// 设备管理界面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- AppData.Instance.MainWindowViewModel.CurrentViewModle = AppData.Instance.MainWindowViewModel.devManageViewModel;
- }
- /// <summary>
- /// 患者管理界面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Parien_Click(object sender, RoutedEventArgs e)
- {
- //AppData.Instance.MainWindowViewModel.patientManageViewModel.SetTLInfo(vm.tLInfo);
- //AppData.Instance.MainWindowViewModel.CurrentViewModle = AppData.Instance.MainWindowViewModel.patientManageViewModel;
- }
- /// <summary>
- /// 培养记录界面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Record_Click(object sender, RoutedEventArgs e)
- {
- AppData.Instance.MainWindowViewModel.CurrentViewModle = vm.ParentViewModel;
- }
- private void Mark_Click(object sender, RoutedEventArgs e)
- {
- vm.MarkEmbryo();
- }
- /// <summary>
- /// 图片查看界面
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void EmbryoPicClick(object sender, RoutedEventArgs e)
- {
- if (vm == null) return;
- if (vm.CurrentEmbryo != null)
- {
- AppData.Instance.MainWindowViewModel.CurrentViewModle = new DetailPicViewModel(vm, vm.MaxTotalLayer, vm.CurrentEmbryo.wellSn);
- }
- else
- {
- AppData.Instance.MainWindowViewModel.CurrentViewModle = new DetailPicViewModel(vm, vm.MaxTotalLayer, 1);
- }
- return;
- }
- /// <summary>
- /// 标记明细
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ButtonBottomImage_Click(object sender, RoutedEventArgs e)
- {
- AppData.Instance.MainWindowViewModel.CurrentViewModle = new MarkDetailViewModel(vm, vm.CurrentDish.id);
- }
- private void Export_Click(object sender, RoutedEventArgs e)
- {
- AppData.Instance.MainWindowViewModel.MaskVisibility = true;
- new ExportBulkWindow(vm.CurrentDish, vm.DishPicAndVideoList, IsCleanVideo).ShowDialog();
- AppData.Instance.MainWindowViewModel.MaskVisibility = false;
- }
- /// <summary>
- /// 移植按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- //private void EmbryoMove_Click(object sender, RoutedEventArgs e)
- //{
- // CloseCeLiang();
- // PlayerPause();
- // if (vm.CurrentEmbryo == null) return;
- // string tag = "移植";
- // string messInfo = $"是否确定对{vm.CurrentEmbryo.wellSn}号胚胎进行移植?";
- // int iconType = 2;
- // if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
- // {
- // tag = "完成";
- // switch (vm.CurrentEmbryo.state)
- // {
- // case (int)EmbryoState.Freezing:
- // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已冷冻";
- // iconType = 1;
- // break;
- // case (int)EmbryoState.Transplant:
- // messInfo = $"是否取消{vm.CurrentEmbryo.wellSn}号胚胎的移植标记?";
- // tag = "取消";
- // break;
- // case (int)EmbryoState.Cancellation:
- // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已作废";
- // iconType = 3;
- // break;
- // case (int)EmbryoState.Delete:
- // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已删除";
- // iconType = 4;
- // break;
- // }
- // }
- // EmbryoOp(tag, messInfo, iconType);
- // return;
- //}
- //string s1 = "Whether or not to";
- //string s2 = "embryo No.";
- //string s3 = "Whether or not to cancel the";
- //string s4 = "mark of embryo No.";
- //string s5 = "Embryo No.";
- //string s6 = "has been";
- string s1 = KeyToStringConvert.GetLanguageStringByKey("0521");
- string s2 = KeyToStringConvert.GetLanguageStringByKey("0522");
- string s3 = KeyToStringConvert.GetLanguageStringByKey("0523");
- string s4 = KeyToStringConvert.GetLanguageStringByKey("0524");
- string s5 = KeyToStringConvert.GetLanguageStringByKey("0525");
- string s6 = KeyToStringConvert.GetLanguageStringByKey("0526");
- string spaceString = KeyToStringConvert.GetLanguageStringByKey("0636");
- string haoString = KeyToStringConvert.GetLanguageStringByKey("0635");
- private void EmbryoMove_Click(object sender, RoutedEventArgs e)
- {
- CloseCeLiang();
- PlayerPause();
- if (vm.CurrentEmbryo == null) return;
- string tag = KeyToStringConvert.GetLanguageStringByKey("0041");
- string messInfo = GetMessageInfo(tag);
- int iconType = 2;
- if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
- {
- tag = "完成";
- switch (vm.CurrentEmbryo.state)
- {
- case (int)EmbryoState.Freezing:
- messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("0040"));
- iconType = 1;
- break;
- case (int)EmbryoState.Transplant:
- messInfo = GetCancelMarkMessage();
- tag = "取消";
- break;
- case (int)EmbryoState.Cancellation:
- messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("0042"));
- iconType = 3;
- break;
- case (int)EmbryoState.Delete:
- messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("0043"));
- iconType = 4;
- break;
- }
- }
- EmbryoOp(tag, messInfo, iconType);
- return;
- }
- /// <summary>
- /// 冷冻按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void EmbryoFree_Click(object sender, RoutedEventArgs e)
- {
- CloseCeLiang();
- PlayerPause();
- if (vm.CurrentEmbryo == null) return;
- int iconType = 1;
- string tag = KeyToStringConvert.GetLanguageStringByKey("0040");
- string messInfo = GetMessageInfo(tag);
- if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
- {
- tag = "完成";
- switch (vm.CurrentEmbryo.state)
- {
- case (int)EmbryoState.Freezing:
- messInfo = GetCancelMarkMessage();
- tag = "取消";
- break;
- case (int)EmbryoState.Transplant:
- messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("0041"));
- iconType = 2;
- break;
- case (int)EmbryoState.Cancellation:
- messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("0042"));
- iconType = 3;
- break;
- case (int)EmbryoState.Delete:
- messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("0043"));
- iconType = 4;
- break;
- }
- }
- EmbryoOp(tag, messInfo, iconType);
- return;
- }
- //private void EmbryoFree_Click(object sender, RoutedEventArgs e)
- //{
- // CloseCeLiang();
- // PlayerPause();
- // if (vm.CurrentEmbryo == null) return;
- // int iconType = 1;
- // string tag = "冷冻";
- // string messInfo = $"是否确定对{vm.CurrentEmbryo.wellSn}号胚胎进行冷冻?";
- // if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
- // {
- // tag = "完成";
- // switch (vm.CurrentEmbryo.state)
- // {
- // case (int)EmbryoState.Freezing:
- // messInfo = $"是否取消{vm.CurrentEmbryo.wellSn}号胚胎的冷冻标记?";
- // tag = "取消";
- // break;
- // case (int)EmbryoState.Transplant:
- // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已移植";
- // iconType = 2;
- // break;
- // case (int)EmbryoState.Cancellation:
- // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已作废";
- // iconType = 3;
- // break;
- // case (int)EmbryoState.Delete:
- // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已删除";
- // iconType = 4;
- // break;
- // }
- // }
- // EmbryoOp(tag, messInfo, iconType);
- // return;
- //}
- /// <summary>
- /// 作废按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void EmbryoInv_Click(object sender, RoutedEventArgs e)
- {
- CloseCeLiang();
- PlayerPause();
- if (vm.CurrentEmbryo == null) return;
- int iconType = 3;
- string tag = KeyToStringConvert.GetLanguageStringByKey("0042");
- string messInfo = GetMessageInfo(tag);
- if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
- {
- tag = "完成";
- switch (vm.CurrentEmbryo.state)
- {
- case (int)EmbryoState.Freezing:
- messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("0040"));
- iconType = 1;
- break;
- case (int)EmbryoState.Transplant:
- messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("0041"));
- iconType = 2;
- break;
- case (int)EmbryoState.Cancellation:
- messInfo = GetCancelMarkMessage();
- tag = "取消";
- break;
- case (int)EmbryoState.Delete:
- messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("0043"));
- iconType = 4;
- break;
- }
- }
- EmbryoOp(tag, messInfo, iconType);
- return;
- }
- //private void EmbryoInv_Click(object sender, RoutedEventArgs e)
- //{
- // CloseCeLiang();
- // PlayerPause();
- // if (vm.CurrentEmbryo == null) return;
- // int iconType = 3;
- // string tag = "作废";
- // string messInfo = $"是否确定对{vm.CurrentEmbryo.wellSn}号胚胎进行作废?";
- // if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
- // {
- // tag = "完成";
- // switch (vm.CurrentEmbryo.state)
- // {
- // case (int)EmbryoState.Freezing:
- // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已冷冻";
- // iconType = 1;
- // break;
- // case (int)EmbryoState.Transplant:
- // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已移植";
- // iconType = 2;
- // break;
- // case (int)EmbryoState.Cancellation:
- // messInfo = $"是否取消{vm.CurrentEmbryo.wellSn}号胚胎的作废标记?";
- // tag = "取消";
- // break;
- // case (int)EmbryoState.Delete:
- // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已删除";
- // iconType = 4;
- // break;
- // }
- // }
- // EmbryoOp(tag, messInfo, iconType);
- // return;
- //}
- /// <summary>
- /// 删除按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void EmbryoDel_Click(object sender, RoutedEventArgs e)
- {
- CloseCeLiang();
- PlayerPause();
- if (vm.CurrentEmbryo == null) return;
- int iconType = 4;
- string tag = KeyToStringConvert.GetLanguageStringByKey("0043");
- string messInfo = GetMessageInfo(tag);
- if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
- {
- tag = "完成";
- switch (vm.CurrentEmbryo.state)
- {
- case (int)EmbryoState.Freezing:
- messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("0040"));
- iconType = 1;
- break;
- case (int)EmbryoState.Transplant:
- messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("0041"));
- iconType = 2;
- break;
- case (int)EmbryoState.Cancellation:
- messInfo = GetMarkMessage(KeyToStringConvert.GetLanguageStringByKey("0042"));
- iconType = 3;
- break;
- case (int)EmbryoState.Delete:
- messInfo = GetCancelMarkMessage();
- tag = "取消";
- break;
- }
- }
- EmbryoOp(tag, messInfo, iconType);
- return;
- }
- //private void EmbryoDel_Click(object sender, RoutedEventArgs e)
- //{
- // CloseCeLiang();
- // PlayerPause();
- // if (vm.CurrentEmbryo == null) return;
- // int iconType = 4;
- // string tag = "删除";
- // string messInfo = $"是否确定对{vm.CurrentEmbryo.wellSn}号胚胎进行删除?";
- // if (vm.CurrentEmbryo.state != (int)EmbryoState.None && vm.CurrentEmbryo.state != (int)EmbryoState.End)
- // {
- // tag = "完成";
- // switch (vm.CurrentEmbryo.state)
- // {
- // case (int)EmbryoState.Freezing:
- // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已冷冻";
- // iconType = 1;
- // break;
- // case (int)EmbryoState.Transplant:
- // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已移植";
- // iconType = 2;
- // break;
- // case (int)EmbryoState.Cancellation:
- // messInfo = $"{vm.CurrentEmbryo.wellSn}号胚胎已作废";
- // iconType = 3;
- // break;
- // case (int)EmbryoState.Delete:
- // messInfo = $"是否取消{vm.CurrentEmbryo.wellSn}号胚胎的删除标记?";
- // tag = "取消";
- // break;
- // }
- // }
- // EmbryoOp(tag, messInfo, iconType);
- // return;
- //}
- /// <summary>
- /// 结束按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void EmbryoOver_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- CloseCeLiang();
- PlayerPause();
- if (vm.CurrentDish == null || vm.CurrentDish.id == 0) return;
- string tag = KeyToStringConvert.GetLanguageStringByKey("0518");
- string messInfo = $"{KeyToStringConvert.GetLanguageStringByKey("0519")}?";
- if (vm.CurrentDish.state == 0)
- {
- messInfo = KeyToStringConvert.GetLanguageStringByKey("0520");
- tag = "完成";
- }
- EmbryoOp(tag, messInfo, 5);
- return;
- }
- catch (Exception ex)
- {
- ExLog(ex, "EmbryoOver_Click");
- }
- //try
- //{
- // CloseCeLiang();
- // PlayerPause();
- // if (vm.CurrentDish == null || vm.CurrentDish.id == 0) return;
- // string tag = "结束";
- // string messInfo = $"是否结束培养所有胚胎?";
- // if (vm.CurrentDish.state == 0)
- // {
- // messInfo = "当前舱室已结束培养";
- // tag = "完成";
- // }
- // EmbryoOp(tag, messInfo, 5);
- // return;
- //}
- //catch (Exception ex)
- //{
- // ExLog(ex, "EmbryoOver_Click");
- //}
- }
- private string GetMessageInfo(string stateString)
- {
- return $"{s1}{spaceString}{stateString}{spaceString}{s2}{vm.CurrentEmbryo.wellSn}{haoString}?";
- }
- private string GetMarkMessage(string stateString)
- {
- return $"{s5}{vm.CurrentEmbryo.wellSn}{spaceString}{s6}{spaceString}{stateString}";
- }
- private string GetCancelMarkMessage()
- {
- return $"{s3}{spaceString}{vm.CurrentEmbryo.wellSn}{haoString}?";
- }
- /// <summary>
- /// 胚胎操作
- /// </summary>
- private void EmbryoOp(string tag, string infoString, int type)
- {
- if (tag == "完成")
- {
- AppData.Instance.MainWindowViewModel.MaskVisibility = true;
- new MessagePrompt().ShowEmbryoOper(tag, infoString, type);
- AppData.Instance.MainWindowViewModel.MaskVisibility = false;
- return;
- }
- AppData.Instance.MainWindowViewModel.MaskVisibility = true;
- var rs = new MessagePrompt().ShowEmbryoOper(tag, infoString, type);
- AppData.Instance.MainWindowViewModel.MaskVisibility = false;
- if (rs != true) return;
- if (tag == "取消")
- {
- EmbryoMark((int)EmbryoState.None);
- return;
- }
- switch (type)
- {
- case 1:
- EmbryoMark((int)EmbryoState.Freezing);
- break;
- case 3:
- EmbryoMark((int)EmbryoState.Cancellation);
- break;
- case 2:
- EmbryoMark((int)EmbryoState.Transplant);
- break;
- case 4:
- EmbryoMark((int)EmbryoState.Delete);
- break;
- case 5:
- Finish();
- break;
- default:
- break;
- }
- }
- //private void EmbryoOp(string tag, string infoString, int type)
- //{
- // if (tag == "完成")
- // {
- // AppData.Instance.MainWindowViewModel.MaskVisibility = true;
- // new MessagePrompt().ShowEmbryoOper(tag, infoString, type);
- // AppData.Instance.MainWindowViewModel.MaskVisibility = false;
- // return;
- // }
- // AppData.Instance.MainWindowViewModel.MaskVisibility = true;
- // var rs = new MessagePrompt().ShowEmbryoOper(tag, infoString, type);
- // AppData.Instance.MainWindowViewModel.MaskVisibility = false;
- // if (rs == true)
- // {
- // switch (tag)
- // {
- // case "冷冻":
- // EmbryoMark((int)EmbryoState.Freezing);
- // break;
- // case "作废":
- // EmbryoMark((int)EmbryoState.Cancellation);
- // break;
- // case "移植":
- // EmbryoMark((int)EmbryoState.Transplant);
- // break;
- // case "删除":
- // EmbryoMark((int)EmbryoState.Delete);
- // break;
- // case "结束":
- // Finish();
- // break;
- // case "取消":
- // EmbryoMark((int)EmbryoState.None);
- // break;
- // default:
- // break;
- // }
- // }
- //}
- /// <summary>
- /// 结束培养
- /// </summary>
- /// <exception cref="NotImplementedException"></exception>
- private void Finish()
- {
- try
- {
- if (!vm.EndDish())
- {
- //MessageShow("结束培养失败");
- MessageShow(KeyToStringConvert.GetLanguageStringByKey("0318"));
- return;
- }
- vm.Back();
- //vm.CurrentDish = new Dish();
- //AppData.Instance.BackMainPage();
- }
- catch (Exception ex)
- {
- ExLog(ex, "Finish");
- }
- }
- private void EmbryoMark(int embryoState)
- {
- try
- {
- if (!vm.MarkEmbryo(embryoState))
- {
- //MessageShow("胚胎标记失败");
- MessageShow(KeyToStringConvert.GetLanguageStringByKey("0319"));
- return;
- }
- DateTime ct = DateTime.Now;
- vm.CurrentEmbryo.state = embryoState;
- vm.CurrentEmbryo.stateTime = ct.ToString("yyyy-MM-dd HH:mm:ss");
- SetEmbryoState(vm.CurrentEmbryo.wellSn, vm.CurrentEmbryo.state);
- Toast(true);
- //AppData.Instance.MainPageView.SetMainEmbryoState(vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.wellSn, vm.CurrentEmbryo.state);
- }
- catch (Exception ex)
- {
- ExLog(ex, "EmbryoMark");
- }
- }
- /// <summary>
- /// 播放暂停
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Video_Click(object sender, RoutedEventArgs e)
- {
- CloseCeLiang();
- if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
- {
- if (PlayerState == PlayerStateEnum.Playing)
- {
- PlayerPause();
- }
- else
- {
- newCurrentTime = -1;
- if (PlayerPlay())
- {
- //this._preview.Visibility = Visibility.Hidden;
- this.Canvas_preview.Visibility = Visibility.Hidden;
- vm.CurrentFocal = 0;
- }
- else
- {
- SetPreviewNoVideo();
- }
- }
- }
- else
- {
- SetPreviewNoVideo();
- }
- }
- /// <summary>
- /// 上一帧
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void PreviousFrame_Click(object sender, RoutedEventArgs e)
- {
- CloseCeLiang();
- if (vm == null || vm.CurrentWellLayerPicAndVideo == null) return;
- if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
- {
- PlayerPause();
- PlayerLastFrame(vm.CurrentWellLayerPicAndVideo.fps);
- //this._preview.Visibility = Visibility.Hidden;
- this.Canvas_preview.Visibility = Visibility.Hidden;
- }
- }
- /// <summary>
- /// 下一帧
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void NextFrame_Click(object sender, RoutedEventArgs e)
- {
- CloseCeLiang();
- if (vm == null || vm.CurrentWellLayerPicAndVideo == null) return;
- if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
- {
- PlayerPause();
- PlayerNextFrame(vm.CurrentWellLayerPicAndVideo.fps);
- //this._preview.Visibility = Visibility.Hidden;
- this.Canvas_preview.Visibility = Visibility.Hidden;
- }
- }
- /// <summary>
- /// 上一层
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BigFocus_Click(object sender, RoutedEventArgs e)
- {
- PlayerPause();
- CloseCeLiang();
- if (vm == null || vm.CurrentPic == null || vm.CurrentWellDishPicAndVideo == null) return;
- if (vm.CurrentEmbryo == null) return;
- if (vm.CurrentWellLayerPicAndVideo != null) ChangeFocalNoVideo(true);
- //if (vm.CurrentWellLayerPicAndVideo != null) if (!string.IsNullOrEmpty(vm.CurrentWellLayerPicAndVideo.videoUrl)) ChangeFocalNoVideo(true);
- // else ChangeImageFocal(true);
- }
- /// <summary>
- /// 下一层
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void SmallFocus_Click(object sender, RoutedEventArgs e)
- {
- PlayerPause();
- CloseCeLiang();
- if (vm == null || vm.CurrentPic == null || vm.CurrentWellDishPicAndVideo == null) return;
- if (vm.CurrentEmbryo == null) return;
- if (vm.CurrentWellLayerPicAndVideo != null) ChangeFocalNoVideo(false);
- //if (vm.CurrentWellLayerPicAndVideo != null) if (!string.IsNullOrEmpty(vm.CurrentWellLayerPicAndVideo.videoUrl)) ChangeFocalNoVideo(false);
- // else ChangeImageFocal(false);
- }
- /// <summary>
- /// 设置倍率
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- if (vm == null) return;
- PlayerSetSpeedRatio(vm.SelectedFps.Key);
- if (this._fps_Popup.IsOpen)
- this._fps_Popup.IsOpen = false;
- }
- /// <summary>
- /// 快捷定位
- /// </summary>
- /// <param name="minHour"></param>
- /// <param name="maxHour"></param>
- /// <param name="quickName"></param>
- private void QuickButton_Click(int minHour, int maxHour, string quickName)
- {
- try
- {
- CloseCeLiang();
- PlayerPause();
- if (vm.CurrentWellLayerPicAndVideo == null || vm.CurrentWellLayerPicAndVideo.videoPictures == null || !vm.CurrentWellLayerPicAndVideo.videoPictures.Any())
- {
- //MessageShow($"当前胚胎还未发育到{quickName}阶段");
- MessageShow($"{KeyToStringConvert.GetLanguageStringByKey("0316")} {quickName}");
- return;
- }
- var lastPic = vm.CurrentWellLayerPicAndVideo.videoPictures.Last();
- if (minHour > lastPic.developTime)
- {
- //MessageShow($"当前胚胎还未发育到{quickName}阶段");
- MessageShow($"{KeyToStringConvert.GetLanguageStringByKey("0316")} {quickName}");
- return;
- }
- int picCount = vm.CurrentWellLayerPicAndVideo.videoPictures.Count;
- for (int i = 0; i < picCount; i++)
- {
- var item = vm.CurrentWellLayerPicAndVideo.videoPictures[i];
- if (item.developTime >= minHour)
- {
- if (IsCleanVideo)
- {
- this._preview.Visibility = Visibility.Visible;
- vm.VideoCurrentTime = i + 1;
- this._preview.Source = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{item.imageUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}");
- }
- else
- {
- if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
- {
- this._preview.Visibility = Visibility.Hidden;
- double pro = (i * (1000.00 / vm.CurrentWellLayerPicAndVideo.fps));
- SetTimeProgressbarProgressValue(pro);
- SetPlayerPosition(pro);
- }
- else
- {
- this._preview.Visibility = Visibility.Visible;
- vm.VideoCurrentTime = i + 1;
- this._preview.Source = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{item.imageUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}");
- }
- }
- break;
- }
- }
- }
- catch (Exception ex)
- {
- ExLog(ex, $"QuickButton_Click");
- }
- }
- /// <summary>
- /// 播放速率调整
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Fps_MouseUp(object sender, MouseButtonEventArgs e)
- {
- CloseCeLiang();
- if (this._fps_Popup.IsOpen) this._fps_Popup.IsOpen = false;
- else this._fps_Popup.IsOpen = true;
- }
- private void CeLiang_Click(object sender, RoutedEventArgs e)
- {
- PlayerPause();
- if (vm.CurrentEmbryo == null)
- {
- //MessageBox.Show("embryo为空");
- return;
- }
- int developTime = 0;
- if (vm.CurrentPic == null)
- {
- if (vm.CurrentWellDishPicAndVideo != null && vm.CurrentWellDishPicAndVideo.focus)
- {
- developTime = vm.CurrentWellDishPicAndVideo.developTime;
- }
- else
- {
- //MessageBox.Show("CurrentPic为空");
- return;
- }
- }
- else
- {
- developTime = vm.CurrentPic.developTime;
- }
- if (isCeLiang)
- {
- count = 0;
- this._ceLiang_Border.Visibility = Visibility.Hidden;
- this.b1.Text = "";
- this.canvas1.Children.Remove(myLine);
- this.canvas1.Children.Remove(starEllipse);
- this.canvas1.Children.Remove(endEllipse);
- isCeLiang = false;
- MeaUIShow(false);
- }
- else
- {
- isCeLiang = true;
- MeaUIShow(true);
- }
- DetailPicInfo detailPicInfo = null;
- if (vm.CurrentPic == null)
- {
- detailPicInfo = vm.detailProvider.GetDetailPicInfoApi(vm.CurrentEmbryo.tlSn, vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, 9999, developTime);
- }
- else
- {
- detailPicInfo = vm.detailProvider.GetDetailPicInfoApi(vm.CurrentEmbryo.tlSn, vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, vm.CurrentFocal, developTime);
- }
- if (detailPicInfo != null) PicRadius = detailPicInfo.radius;
- Log4netHelper.WriteLog($"{vm.CurrentEmbryo.id}:{PicRadius}");
- e.Handled = true;
- }
- private void Button_Click_1(object sender, RoutedEventArgs e)
- {
- if (vm == null || vm.CurrentWellLayerPicAndVideo == null || string.IsNullOrEmpty(vm.CurrentWellLayerPicAndVideo.videoUrl) || vm.CurrentWellLayerPicAndVideo.videoUrl == AppData.Instance.CleanVideoString) return;
- string url = $"{AppData.Instance.BaseUrl}{vm.CurrentWellLayerPicAndVideo.videoUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}";
- TimeLog($"开始下载:{url}");
- Stopwatch stopwatch = Stopwatch.StartNew();
- AppData.Instance.HttpServiceCall.DownLoadFileAsync(url, $"C:\\TLData\\ivf_tl_Manage_logs\\{DateTime.Now.ToString("HH_mm")}.mp4").GetAwaiter().GetResult();
- TimeLog($"下载耗时:{stopwatch.ElapsedMilliseconds}毫秒、{stopwatch.Elapsed.TotalSeconds}秒");
- }
- int PicRadius = 0;
- bool isMax = false;
- double maxWidth = 610;
- double maxLeft = 50;
- double minWidth = 330;
- double minLeft = 190;
- int count = 0;
- bool isCeLiang = false;
- Line myLine = null;
- Ellipse starEllipse = null;
- Ellipse endEllipse = null;
- private void PreviewMouseDownEvent(object sender, MouseButtonEventArgs e)
- {
- if (!this.IsLoaded) return;
- if (!isCeLiang)
- {
- if (e.ChangedButton == MouseButton.Left && e.ClickCount == 2)
- {
- if (isMax == false)
- {
- this.nextEmbryoButton.Visibility = Visibility.Visible;
- this.lastEmbryoButton.Visibility = Visibility.Visible;
- //_preview.Width = maxWidth;
- //_preview.Height = maxWidth;
- _mask.Width = maxWidth;
- _mask.Height = maxWidth;
- mediaElementPlayer.Width = maxWidth;
- mediaElementPlayer.Height = maxWidth;
- canvas1.Width = maxWidth;
- canvas1.Height = maxWidth;
- isMax = true;
- //Canvas.SetLeft(_preview, maxLeft);
- //Canvas.SetTop(_preview, maxLeft);
- Canvas.SetLeft(mediaElementPlayer, maxLeft);
- Canvas.SetTop(mediaElementPlayer, maxLeft);
- Canvas.SetLeft(_mask, maxLeft);
- Canvas.SetTop(_mask, maxLeft);
- Canvas.SetLeft(canvas1, maxLeft);
- Canvas.SetTop(canvas1, maxLeft);
- Panel.SetZIndex(mediaElementPlayer, 16);
- //Panel.SetZIndex(_preview, 17);
- Panel.SetZIndex(canvas1, 18);
- }
- else
- {
- this.nextEmbryoButton.Visibility = Visibility.Hidden;
- this.lastEmbryoButton.Visibility = Visibility.Hidden;
- //_preview.Width = minWidth;
- //_preview.Height = minWidth;
- _mask.Width = minWidth;
- _mask.Height = minWidth;
- mediaElementPlayer.Width = minWidth;
- mediaElementPlayer.Height = minWidth;
- canvas1.Width = minWidth;
- canvas1.Height = minWidth;
- isMax = false;
- //Canvas.SetLeft(_preview, minLeft);
- //Canvas.SetTop(_preview, minLeft);
- Canvas.SetLeft(mediaElementPlayer, minLeft);
- Canvas.SetTop(mediaElementPlayer, minLeft);
- Canvas.SetLeft(_mask, minLeft);
- Canvas.SetTop(_mask, minLeft);
- Canvas.SetLeft(canvas1, minLeft);
- Canvas.SetTop(canvas1, minLeft);
- Panel.SetZIndex(mediaElementPlayer, 8);
- //Panel.SetZIndex(_preview, 9);
- Panel.SetZIndex(canvas1, 10);
- }
- SetLoad(isMax);
- SetPreView(isMax);
- }
- e.Handled = true;
- return;
- }
- else
- {
- switch (count)
- {
- case 0:
- myLine = new Line();
- myLine.X1 = e.GetPosition(this.canvas1).X;
- myLine.Y1 = e.GetPosition(this.canvas1).Y;
- starEllipse = CreateEllipse(myLine.X1, myLine.Y1);
- this.canvas1.Children.Add(starEllipse);
- count++;
- break;
- case 1:
- myLine.X2 = e.GetPosition(canvas1).X;
- myLine.Y2 = e.GetPosition(canvas1).Y;
- endEllipse = CreateEllipse(myLine.X2, myLine.Y2);
- this.canvas1.Children.Add(endEllipse);
- myLine.HorizontalAlignment = HorizontalAlignment.Left;
- myLine.VerticalAlignment = VerticalAlignment.Center;
- myLine.StrokeDashArray = new DoubleCollection(new List<double> { 8d, 4d });
- myLine.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFB000"));
- this.canvas1.Children.Add(myLine);
- double offsetX = myLine.X2 - myLine.X1;
- double offsetY = myLine.Y2 - myLine.Y1;
- _ceLiang_Border.SetValue(Canvas.LeftProperty, myLine.X1 + offsetX / 2 - 46.5);
- _ceLiang_Border.SetValue(Canvas.TopProperty, myLine.Y1 + offsetY / 2 - 50);
- RotateTransform rotateTransform = new RotateTransform();
- rotateTransform.Angle = GetAngle(myLine.X1, myLine.Y1, myLine.X2, myLine.Y2);
- _ceLiang_Border.RenderTransformOrigin = new System.Windows.Point(0.5, 0.5);
- _ceLiang_Border.RenderTransform = rotateTransform;
- double fangDaBeiShu = 8.5778;//放大倍数
- double xiangYuan = 2.2;
- double picWidth = isMax ? 610d : 330d;
- //if (vm != null && vm.CurrentPicZhen != null) picWidth = (double)(vm.CurrentPicZhen.radius * 2);
- if (PicRadius != 0) picWidth = (double)(PicRadius * 2.0);
- int meaValue = (int)(((Math.Sqrt(Math.Pow(offsetX, 2.0) + Math.Pow(offsetY, 2.0)) * xiangYuan) / fangDaBeiShu) / ((isMax ? 610.00 : 330.00) / picWidth)) + AppData.Instance.Measurement;
- b1.Text = $"{meaValue}µm";
- foreach (var item in vm.MeasurementList)
- {
- if (item.MeasurementValue == -1)
- {
- item.MeasurementValue = meaValue;
- break;
- }
- }
- //var 线条长度 = Math.Sqrt(Math.Pow(offsetX, 2.0) + Math.Pow(offsetY, 2.0));
- //var 线条长度经过像元 = (线条长度 * xiangYuan);
- //var 控件放大倍数 = ((isMax ? 610d : 330d) / picWidth);
- //var aaaa = 线条长度经过像元 / fangDaBeiShu/ 控件放大倍数;
- this._ceLiang_Border.Visibility = Visibility.Visible;
- count++;
- break;
- case 2:
- count = 0;
- this._ceLiang_Border.Visibility = Visibility.Hidden;
- this.canvas1.Children.Remove(myLine);
- this.canvas1.Children.Remove(starEllipse);
- this.canvas1.Children.Remove(endEllipse);
- myLine = new Line();
- myLine.X1 = e.GetPosition(canvas1).X;
- myLine.Y1 = e.GetPosition(canvas1).Y;
- starEllipse = CreateEllipse(myLine.X1, myLine.Y1);
- this.canvas1.Children.Add(starEllipse);
- count++;
- break;
- default:
- break;
- }
- e.Handled = true;
- return;
- }
- e.Handled = true;
- }
- private void SetLoad(bool isMax)
- {
- if (isMax)
- {
- Image_Load.Width = maxWidth;
- Image_Load.Height = maxWidth;
- Canvas_Load.Width = maxWidth;
- Canvas_Load.Height = maxWidth;
- TextBlock_Load.Width = maxWidth;
- TextBlock_Load.FontSize = 38;
- Canvas.SetTop(TextBlock_Load, 361);
- Canvas.SetLeft(Canvas_Load, maxLeft);
- Canvas.SetTop(Canvas_Load, maxLeft);
- Panel.SetZIndex(Canvas_Load, 15);
- }
- else
- {
- Image_Load.Width = minWidth;
- Image_Load.Height = minWidth;
- Canvas_Load.Width = minWidth;
- Canvas_Load.Height = minWidth;
- TextBlock_Load.Width = minWidth;
- TextBlock_Load.FontSize = 20;
- Canvas.SetTop(TextBlock_Load, 198);
- Canvas.SetLeft(Canvas_Load, minLeft);
- Canvas.SetTop(Canvas_Load, minLeft);
- Panel.SetZIndex(Canvas_Load, 7);
- }
- }
- private void SetPreView(bool isMax)
- {
- if (isMax)
- {
- _preview.Width = maxWidth;
- _preview.Height = maxWidth;
- Canvas_preview.Width = maxWidth;
- Canvas_preview.Height = maxWidth;
- TextBlock_preview.Width = maxWidth;
- TextBlock_preview.FontSize = 38;
- Canvas.SetTop(TextBlock_preview, 361);
- Canvas.SetLeft(Canvas_preview, maxLeft);
- Canvas.SetTop(Canvas_preview, maxLeft);
- Panel.SetZIndex(Canvas_preview, 17);
- }
- else
- {
- _preview.Width = minWidth;
- _preview.Height = minWidth;
- Canvas_preview.Width = minWidth;
- Canvas_preview.Height = minWidth;
- TextBlock_preview.Width = minWidth;
- TextBlock_preview.FontSize = 20;
- Canvas.SetTop(TextBlock_preview, 198);
- Canvas.SetLeft(Canvas_preview, minLeft);
- Canvas.SetTop(Canvas_preview, minLeft);
- Panel.SetZIndex(Canvas_preview, 9);
- }
- }
- private void Canvas_PreviewMouseDown(object sender, MouseButtonEventArgs e)
- {
- if (e.Source is ButtonBottomImage bottomImage && bottomImage.Name == "_celiang_ButtonBottomImage")
- {
- e.Handled = true;
- return;
- }
- if (e.Source is Canvas canvas && canvas.Name == "canvas1")
- {
- e.Handled = true;
- return;
- }
- CloseCeLiang();
- }
- private Ellipse CreateEllipse(double x, double y)
- {
- Ellipse ellipse = new Ellipse();
- ellipse.Width = 10;
- ellipse.Height = 10;
- ellipse.Fill = new SolidColorBrush(Colors.Red);
- ellipse.SetValue(Canvas.LeftProperty, x - (10 / 2));
- ellipse.SetValue(Canvas.TopProperty, y - (10 / 2));
- ellipse.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFB000"));
- return ellipse;
- }
- private double GetAngle(double x1, double y1, double x2, double y2)
- {
- double angle = Math.Atan2(y2 - y1, x2 - x1);
- double degrees = angle * 180 / Math.PI;
- double normalizedAngle = degrees % 180;
- if (normalizedAngle > 90)
- {
- normalizedAngle -= 180;
- }
- else if (normalizedAngle < -90)
- {
- normalizedAngle += 180;
- }
- return normalizedAngle;
- }
- private void CloseCeLiang()
- {
- if (isCeLiang)
- {
- PicRadius = 0;
- count = 0;
- this._ceLiang_Border.Visibility = Visibility.Hidden;
- this.b1.Text = "";
- this.canvas1.Children.Remove(myLine);
- this.canvas1.Children.Remove(starEllipse);
- this.canvas1.Children.Remove(endEllipse);
- isCeLiang = false;
- MeaUIShow(false);
- }
- }
- private void LastEmbryo_Click(object sender, RoutedEventArgs e)
- {
- int index = selectedIndex;
- if (index == 0)
- {
- index = 15;
- }
- else
- {
- index--;
- }
- SelectIndex(index);
- CloseCeLiang();
- PlayerPause();
- ChangeEmbryo(index + 1);
- }
- private void NextEmbryo_Click(object sender, RoutedEventArgs e)
- {
- int index = selectedIndex;
- if (index == 15)
- {
- index = 0;
- }
- else
- {
- index++;
- }
- SelectIndex(index);
- CloseCeLiang();
- PlayerPause();
- ChangeEmbryo(index + 1);
- }
- private void ListBox_ManipulationBoundaryFeedback(object sender, ManipulationBoundaryFeedbackEventArgs e)
- {
- e.Handled = true;
- }
- private void Auto_Click(object sender, RoutedEventArgs e)
- {
- if (vm == null) return;
- var list = vm.CurrentDish.embryoList.Where(x => x.state == (int)EmbryoState.None).ToList();
- //var list = vm.CurrentDish.embryoList.ToList();
- if (!list.Any())
- {
- //new ToastMessageWindow(AppData.Instance.MainWindow, $"暂无胚胎需要对焦预览").Show();
- new ToastMessageWindow(AppData.Instance.MainWindow, KeyToStringConvert.GetLanguageStringByKey("0320")).Show();
- return;
- }
- AppData.Instance.MainWindowViewModel.MaskVisibility = true;
- new AutoFocusWindow(vm.CurrentDish.tlSn, vm.CurrentDish.houseSn, list, vm.CurrentEmbryo).ShowDialog();
- AppData.Instance.MainWindowViewModel.MaskVisibility = false;
- return;
- }
- private void AverageValue_Click(object sender, RoutedEventArgs e)
- {
- int allValue = 0;
- int count = 0;
- foreach (var item in vm.MeasurementList)
- {
- if (item.MeasurementValue != -1)
- {
- allValue += item.MeasurementValue;
- count++;
- }
- }
- if (count == 0)
- {
- MessageShow("至少满足一次测量");
- return;
- }
- this.averageValueText.Text = $"{((double)allValue / count).ToString("f2")}";
- }
- private void ClearMea_Click(object sender, RoutedEventArgs e)
- {
- if (this.meaListBox.SelectedItem == null) return;
- if (this.meaListBox.SelectedItem is MeasurementEntity mea)
- {
- mea.MeasurementValue = -1;
- }
- }
- private void MeaUIShow(bool b)
- {
- if (b)
- {
- this.meaUI1.Visibility = Visibility.Visible;
- //this.meaUI2.Visibility = Visibility.Visible;
- //this.meaUI3.Visibility = Visibility.Visible;
- }
- else
- {
- this.meaUI1.Visibility = Visibility.Hidden;
- //this.meaUI2.Visibility = Visibility.Hidden;
- //this.meaUI3.Visibility = Visibility.Hidden;
- }
- }
- private void ClearMeasurementList()
- {
- this.averageValueText.Text = "";
- if (vm == null || vm.MeasurementList == null) return;
- foreach (var item in vm.MeasurementList)
- {
- item.MeasurementValue = -1;
- }
- }
- #region 初始化
- private void InitQuickButton()
- {
- this._quick_StackPanel.Children.Clear();
- if (vm == null || vm.QuickButtons == null || !vm.QuickButtons.Any())
- {
- //this._quick_TextBlock.Visibility = Visibility.Hidden;
- return;
- }
- bool isFirst = true;
- var newList = vm.QuickButtons.OrderBy(x => x.orderNum).Take(7);
- foreach (var item in newList)
- {
- ButtonLeftImage buttonLeftImage = new ButtonLeftImage()
- {
- IconWidth = 40,
- IconHeight = 40,
- IconMargin = new Thickness(0, 0, 5, 0),
- Content = item.buttonName,
- FontWeight = FontWeights.Medium,
- FontSize = 24,
- Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9B9B9B")),
- MouseOverForeground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D")),
- IconSource = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailQuickIcon.png", UriKind.Absolute)),
- MouseOverIconSource = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailQuickMouseOverIcon.png", UriKind.Absolute)),
- };
- if (!isFirst) buttonLeftImage.Margin = new Thickness(20, 0, 0, 0);
- if (isFirst) isFirst = false;
- buttonLeftImage.Click += (sender, args) =>
- {
- QuickButton_Click(item.minHour * 60, item.maxHour * 60, item.buttonName);
- };
- this._quick_StackPanel.Children.Add(buttonLeftImage);
- }
- }
- private void InitCustom()
- {
- try
- {
- EllipseGeometry ellipseGeometry = new EllipseGeometry(new Point(imageRadius, imageRadius), imageRadius, imageRadius);
- Embryo itemEmbryo = null;
- for (int i = 0; i < ellipseCount; i++)
- {
- TextBlock textBlock = new TextBlock();
- Image border = new Image();
- Image image = new Image();
- Image opImage = new Image();
- this._canvas.Children.Add(textBlock);
- this._canvas.Children.Add(border);
- this._canvas.Children.Add(image);
- this._canvas.Children.Add(opImage);
- Panel.SetZIndex(textBlock, 11);
- Panel.SetZIndex(border, 12);
- Panel.SetZIndex(image, 13);
- Panel.SetZIndex(opImage, 14);
- textBlock.FontWeight = FontWeights.Medium;
- textBlock.Foreground = deaeatForeground;
- textBlock.FontSize = 14;
- textBlock.Width = 16;
- textBlock.Height = 22;
- textBlock.Text = $"{i + 1}";
- textBlock.TextAlignment = TextAlignment.Center;
- textBlock.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - 7);
- textBlock.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - 11);
- TextBlockList.Add(textBlock);
- ImageList.Add(border);
- PicImageList.Add(image);
- border.Width = backImageRadius * 2;
- border.Height = backImageRadius * 2;
- border.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * backImageBigRadius - backImageRadius);
- border.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * backImageBigRadius - backImageRadius);
- opImage.Width = operRaius * 2;
- opImage.Height = operRaius * 2;
- opImage.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * operBigRadius - operRaius);
- opImage.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * operBigRadius - operRaius);
- opImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState1Icon.png", UriKind.Absolute));
- OperImageList.Add(opImage);
- image.Width = imageRadius * 2;
- image.Height = imageRadius * 2;
- image.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
- image.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
- image.SetValue(Image.ClipProperty, ellipseGeometry);
- image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoEmbryo.png", UriKind.Absolute));
- image.Tag = i;
- image.MouseUp += (s, e) =>
- {
- if (!this.IsLoaded) return;
- if (!(s is Image source)) return;
- int index = (int)source.Tag;
- if (selectedIndex == index) return;
- SelectIndex(index);
- CloseCeLiang();
- PlayerPause();
- ChangeEmbryo(index + 1);
- };
- var aa = vm.CurrentDish;
- itemEmbryo = vm.CurrentDish.embryoList.FirstOrDefault(x => x.wellSn == i + 1);
- if (itemEmbryo == null)//无胚胎
- {
- opImage.Visibility = Visibility.Hidden;
- textBlock.Tag = 0;
- textBlock.Foreground = noEmbryoForeground;
- border.Tag = 0;
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoEmbryoBackground.png", UriKind.Absolute));
- continue;
- }
- image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoEmbryo1.png", UriKind.Absolute));
- switch ((EmbryoState)itemEmbryo.state)
- {
- case EmbryoState.Freezing: //冷冻
- opImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState1Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Transplant://移植
- opImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState2Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Cancellation://作废
- opImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState3Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Delete://删除
- opImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState4Icon.png", UriKind.Absolute));
- break;
- default:
- opImage.Visibility = Visibility.Hidden;
- break;
- }
- var currentData = vm.DishPicAndVideoList.FirstOrDefault(x => x.wellSn == itemEmbryo.wellSn);
- if (currentData == null || string.IsNullOrEmpty(currentData.lastPicture))//无图片
- {
- textBlock.Tag = 1;
- textBlock.Foreground = noPicForeground;
- border.Tag = 1;
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png", UriKind.Absolute));
- continue;
- }
- string borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png";
- int borderTag = 3;
- switch ((EmbryoState)itemEmbryo.state)
- {
- case EmbryoState.End:
- case EmbryoState.None:
- borderTag = 2;
- borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png";
- break;
- case EmbryoState.Freezing: //冷冻
- borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState1Icon.png";
- break;
- case EmbryoState.Transplant://移植
- borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState2Icon.png";
- break;
- case EmbryoState.Cancellation://作废
- borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState3Icon.png";
- break;
- case EmbryoState.Delete://删除
- borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState4Icon.png";
- break;
- }
- textBlock.Tag = 2;
- textBlock.Foreground = deaeatForeground;
- border.Tag = borderTag;
- border.Source = new BitmapImage(new Uri(borderSource, UriKind.Absolute));
- }
- SelectIndex(0);
- }
- catch (Exception)
- {
- throw;
- }
- }
- private void EmbryoAlarmEvent(int wellsn, int stateAlarm)
- {
- try
- {
- Dispatcher.Invoke(() => { SetWellImage(wellsn - 1, selectedIndex); });
- }
- catch (Exception ex)
- {
- }
- }
- private void InitCustomNew()
- {
- try
- {
- EllipseGeometry ellipseGeometry = new EllipseGeometry(new Point(imageRadius, imageRadius), imageRadius, imageRadius);
- Embryo itemEmbryo = null;
- for (int i = 0; i < ellipseCount; i++)
- {
- TextBlock textBlock = new TextBlock();
- Image border = new Image();
- Image image = new Image();
- Image opImage = new Image();
- this._canvas.Children.Add(textBlock);
- this._canvas.Children.Add(border);
- this._canvas.Children.Add(image);
- this._canvas.Children.Add(opImage);
- TextBlockList.Add(textBlock);
- ImageList.Add(border);
- PicImageList.Add(image);
- OperImageList.Add(opImage);
- Panel.SetZIndex(textBlock, 11);
- Panel.SetZIndex(border, 12);
- Panel.SetZIndex(image, 13);
- Panel.SetZIndex(opImage, 14);
- textBlock.FontWeight = FontWeights.Medium;
- textBlock.FontSize = 14;
- textBlock.Width = 16;
- textBlock.Height = 22;
- textBlock.Text = $"{i + 1}";
- textBlock.TextAlignment = TextAlignment.Center;
- textBlock.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - 7);
- textBlock.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - 11);
- border.Width = backImageRadius * 2;
- border.Height = backImageRadius * 2;
- border.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * backImageBigRadius - backImageRadius);
- border.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * backImageBigRadius - backImageRadius);
- opImage.Width = operRaius * 2;
- opImage.Height = operRaius * 2;
- opImage.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * operBigRadius - operRaius);
- opImage.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * operBigRadius - operRaius);
- image.Width = imageRadius * 2;
- image.Height = imageRadius * 2;
- image.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
- image.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
- image.SetValue(Image.ClipProperty, ellipseGeometry);
- if (vm.CurrentDish == null)
- {
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoEmbryoBackground.png", UriKind.Absolute));
- }
- else
- {
- itemEmbryo = SetWellImage(i, 0);
- if (itemEmbryo == null)
- {
- textBlock.Tag = 0;
- textBlock.Foreground = noEmbryoForeground;
- image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoEmbryo.png", UriKind.Absolute));
- }
- else
- {
- textBlock.Tag = 2;
- textBlock.Foreground = deaeatForeground;
- image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoEmbryo1.png", UriKind.Absolute));
- switch ((EmbryoState)itemEmbryo.state)
- {
- case EmbryoState.Freezing: //冷冻
- opImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState1Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Transplant://移植
- opImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState2Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Cancellation://作废
- opImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState3Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Delete://删除
- opImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState4Icon.png", UriKind.Absolute));
- break;
- default:
- opImage.Visibility = Visibility.Hidden;
- break;
- }
- }
- }
- if (i == 0) textBlock.Foreground = new SolidColorBrush(Colors.White);
- int index = i;
- image.MouseUp += (s, e) =>
- {
- if (!this.IsLoaded) return;
- if (selectedIndex == index) return;
- SelectIndex(index);
- CloseCeLiang();
- PlayerPause();
- ChangeEmbryo(index + 1);
- };
- }
- //SelectIndex(0);
- }
- catch (Exception ex)
- {
- ExLog(ex, "InitCustomNew");
- }
- }
- private object lock1 = new object();
- private Embryo SetWellImage(int index, int oldIndex)
- {
- lock (lock1)
- {
- if (vm == null || vm.CurrentDish == null) return null;
- Image imageBorder = ImageList[index];
- var itemEmbryo = vm.CurrentDish.embryoList.FirstOrDefault(x => x.wellSn == index + 1);
- if (itemEmbryo == null)
- {
- if (index == oldIndex)
- {
- imageBorder.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoSelectedIcon.png", UriKind.Absolute));
- }
- else
- {
- imageBorder.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoEmbryoBackground.png", UriKind.Absolute));
- }
- return itemEmbryo;
- }
- string borderSource = null;
- switch ((EmbryoState)itemEmbryo.state)
- {
- case EmbryoState.End:
- case EmbryoState.None:
- if (itemEmbryo.alarm == 1)
- {
- borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState3Icon.png";
- }
- else
- {
- if (index == oldIndex)
- {
- borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoSelectedIcon.png";
- }
- else
- {
- borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png";
- }
- }
- break;
- case EmbryoState.Freezing: //冷冻
- borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState1Icon.png";
- break;
- case EmbryoState.Transplant://移植
- borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState2Icon.png";
- break;
- case EmbryoState.Cancellation://作废
- borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState3Icon.png";
- break;
- case EmbryoState.Delete://删除
- borderSource = "pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState4Icon.png";
- break;
- }
- imageBorder.Source = new BitmapImage(new Uri(borderSource, UriKind.Absolute));
- return itemEmbryo;
- }
- }
- /// <summary>
- /// 设置选中状态
- /// </summary>
- /// <param name="index"></param>
- private void SelectIndex(int index)
- {
- switch (TextBlockList[selectedIndex].Tag.ToString())
- {
- case "0":
- TextBlockList[selectedIndex].Foreground = noEmbryoForeground;
- break;
- case "1":
- TextBlockList[selectedIndex].Foreground = noPicForeground;
- break;
- case "2":
- TextBlockList[selectedIndex].Foreground = deaeatForeground;
- break;
- }
- SetWellImage(selectedIndex, -1);
- selectedIndex = index;
- TextBlockList[selectedIndex].Foreground = new SolidColorBrush(Colors.White);
- var itemEmbryo = vm.CurrentDish.embryoList.FirstOrDefault(x => x.wellSn == selectedIndex + 1);
- if (itemEmbryo == null)
- {
- ImageList[selectedIndex].Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoSelectedIcon.png", UriKind.Absolute));
- }
- else
- {
- if ((itemEmbryo.state == (int)EmbryoState.End || itemEmbryo.state == (int)EmbryoState.None) && itemEmbryo.alarm == 0)
- {
- ImageList[selectedIndex].Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoSelectedIcon.png", UriKind.Absolute));
- }
- }
- RotateTransform rotateTransform = this._sx.RenderTransform as RotateTransform;
- rotateTransform.Angle = angle * selectedIndex;
- }
- private void SelectIndexold(int index)
- {
- switch (TextBlockList[selectedIndex].Tag.ToString())
- {
- case "0":
- TextBlockList[selectedIndex].Foreground = noEmbryoForeground;
- break;
- case "1":
- TextBlockList[selectedIndex].Foreground = noPicForeground;
- break;
- case "2":
- TextBlockList[selectedIndex].Foreground = deaeatForeground;
- break;
- }
- switch (ImageList[selectedIndex].Tag.ToString())
- {
- case "0":
- ImageList[selectedIndex].Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoEmbryoBackground.png", UriKind.Absolute));
- break;
- case "1":
- case "2":
- ImageList[selectedIndex].Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png", UriKind.Absolute));
- break;
- }
- selectedIndex = index;
- TextBlockList[selectedIndex].Foreground = new SolidColorBrush(Colors.White);
- switch (ImageList[selectedIndex].Tag.ToString())
- {
- case "0":
- case "1":
- case "2":
- ImageList[selectedIndex].Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoSelectedIcon.png", UriKind.Absolute));
- break;
- }
- RotateTransform rotateTransform = this._sx.RenderTransform as RotateTransform;
- rotateTransform.Angle = angle * selectedIndex;
- }
- /// <summary>
- /// 切换well
- /// </summary>
- /// <param name="well"></param>
- public void ChangeEmbryo(int well)
- {
- try
- {
- PlayerDispose();
- ClearMeasurementList();
- if (vm == null) return;
- vm.CurrentEmbryo = null;
- vm.CurrentWellDishPicAndVideo = null;
- vm.CurrentWellLayerPicAndVideo = null;
- vm.CurrentPic = null;
- SetVideoButtonState(false);
- vm.CurrentFocal = 0;
- this._bigFocal_Button.IsEnabled = true;
- this._smallFocal_Button.IsEnabled = true;
- if (vm.CurrentDish != null && vm.CurrentDish.id > 0) vm.CurrentEmbryo = vm.CurrentDish.embryoList.FirstOrDefault(x => x.wellSn == well);
- if (vm.CurrentEmbryo == null)
- {
- vm.VideoAllTime = 1;
- vm.VideoCurrentTime = 0;
- }
- if (vm.CurrentEmbryo != null) vm.CurrentWellDishPicAndVideo = vm.DishPicAndVideoList.FirstOrDefault(x => x.wellSn == vm.CurrentEmbryo.wellSn);
- if (vm.CurrentWellDishPicAndVideo != null) vm.CurrentWellLayerPicAndVideo = vm.CurrentWellDishPicAndVideo.videos.FirstOrDefault(x => x.pictureLayer == 0);
- if (vm.MaxTotalLayer == -1) if (vm.CurrentWellLayerPicAndVideo != null) vm.MaxTotalLayer = vm.CurrentWellLayerPicAndVideo.videoPictures.Max(x => x.totalLayer);
- SetPreview(well);
- SetVideo(vm.CurrentFocal, true);
- if (vm.CurrentWellLayerPicAndVideo != null && vm.CurrentWellLayerPicAndVideo.videoPictures.Any())
- {
- this._bigFocal_Button.IsEnabled = true;
- this._smallFocal_Button.IsEnabled = true;
- if (string.IsNullOrEmpty(vm.CurrentWellLayerPicAndVideo.videoUrl) || vm.CurrentWellLayerPicAndVideo.videoUrl == AppData.Instance.CleanVideoString)
- {
- var aaa = this.te.VideoCurrentTime;
- var aaa1 = this.te.VideoAllTime;
- vm.VideoAllTime = 1;
- vm.VideoCurrentTime = 0;
- vm.VideoAllTime = vm.CurrentWellLayerPicAndVideo.videoPictures.Count;
- vm.VideoCurrentTime = vm.VideoAllTime;
- }
- }
- else
- {
- this._bigFocal_Button.IsEnabled = false;
- this._smallFocal_Button.IsEnabled = false;
- }
- }
- catch (Exception ex)
- {
- ExLog(ex, "ChangeEmbryo");
- }
- }
- /// <summary>
- /// 设置视频
- /// </summary>
- private bool SetVideo(int focal, bool isUpdate)
- {
- if (vm.CurrentWellLayerPicAndVideo != null && !string.IsNullOrEmpty(vm.CurrentWellLayerPicAndVideo.videoUrl) && vm.CurrentWellLayerPicAndVideo.videoUrl != AppData.Instance.CleanVideoString)
- {
- TimeLog($"视频设置完成");
- if (PlayerSetSource($"{AppData.Instance.BaseUrl}{vm.CurrentWellLayerPicAndVideo.videoUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}")) return true;
- }
- if (!isUpdate) return false;
- vm.VideoAllTime = 1;
- vm.VideoCurrentTime = 0;
- return true;
- }
- /// <summary>
- /// 设置缩略图
- /// </summary>
- /// <param name="datas"></param>
- private void SetEmbryoPic()
- {
- Image item = null;
- for (int i = 0; i < 16; i++)
- {
- if (!PicImageList.Any()) return;
- item = PicImageList[i];
- var embryo = vm.CurrentDish.embryoList.FirstOrDefault(x => x.wellSn == i + 1);
- if (embryo == null)
- {
- item.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoEmbryo.png", UriKind.Absolute));
- continue;
- }
- var currentData = vm.DishPicAndVideoList.FirstOrDefault(x => x.wellSn == embryo.wellSn);
- if (currentData == null || currentData.lastPicture == null)
- {
- item.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoNoPic.png", UriKind.Absolute));
- }
- else
- {
- item.Source = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{currentData.lastPicture.Replace(AppData.Instance.PicSuf, $"_80x80{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpServiceCall.GetToken()}");
- }
- }
- }
- /// <summary>
- /// 设置封面
- /// </summary>
- /// <param name="well"></param>
- private void SetPreview(int well)
- {
- vm.SelectedFps = new KeyValuePair<double, string>(1d, "1.0x");
- currentMediaElement.SpeedRatio = 1d;
- //this._preview.Visibility = Visibility.Visible;
- this.Canvas_preview.Visibility = Visibility.Visible;
- if (vm.CurrentEmbryo == null)
- {
- //this._preview.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoEmbryoBigPic.png", UriKind.Absolute));
- AppData.Instance.SetImageSource(this._preview, LogoEnum.Circle);
- this.TextBlock_preview.Text = peitai;
- return;
- }
- if (vm.CurrentWellDishPicAndVideo == null || string.IsNullOrEmpty(vm.CurrentWellDishPicAndVideo.lastPicture))
- {
- this._preview.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoPicBigPic.png", UriKind.Absolute));
- this.TextBlock_preview.Text = paiShe;
- return;
- }
- //var bb = PicImageList[(well - 1)];
- //var cc = ((BitmapImage)bb.Source).UriSource.AbsolutePath.Replace("_80x80.jpg", ".jpg").Substring(1);
- this._preview.Source = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{vm.CurrentWellDishPicAndVideo.lastPicture}?token={AppData.Instance.HttpServiceCall.GetToken()}");
- this.TextBlock_preview.Text = "";
- }
- /// <summary>
- /// 设置封面为无视频
- /// </summary>
- /// <param name="well"></param>
- private void SetPreviewNoVideo()
- {
- this.Canvas_preview.Visibility = Visibility.Visible;
- //this._preview.Visibility = Visibility.Visible;
- this._preview.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoVideoPic.png", UriKind.Absolute));
- this.TextBlock_preview.Text = shiping;
- }
- /// <summary>
- /// 设置胚胎状态
- /// </summary>
- /// <param name="well"></param>
- /// <param name="embryoState"></param>
- private void SetEmbryoState(int well, int embryoState)
- {
- var item = OperImageList[(well - 1)];
- var backItme = ImageList[(well - 1)];
- EmbryoState state = (EmbryoState)embryoState;
- item.Visibility = Visibility.Visible;
- backItme.Tag = 3;
- switch (state)
- {
- case EmbryoState.Freezing://冷冻
- item.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState1Icon.png", UriKind.Absolute));
- backItme.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState1Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Transplant://移植
- item.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState2Icon.png", UriKind.Absolute));
- backItme.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState2Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Cancellation://作废
- item.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState3Icon.png", UriKind.Absolute));
- backItme.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState3Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Delete://删除
- item.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState4Icon.png", UriKind.Absolute));
- backItme.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState4Icon.png", UriKind.Absolute));
- break;
- default:
- item.Visibility = Visibility.Hidden;
- backItme.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoSelectedIcon.png", UriKind.Absolute));
- backItme.Tag = 2;
- break;
- }
- }
- /// <summary>
- /// 切换图层
- /// </summary>
- /// <param name="isMax"></param>
- private void ChangeFocal(bool isMax)
- {
- try
- {
- //DebugLog($"开始切换图层:{DateTime.Now}");
- int maxFocal = (vm.CurrentPic.totalLayer - 1) / 2;
- int minFocal = -maxFocal;
- int newCurrentFocal = vm.CurrentFocal;
- if (isMax) newCurrentFocal++;
- else newCurrentFocal--;
- if (newCurrentFocal < maxFocal) this._bigFocal_Button.IsEnabled = true;
- else this._bigFocal_Button.IsEnabled = false;
- if (newCurrentFocal > minFocal) this._smallFocal_Button.IsEnabled = true;
- else this._smallFocal_Button.IsEnabled = false;
- if (newCurrentFocal < minFocal || newCurrentFocal > maxFocal) return;
- //this._preview.Visibility = Visibility.Hidden;
- this.Canvas_preview.Visibility = Visibility.Hidden;
- Task.Run(() =>
- {
- Dispatcher.Invoke(() =>
- {
- var a = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{vm.detailProvider.GetImageUrlApi(vm.CurrentEmbryo.tlSn, vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, newCurrentFocal, vm.CurrentPic.developTime)}?token={AppData.Instance.HttpServiceCall.GetToken()}");
- if (a != null)
- {
- //this._preview.Visibility = Visibility.Visible;
- this.Canvas_preview.Visibility = Visibility.Visible;
- this.TextBlock_preview.Text = "";
- this._preview.Source = a;
- }
- });
- });
- newCurrentTime = 0;
- vm.CurrentFocal = newCurrentFocal;
- SetVideoButtonState(false);
- //var time1 = stopwatch.Elapsed;
- //DebugLog($"切换图层确定新图层:{DateTime.Now},耗时:{time1.TotalMilliseconds}");
- if (vm.CurrentWellDishPicAndVideo == null) return;
- vm.CurrentWellLayerPicAndVideo = vm.CurrentWellDishPicAndVideo.videos.FirstOrDefault(x => x.pictureLayer == vm.CurrentFocal);
- SetVideo(vm.CurrentFocal, false);
- if (vm.CurrentWellLayerPicAndVideo.videoPictures == null || !vm.CurrentWellLayerPicAndVideo.videoPictures.Any())
- {
- vm.CurrentWellLayerPicAndVideo.videoPictures = vm.detailProvider.GetVideoTimeLineApi(vm.CurrentEmbryo.tlSn, vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, vm.CurrentFocal);
- }
- if (vm.CurrentWellLayerPicAndVideo.videoPictures == null || !vm.CurrentWellLayerPicAndVideo.videoPictures.Any() || vm.CurrentPic == null) return;
- int i = 0;
- foreach (var item in vm.CurrentWellLayerPicAndVideo.videoPictures)
- {
- if (item.developTime >= vm.CurrentPic.developTime) break;
- i++;
- }
- newCurrentTime = i * (1000.00 / vm.CurrentWellLayerPicAndVideo.fps);
- //if (i == 0) newCurrentTime = 0;
- //else newCurrentTime = (i + 1) * (1000.00 / vm.CurrentWellLayerPicAndVideo.fps);
- //var time2 = stopwatch.Elapsed;
- //DebugLog($"切换图层确定新图层:{DateTime.Now},耗时:{(time2 - time1).TotalMilliseconds},切换图层以及设置视频源总耗时:{time2.TotalMilliseconds}");
- }
- catch (Exception ex)
- {
- ExLog(ex, "ChangeFocal");
- }
- //finally
- //{
- // stopwatch.Stop();
- //}
- }
- /// <summary>
- /// 切换图层
- /// </summary>
- /// <param name="isMax"></param>
- private void ChangeImageFocal(bool isMax)
- {
- try
- {
- int maxFocal = (vm.CurrentPic.totalLayer - 1) / 2;
- int minFocal = -maxFocal;
- int newCurrentFocal = vm.CurrentFocal;
- if (isMax) newCurrentFocal++;
- else newCurrentFocal--;
- if (newCurrentFocal < maxFocal) this._bigFocal_Button.IsEnabled = true;
- else this._bigFocal_Button.IsEnabled = false;
- if (newCurrentFocal > minFocal) this._smallFocal_Button.IsEnabled = true;
- else this._smallFocal_Button.IsEnabled = false;
- if (newCurrentFocal < minFocal || newCurrentFocal > maxFocal) return;
- var newCurrentWellLayerPicAndVideo = vm.CurrentWellDishPicAndVideo.videos.FirstOrDefault(x => x.pictureLayer == newCurrentFocal);
- newCurrentWellLayerPicAndVideo = vm.CurrentWellDishPicAndVideo.videos.FirstOrDefault(x => x.pictureLayer == newCurrentFocal);
- if (newCurrentWellLayerPicAndVideo == null) return;
- if (!newCurrentWellLayerPicAndVideo.videoPictures.Any()) return;
- vm.CurrentWellLayerPicAndVideo = newCurrentWellLayerPicAndVideo;
- //this._preview.Visibility = Visibility.Visible;
- this.Canvas_preview.Visibility = Visibility.Visible;
- var oldDevelopTime = vm.CurrentPic.developTime;
- vm.CurrentFocal = newCurrentFocal;
- vm.VideoAllTime = vm.CurrentWellLayerPicAndVideo.videoPictures.Count;
- int i = 0;
- foreach (var item in vm.CurrentWellLayerPicAndVideo.videoPictures)
- {
- if (item.developTime >= oldDevelopTime) break;
- i++;
- }
- //Debug.WriteLine($"{vm.CurrentWellLayerPicAndVideo.videoPictures[163].developTime} -> {oldDevelopTime}");
- //Debug.WriteLine($"focal:{i} -》 {vm.CurrentWellLayerPicAndVideo.videoPictures.Count}");
- //vm.VideoCurrentTime = vm.VideoAllTime;
- this._preview.Source = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{vm.CurrentWellLayerPicAndVideo.videoPictures[i].imageUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}");
- this.TextBlock_preview.Text = "";
- vm.VideoCurrentTime = 0;
- vm.VideoCurrentTime = i + 1;
- return;
- Task.Run(() =>
- {
- Dispatcher.Invoke(() =>
- {
- var a = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{vm.detailProvider.GetImageUrlApi(vm.CurrentEmbryo.tlSn, vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, newCurrentFocal, vm.CurrentPic.developTime)}?token={AppData.Instance.HttpServiceCall.GetToken()}");
- if (a != null)
- {
- this._preview.Visibility = Visibility.Visible;
- this._preview.Source = a;
- }
- });
- });
- newCurrentTime = 0;
- vm.CurrentFocal = newCurrentFocal;
- SetVideoButtonState(false);
- //var time1 = stopwatch.Elapsed;
- //DebugLog($"切换图层确定新图层:{DateTime.Now},耗时:{time1.TotalMilliseconds}");
- if (vm.CurrentWellDishPicAndVideo == null) return;
- vm.CurrentWellLayerPicAndVideo = vm.CurrentWellDishPicAndVideo.videos.FirstOrDefault(x => x.pictureLayer == vm.CurrentFocal);
- SetVideo(vm.CurrentFocal, false);
- if (vm.CurrentWellLayerPicAndVideo.videoPictures == null || !vm.CurrentWellLayerPicAndVideo.videoPictures.Any())
- {
- vm.CurrentWellLayerPicAndVideo.videoPictures = vm.detailProvider.GetVideoTimeLineApi(vm.CurrentEmbryo.tlSn, vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, vm.CurrentFocal);
- }
- if (vm.CurrentWellLayerPicAndVideo.videoPictures == null || !vm.CurrentWellLayerPicAndVideo.videoPictures.Any() || vm.CurrentPic == null) return;
- newCurrentTime = i * (1000.00 / vm.CurrentWellLayerPicAndVideo.fps);
- //if (i == 0) newCurrentTime = 0;
- //else newCurrentTime = (i + 1) * (1000.00 / vm.CurrentWellLayerPicAndVideo.fps);
- //var time2 = stopwatch.Elapsed;
- //DebugLog($"切换图层确定新图层:{DateTime.Now},耗时:{(time2 - time1).TotalMilliseconds},切换图层以及设置视频源总耗时:{time2.TotalMilliseconds}");
- }
- catch (Exception ex)
- {
- ExLog(ex, "ChangeImageFocal");
- }
- //finally
- //{
- // stopwatch.Stop();
- //}
- }
- private void ChangeFocalNoVideo(bool isMax)
- {
- try
- {
- //DebugLog($"开始切换图层:{DateTime.Now}");
- int maxFocal = (vm.CurrentPic.totalLayer - 1) / 2;
- int minFocal = -maxFocal;
- int newCurrentFocal = vm.CurrentFocal;
- CC:
- Debug.WriteLine($"{newCurrentFocal}、{vm.CurrentPic.developTime}");
- if (isMax) newCurrentFocal++;
- else newCurrentFocal--;
- if (newCurrentFocal < maxFocal) this._bigFocal_Button.IsEnabled = true;
- else this._bigFocal_Button.IsEnabled = false;
- if (newCurrentFocal > minFocal) this._smallFocal_Button.IsEnabled = true;
- else this._smallFocal_Button.IsEnabled = false;
- if (newCurrentFocal < minFocal || newCurrentFocal > maxFocal) return;
- //totalLayer返回11,但是视频图片数据只有7层
- var aa = vm.CurrentWellDishPicAndVideo.videos.FirstOrDefault(x => x.pictureLayer == newCurrentFocal);
- if (aa == null) goto CC;
- if (aa.videoPictures == null || !aa.videoPictures.Any())
- {
- aa.videoPictures = vm.detailProvider.GetVideoTimeLineApi(vm.CurrentEmbryo.tlSn, vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, newCurrentFocal);
- }
- if (aa.videoPictures == null || !aa.videoPictures.Any()) goto CC;
- bool b = false;
- string imageUrl = null;
- foreach (var item in aa.videoPictures)
- {
- if (item.developTime == vm.CurrentPic.developTime)
- {
- b = true;
- imageUrl = item.imageUrl;
- break;
- }
- }
- if (!b) goto CC;
- Task.Run(() =>
- {
- if (string.IsNullOrEmpty(imageUrl)) imageUrl = vm.detailProvider.GetImageUrlApi(vm.CurrentEmbryo.tlSn, vm.CurrentEmbryo.houseSn, vm.CurrentEmbryo.id, newCurrentFocal, vm.CurrentPic.developTime);
- Dispatcher.Invoke(() =>
- {
- var a = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{imageUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}");
- if (a != null)
- {
- this.Canvas_preview.Visibility = Visibility.Visible;
- //this._preview.Visibility = Visibility.Visible;
- this._preview.Source = a;
- }
- });
- });
- vm.CurrentFocal = newCurrentFocal;
- }
- catch (Exception ex)
- {
- ExLog(ex, "ChangeFocalNoVideo");
- }
- }
- private void SetVideoButtonState(bool IsEnabledVideo)
- {
- Task.Run(() =>
- {
- Dispatcher.Invoke(() =>
- {
- this._lastButton.IsEnabled = IsEnabledVideo;
- this._playButton.IsEnabled = IsEnabledVideo;
- this._nextButton.IsEnabled = IsEnabledVideo;
- });
- });
- }
- #endregion
- #region 进度条事件
- private void ProgressbarUserControl_BeforeInteractionEvent()
- {
- CloseCeLiang();
- PlayerPause();
- if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
- {
- //this._preview.Visibility = Visibility.Hidden;
- this.Canvas_preview.Visibility = Visibility.Hidden;
- }
- else
- {
- }
- }
- private void ProgressbarUserControl_AfterInteractionEvent(double obj)
- {
- //Debug.WriteLine($"After:{obj}->{ProToImageIndex()} ->{vm.CurrentWellLayerPicAndVideo.videoPictures.Count}");
- if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
- {
- currentMediaElement.LoadedBehavior = MediaState.Manual;
- SetPlayerPosition(obj);
- }
- else
- {
- if (vm.CurrentWellLayerPicAndVideo != null && vm.CurrentWellLayerPicAndVideo.videoPictures.Any())
- {
- this._preview.Source = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{vm.CurrentWellLayerPicAndVideo.videoPictures[ProToImageIndex()].imageUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}");
- this.TextBlock_preview.Text = "";
- }
- }
- }
- private void ProgressbarUserControl_ProChangendEvent(double obj)
- {
- //Debug.WriteLine($"ProChangend:{obj}->{ProToImageIndex()}");
- if (PlayerState != PlayerStateEnum.Nothing || PlayerState != PlayerStateEnum.Error)
- {
- SetPlayerPosition(obj);
- }
- else
- {
- //this._preview.Source = AppData.Instance.StringToBitmapImage($"{AppData.Instance.BaseUrl}{vm.CurrentWellLayerPicAndVideo.videoPictures[ProToImageIndex()].imageUrl}?token={AppData.Instance.HttpServiceCall.GetToken()}");
- }
- }
- int picCount = 0;
- int picIndex = 0;
- private string ProgressbarUserControl_LengthDevelopmentEvent(double arg)
- {
- try
- {
- if (vm == null || vm.CurrentWellLayerPicAndVideo == null)
- {
- vm.CurrentPic = null;
- return "00h:00m";
- }
- if (vm.CurrentWellLayerPicAndVideo == null || vm.CurrentWellLayerPicAndVideo.videoPictures == null || !vm.CurrentWellLayerPicAndVideo.videoPictures.Any())
- {
- vm.CurrentPic = null;
- return "00h:00m";
- }
- if (string.IsNullOrEmpty(vm.CurrentWellLayerPicAndVideo.videoUrl) || vm.CurrentWellLayerPicAndVideo.videoUrl == AppData.Instance.CleanVideoString)
- {
- picIndex = ProToImageIndex();
- vm.CurrentPic = vm.CurrentWellLayerPicAndVideo.videoPictures[picIndex];
- //Debug.WriteLine($"proLength {picIndex} ->{vm.CurrentWellLayerPicAndVideo.videoPictures.Count}");
- return $"{(vm.CurrentPic.developTime / 60).ToString("D2")}h:{(vm.CurrentPic.developTime % 60).ToString("D2")}m";
- }
- else
- {
- picCount = vm.CurrentWellLayerPicAndVideo.videoPictures.Count;
- picIndex = VideoProToImageIndex();
- if (picIndex < 0) picIndex = 0;
- if (picIndex > (picCount - 1)) picIndex = picCount - 1;
- vm.CurrentPic = vm.CurrentWellLayerPicAndVideo.videoPictures[picIndex];
- return $"{(vm.CurrentPic.developTime / 60).ToString("D2")}h:{(vm.CurrentPic.developTime % 60).ToString("D2")}m";
- }
- }
- catch (Exception ex)
- {
- vm.CurrentPic = null;
- ExLog(ex, "获取当前帧发育时长");
- return "00h:00m";
- }
- }
- /// <summary>
- /// 0- count-1
- /// </summary>
- /// <returns></returns>
- public int VideoProToImageIndex()
- {
- try
- {
- if (vm == null || vm.CurrentWellLayerPicAndVideo == null) return 0;
- return (int)(vm.VideoCurrentTime / (1000.00 / vm.CurrentWellLayerPicAndVideo.fps));
- }
- catch (Exception ex)
- {
- ExLog(ex, "VideoProToImageIndex");
- return 0;
- }
- }
- /// <summary>
- /// 进度条换算图片下标
- /// </summary>
- /// <returns></returns>
- public int ProToImageIndex()
- {
- try
- {
- if (vm == null || vm.CurrentWellLayerPicAndVideo == null || !vm.CurrentWellLayerPicAndVideo.videoPictures.Any()) return 0;
- var imageIndex = ((int)vm.VideoCurrentTime - 1);
- if (imageIndex < 0) imageIndex = 0;
- if (imageIndex >= vm.CurrentWellLayerPicAndVideo.videoPictures.Count) imageIndex = vm.CurrentWellLayerPicAndVideo.videoPictures.Count - 1;
- return imageIndex;
- }
- catch (Exception ex)
- {
- ExLog(ex, "ProToImageIndex");
- return 0;
- }
- }
- #endregion
- #region 视频基础操作
- double newCurrentTime = -1;
- double beilv = 1;
- MediaElement currentMediaElement = null;
- /// <summary>
- /// 定时器
- /// </summary>
- public System.Timers.Timer dispatcherTimer = new System.Timers.Timer();
- /// <summary>
- /// 视频状态
- /// </summary>
- public PlayerStateEnum PlayerState { get; set; } = PlayerStateEnum.Nothing;
- /// <summary>
- /// 播放器事件初始化
- /// </summary>
- public void PlayerEvent(MediaElement mediaElement)
- {
- try
- {
- currentMediaElement = mediaElement;
- currentMediaElement.MediaEnded -= MediaEndedEvent;
- currentMediaElement.MediaOpened -= MediaOpenedEvent;
- currentMediaElement.MediaFailed -= MediaFailedEvent; currentMediaElement.BufferingEnded -= CurrentMediaElement_BufferingEnded;
- currentMediaElement.MediaEnded += MediaEndedEvent;
- currentMediaElement.MediaOpened += MediaOpenedEvent;
- currentMediaElement.MediaFailed += MediaFailedEvent;
- //currentMediaElement.BufferingEnded += CurrentMediaElement_BufferingEnded;
- dispatcherTimer.Interval = 25;
- dispatcherTimer.Elapsed -= dispatcherTimer_Elapsed;
- dispatcherTimer.Elapsed += dispatcherTimer_Elapsed;
- }
- catch (Exception ex)
- {
- ExLog(ex, $"播放器事件初始化");
- }
- }
- private void CurrentMediaElement_BufferingEnded(object sender, RoutedEventArgs e)
- {
- TimeLog($"媒体缓冲结束时");
- }
- private string LocalVideo()
- {
- switch (vm.CurrentEmbryo.wellSn)
- {
- case 1:
- return @"C:\Users\20552\Desktop\t-修改_24-01-23-17-35-08\t-修改_well_1.mp4";
- case 2:
- return @"C:\Users\20552\Desktop\t-修改_24-01-23-17-35-08\t-修改_well_2.mp4";
- case 3:
- return @"C:\Users\20552\Desktop\t-修改_24-01-23-17-35-08\t-修改_well_3.mp4";
- case 4:
- return @"C:\Users\20552\Desktop\t-修改_24-01-23-17-35-08\t-修改_well_4.mp4";
- case 5:
- return @"C:\Users\20552\Desktop\t-修改_24-01-23-17-35-08\t-修改_well_5.mp4";
- case 6:
- return @"C:\Users\20552\Desktop\t-修改_24-01-23-17-35-08\t-修改_well_6.mp4";
- case 7:
- return @"C:\Users\20552\Desktop\t-修改_24-01-23-17-35-08\t-修改_well_7.mp4";
- }
- return "";
- }
- private string LocalVideo1()
- {
- switch (vm.CurrentEmbryo.wellSn)
- {
- case 1:
- return @"C:\Users\20552\Desktop\2_24-01-23-17-51-51\2_well_1.mp4";
- case 2:
- return @"C:\Users\20552\Desktop\2_24-01-23-17-51-51\2_well_2.mp4";
- case 3:
- return @"C:\Users\20552\Desktop\2_24-01-23-17-51-51\2_well_3.mp4";
- case 4:
- return @"C:\Users\20552\Desktop\2_24-01-23-17-51-51\2_well_4.mp4";
- case 5:
- return @"C:\Users\20552\Desktop\2_24-01-23-17-51-51\2_well_5.mp4";
- case 6:
- return @"C:\Users\20552\Desktop\2_24-01-23-17-51-51\2_well_6.mp4";
- case 7:
- return @"C:\Users\20552\Desktop\2_24-01-23-17-51-51\2_well_7.mp4";
- }
- return @"C:\Users\20552\Desktop\2_24-01-23-17-51-51\2_well_1.mp4";
- }
- /// <summary>
- /// 设置播放源
- /// </summary>
- /// <param name="FileName"></param>
- public bool PlayerSetSource(string FileName)
- {
- try
- {
- //FileName = "http://192.168.0.218:8300/vod/index.m3u8";
- //FileName = LocalVideo1();
- PlayerDispose();
- currentMediaElement.Source = new Uri(FileName, UriKind.RelativeOrAbsolute);
- currentMediaElement.LoadedBehavior = MediaState.Manual;
- currentMediaElement.SpeedRatio = 1;
- currentMediaElement.Play();
- currentMediaElement.Pause();
- return true;
- }
- catch (Exception ex)
- {
- ExLog(ex, $"设置播放源");
- return false;
- }
- }
- /// <summary>
- /// 播放器加载视频完成事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MediaOpenedEvent(object sender, RoutedEventArgs e)
- {
- try
- {
- if (!this.IsLoaded) return;
- if (vm == null) return;
- //Stopwatch stopwatch = Stopwatch.StartNew();
- TimeLog($"视频加载完成");
- //bool isWhile = true;
- //while (isWhile)
- //{
- // DebugLog($"视频下载进度:{currentMediaElement.DownloadProgress}");
- // isWhile = !(currentMediaElement.DownloadProgress == 1);
- // Thread.Sleep(20);
- //}
- //isWhile = true;
- //while (isWhile)
- //{
- // DebugLog($"视频加载进度:{currentMediaElement.BufferingProgress}");
- // isWhile = !(currentMediaElement.BufferingProgress == 1);
- // Thread.Sleep(20);
- //}
- //ErrorLog($"视频加载完成,开始设置属性", LogEnum.RunRecord);
- currentMediaElement.ScrubbingEnabled = false;
- vm.VideoAllTime = 1;
- vm.VideoCurrentTime = 0;
- if (currentMediaElement.NaturalDuration.HasTimeSpan)
- {
- currentMediaElement.LoadedBehavior = MediaState.Manual;
- PlayerState = PlayerStateEnum.Paused;
- vm.VideoAllTime = currentMediaElement.NaturalDuration.TimeSpan.TotalMilliseconds;
- //Debug.WriteLine($"{vm.CurrentFocal}:{vm.VideoAllTime}:{currentMediaElement.Source}");
- currentMediaElement.ScrubbingEnabled = true;
- //currentMediaElement.SpeedRatio = vm.SelectedFps.Key;
- currentMediaElement.Play();
- currentMediaElement.Pause();
- if (newCurrentTime != -1)
- {
- if (newCurrentTime < 0) newCurrentTime = 0;
- if (newCurrentTime > vm.VideoAllTime) newCurrentTime = vm.VideoAllTime;
- SetTimeProgressbarProgressValue(newCurrentTime);
- SetPlayerPosition(vm.VideoCurrentTime);
- newCurrentTime = -1;
- }
- else
- {
- SetTimeProgressbarProgressValue(vm.VideoAllTime);
- SetPlayerPosition(vm.VideoCurrentTime);
- }
- SetVideoButtonState(true);
- }
- else
- {
- PlayerState = PlayerStateEnum.Nothing;
- }
- //ErrorLog($"视频属性设置完成:{DateTime.Now},总耗时:{stopwatch.Elapsed.TotalMilliseconds}", LogEnum.RunRecord);
- //stopwatch.Stop();
- }
- catch (Exception ex)
- {
- PlayerState = PlayerStateEnum.Error;
- ExLog(ex, $"播放器加载视频完成事件");
- }
- }
- /// <summary>
- /// 播放完成事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MediaEndedEvent(object sender, RoutedEventArgs e)
- {
- //bool isCan = currentMediaElement.CanPause;
- try
- {
- PlayerState = PlayerStateEnum.Paused;
- dispatcherTimer_Stop();
- //currentMediaElement.LoadedBehavior = MediaState.Stop;
- //currentMediaElement.LoadedBehavior = MediaState.Play;
- //currentMediaElement.LoadedBehavior = MediaState.Pause;
- //currentMediaElement.SpeedRatio = 1;
- currentMediaElement.Play();
- currentMediaElement.Pause();
- SetTimeProgressbarProgressValue(vm.VideoAllTime);
- SetPlayerPosition(vm.VideoAllTime);
- SetPlayButton(false);
- }
- catch (Exception ex)
- {
- ExLog(ex, $"播放完成事件");
- }
- }
- /// <summary>
- /// 播放器错误事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- /// <exception cref="NotImplementedException"></exception>
- private void MediaFailedEvent(object? sender, ExceptionRoutedEventArgs e)
- {
- try
- {
- PlayerState = PlayerStateEnum.Error;
- if (vm != null)
- {
- vm.VideoAllTime = 1;
- vm.VideoCurrentTime = 0;
- }
- SetPlayButton(false);
- string ss = "";
- MediaElement med = sender as MediaElement;
- if (med != null)
- {
- ss = med.Source.ToString();
- ErrorLog($"{ss},视频遇到错误", LogEnum.RunError);
- }
- dispatcherTimer_Stop();
- ExLog(e.ErrorException, $"MediaFailedEvent:{ss}");
- }
- catch (Exception ex)
- {
- ExLog(ex, $"播放器错误事件");
- }
- }
- /// <summary>
- /// 播放按钮图标设置
- /// </summary>
- private void SetPlayButton(bool isPlaying)
- {
- if (isPlaying)//正在播放,设置为暂停按钮
- {
- this._playButton.IconSource = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailPauseVideoButtonIcon.png", UriKind.Absolute));
- this._playButton.MouseOverIconSource = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailPauseVideoButtonMouseIcon.png", UriKind.Absolute));
- }
- else//未播放,设置为播放按钮
- {
- this._playButton.IconSource = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailStartVideoButtonIcon.png", UriKind.Absolute));
- this._playButton.MouseOverIconSource = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailStartVideoButtonMouseIcon.png", UriKind.Absolute));
- }
- }
- /// <summary>
- /// 定时器事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dispatcherTimer_Elapsed(object? sender, ElapsedEventArgs e)
- {
- try
- {
- Dispatcher.Invoke(() =>
- {
- SetTimeProgressbarProgressValue(currentMediaElement.Position.TotalMilliseconds);
- });
- if (PlayerState != PlayerStateEnum.Playing)
- {
- dispatcherTimer_Stop();
- }
- }
- catch (Exception ex)
- {
- ExLog(ex, $"定时器事件");
- }
- }
- /// <summary>
- /// 停止定时器
- /// </summary>
- public void dispatcherTimer_Stop()
- {
- try
- {
- if (dispatcherTimer.Enabled)
- {
- dispatcherTimer.Enabled = false;
- dispatcherTimer.Stop();
- }
- }
- catch (Exception ex)
- {
- ExLog(ex, $"停止定时器");
- }
- }
- /// <summary>
- ///设置视频进度
- /// </summary>
- /// <param name="progressValue"></param>
- public void SetPlayerPosition(double currentTime)
- {
- try
- {
- if (PlayerState != PlayerStateEnum.Nothing && PlayerState != PlayerStateEnum.Error)
- {
- currentMediaElement.Position = TimeSpan.FromMilliseconds(currentTime);
- }
- }
- catch (Exception ex)
- {
- ExLog(ex, $"设置视频进度");
- }
- }
- /// <summary>
- /// 设置进度条进度
- /// </summary>
- public void SetTimeProgressbarProgressValue(double newTime)
- {
- try
- {
- if (vm == null) return;
- vm.VideoCurrentTime = newTime;
- }
- catch (Exception ex)
- {
- ExLog(ex, $"设置进度条进度");
- }
- }
- /// <summary>
- /// 释放播放器
- /// </summary>
- public void PlayerDispose()
- {
- try
- {
- dispatcherTimer_Stop();
- if (PlayerState != PlayerStateEnum.Nothing)
- {
- if (currentMediaElement != null)
- {
- currentMediaElement.Close();
- currentMediaElement.LoadedBehavior = MediaState.Close;
- }
- PlayerState = PlayerStateEnum.Nothing;
- }
- }
- catch (Exception ex)
- {
- PlayerState = PlayerStateEnum.Nothing;
- ExLog(ex, $"释放播放器");
- }
- }
- /// <summary>
- /// 设置倍率
- /// </summary>
- /// <param name="newSpeedRatio"></param>
- public void PlayerSetSpeedRatio(double newSpeedRatio)
- {
- try
- {
- beilv = newSpeedRatio;
- if (PlayerState == PlayerStateEnum.Playing)
- {
- currentMediaElement.LoadedBehavior = MediaState.Manual;
- currentMediaElement.SpeedRatio = newSpeedRatio;
- }
- }
- catch (Exception ex)
- {
- ExLog(ex, $"设置倍率");
- }
- }
- /// <summary>
- /// 播放操作
- /// </summary>
- public bool PlayerPlay()
- {
- try
- {
- bool isPlay = false;
- switch (PlayerState)
- {
- case PlayerStateEnum.Error:
- break;
- case PlayerStateEnum.Nothing:
- break;
- case PlayerStateEnum.Opened:
- isPlay = true;
- break;
- case PlayerStateEnum.Paused:
- isPlay = true;
- break;
- case PlayerStateEnum.Playing:
- break;
- case PlayerStateEnum.Stopped:
- currentMediaElement.Stop();
- isPlay = true;
- break;
- }
- if (isPlay)
- {
- PlayerState = PlayerStateEnum.Playing;
- if (vm.VideoCurrentTime == vm.VideoAllTime)
- {
- SetPlayerPosition(0);
- }
- if (!dispatcherTimer.Enabled)
- {
- dispatcherTimer.Start();
- }
- PlayerSetSpeedRatio(beilv);
- currentMediaElement.Play();
- //currentMediaElement.LoadedBehavior = MediaState.Play;
- SetPlayButton(true);
- return true;
- }
- return false;
- }
- catch (Exception ex)
- {
- ExLog(ex, $"播放操作");
- return false;
- }
- }
- /// <summary>
- /// 暂停操作
- /// </summary>
- /// <param name="isSetState"></param>
- public bool PlayerPause()
- {
- try
- {
- bool isPause = false;
- switch (PlayerState)
- {
- case PlayerStateEnum.Error:
- break;
- case PlayerStateEnum.Nothing:
- break;
- case PlayerStateEnum.Opened:
- break;
- case PlayerStateEnum.Paused:
- break;
- case PlayerStateEnum.Playing:
- isPause = true;
- break;
- case PlayerStateEnum.Stopped:
- break;
- }
- if (isPause)
- {
- PlayerState = PlayerStateEnum.Paused;
- //currentMediaElement.LoadedBehavior = MediaState.Pause;
- currentMediaElement.Pause();
- dispatcherTimer_Stop();
- SetPlayButton(false);
- return true;
- }
- return false;
- }
- catch (Exception ex)
- {
- ExLog(ex, $"暂停操作");
- return false;
- }
- }
- /// <summary>
- /// 上一帧
- /// </summary>
- public void PlayerLastFrame(int zhenshu)
- {
- try
- {
- bool isOK = false;
- bool isStop = false;
- switch (PlayerState)
- {
- case PlayerStateEnum.Error:
- break;
- case PlayerStateEnum.Nothing:
- break;
- case PlayerStateEnum.Opened:
- isOK = true;
- break;
- case PlayerStateEnum.Paused:
- isOK = true;
- break;
- case PlayerStateEnum.Playing:
- break;
- case PlayerStateEnum.Stopped:
- isOK = true;
- break;
- }
- if (!isOK) return;
- //var currentPositionTime = currentMediaElement.Position.TotalMilliseconds;
- if (vm.VideoCurrentTime == 0) return;
- var c = vm.VideoCurrentTime - (1000.00 / zhenshu);
- if (c < 0) c = 0;
- SetPlayerPosition(c);
- SetTimeProgressbarProgressValue(c);
- return;
- }
- catch (Exception ex)
- {
- ExLog(ex, $"上一帧");
- }
- }
- /// <summary>
- /// 下一帧
- /// </summary>
- public void PlayerNextFrame(int zhenshu)
- {
- try
- {
- bool isOK = false;
- switch (PlayerState)
- {
- case PlayerStateEnum.Error:
- break;
- case PlayerStateEnum.Nothing:
- break;
- case PlayerStateEnum.Opened:
- isOK = true;
- break;
- case PlayerStateEnum.Paused:
- isOK = true;
- break;
- case PlayerStateEnum.Playing:
- break;
- case PlayerStateEnum.Stopped:
- isOK = true;
- break;
- }
- if (!isOK) return;
- if (vm.VideoCurrentTime == vm.VideoAllTime) return;
- var newpos = vm.VideoCurrentTime + (1000d / zhenshu);
- if (newpos > vm.VideoAllTime) newpos = vm.VideoAllTime;
- SetPlayerPosition(newpos);
- SetTimeProgressbarProgressValue(newpos);
- return;
- }
- catch (Exception ex)
- {
- ExLog(ex, $"下一帧");
- }
- }
- #endregion
- }
- }
|