Exemplo n.º 1
0
        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 "); }
        }
Exemplo n.º 2
0
        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}·"); }
        }