async Task addToMruListIfNotThere(MediaInfoDto nxtPLt) { if (!MruLst.Any(r => r.FileOnly.Equals(nxtPLt.FileOnly, StringComparison.OrdinalIgnoreCase))) { await nxtPLt.SetThumbnail(/*sf*/); //sep13 MruLst.Add(nxtPLt); } }
void mruFindAdd(string fileonly) { if (MruLst.Any(r => fileonly.Equals(r.FileOnly, StringComparison.OrdinalIgnoreCase))) { Cur = MruLst.First(r => fileonly.Equals(r.FileOnly, StringComparison.OrdinalIgnoreCase)); } else { //?? _mru.Add((_cur = new MediaInfoDto(fileonly) { LastUsed = DateTime.Now })); } }
async Task <MediaInfoDto> existingTopMru() { if (!MruLst.Any()) { return(null); } foreach (var mu in MruLst.OrderByDescending(r => r.LastUsed)) { if (await MidExists(mu)) { return(mu); } } return(null); }
public void Mru_FindAdd_MakeCur(StorageFile sf) { if (MruLst.Any(r => sf.Name.Equals(r.FileOnly, StringComparison.OrdinalIgnoreCase))) { Cur = MruLst.First(r => sf.Name.Equals(r.FileOnly, StringComparison.OrdinalIgnoreCase)); if (!Cur.PathFile.Equals(sf.Path, StringComparison.OrdinalIgnoreCase)) // if from another PC: update path to this one. { Cur.PathFile = sf.Path; } } else { MruLst.Add((Cur = new MediaInfoDto(sf) { LastUsed = DateTime.Now })); } }
async void updateSaveSettings() { try { if (Cur == null) { return; } try { var cur = MruLst.FirstOrDefault(r => r.FileOnly.Equals(Cur.FileOnly, StringComparison.OrdinalIgnoreCase)); if (cur == null) { return; } if (!Cur.Equals(cur)) { Cur = cur; } if ( Cur.PlayPosn == mp_Xm.PlaybackSession.Position && Cur.PlayLeng == mp_Xm.PlaybackSession.NaturalDuration && Cur.LastPcNm == DevOp.MachineName) { return; } Cur.PlayPosn = mp_Xm.PlaybackSession.Position; Cur.PlayLeng = mp_Xm.PlaybackSession.NaturalDuration; Cur.LastPcNm = DevOp.MachineName; Cur.LastUsed = DateTime.Now; //AppSettingsHelper.RemoVal(AppSetConst.Mru4Roam); AppSettingsHelper.SaveVal(AppSetConst.Mru4Roam, JsonHelper.ToJson(MruLst)); AppSettingsHelper.SaveVal(AppSetConst.PagesTtl, PagesTtl); AppSettingsHelper.SaveVal(AppSetConst.PlayRate, mp_Xm.PlaybackSession.PlaybackRate); tbDbg3.Text = tbInfo.Text += "."; } catch (COMException ex) { Debug.WriteLine($"$#~>{ex.Message}"); var min = MruLst.Min(x => x.LastUsed); if (MruLst.Any(r => r.LastUsed == min)) { var mru = MruLst.FirstOrDefault(r => r.LastUsed == min); MruLst.Remove(mru); await Speak($"Max limit exceeded. Removing {mru.FileOnly}"); updateSaveSettings(); } else { await Speak($"the history has {MruLst.Count} files. i.e.: nothing to remove."); } } catch (Exception ex) { Debug.WriteLine($"$#~>{ex.Message}"); if (Debugger.IsAttached) { Debugger.Break(); } else { await popEx(ex, "updateStngs"); } } } finally { Debug.WriteLine("--- UpdtStng "); } }
async void updateSaveSettings(string s) { try { if (SlctMru == null) { return; } try { if (mp_Vm.PlaybackSession.NaturalDuration == TimeSpan.Zero || ( SlctMru.PlayPosn.TotalSeconds >= mp_Vm.PlaybackSession.Position.TotalSeconds && SlctMru.PlayLeng == mp_Vm.PlaybackSession.NaturalDuration && SlctMru.LastPcNm == DevOp.MachineName)) { return; } if (SlctMru.PlayPosn < mp_Vm.PlaybackSession.Position) { SlctMru.PlayPosn = mp_Vm.PlaybackSession.Position; } SlctMru.PlayLeng = mp_Vm.PlaybackSession.NaturalDuration; SlctMru.LastPcNm = DevOp.MachineName; SlctMru.LastUsed = DateTime.Now; AppSettingsHelper.SaveStr(AppSetConst.Mru4Roam, JsonHelper.ToJson(MruLst)); AppSettingsHelper.SaveVal(AppSetConst.PagesTtl, PagesTtl); AppSettingsHelper.SaveVal(AppSetConst.PlayRate, mp_Vm.PlaybackSession.PlaybackRate); if (Dispatcher.HasThreadAccess) { TbInfo += $"{s}"; } else { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => TbInfo += $"{s}°"); } } catch (COMException ex) { Debug.WriteLine($"$#~>{ex.Message}"); var min = MruLst.Min(x => x.LastUsed); if (MruLst.Any(r => r.LastUsed == min)) { var mru = MruLst.FirstOrDefault(r => r.LastUsed == min); await Speak($"Max limit exceeded. Removing {mru.FileOnly}"); MruLst.Remove(mru); updateSaveSettings("x"); } else { await Speak($"the history has {MruLst.Count} files. i.e.: nothing to remove."); } } catch (Exception ex) { Debug.WriteLine($"$#~>{ex.Message}"); if (Debugger.IsAttached) { Debugger.Break(); } else { await popEx(ex, GetType().FullName); } } } finally { Debug.WriteLine($"{s}·"); } }