Exemplo n.º 1
0
        IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            Bpr.BeepOk();

            //tb3.Text = string.Format("{0}  {1}", nCode, wParam);
            if (nCode >= 0)
            {
                if (wParam == (IntPtr)InterceptKeys.WM_KEYDOWN)
                {
                    int vkCode = Marshal.ReadInt32(lParam);
                    tb3.Text = $"{nCode}  {wParam}  {vkCode}  DN";
                    Debug.WriteLine(/*(Keys)*/ vkCode, "DN >>>>>>");
                }
                else if (wParam == (IntPtr)InterceptKeys.WM_KEYUP)
                {
                    int vkCode = Marshal.ReadInt32(lParam);
                    tb4.Text = $"{nCode}  {wParam}  {vkCode}  UP";
                    Debug.WriteLine(/*(Keys)*/ vkCode, "UP >>>>>>");
                }
            }

            KeyDown += (s, e) => { if (e.Key == Key.Escape)
                                   {
                                       Close();                                    /* messes up Cancel on save: App.Current.Shutdown();*/
                                   }
                                   e.Handled = true; };                            //tu:
            MouseLeftButtonDown += (s, e) => { DragMove(); e.Handled = true; };

            return(InterceptKeys.CallNextHookEx(InterceptKeys._hookID, nCode, wParam, lParam));
        }
Exemplo n.º 2
0
 void onJumpPrev(object x)
 {
     Bpr.BeepOk(); var v = x; if (Debugger.IsAttached)
     {
         Debugger.Break();
     }
 }
Exemplo n.º 3
0
        void addLike(int like1)
        {
            Bpr.BeepOk();
            var now = DateTime.Now;

            if (UserA)
            {
                _db.MuRateHists.Add(new MuRateHist {
                    DoneAt = now, MediaUnitID = CurMediaUnit.ID, LikeUnit = like1, CurPositionSec = _player.Position.TotalSeconds, DoneBy = "Alex"
                });
            }
            if (UserM)
            {
                _db.MuRateHists.Add(new MuRateHist {
                    DoneAt = now, MediaUnitID = CurMediaUnit.ID, LikeUnit = like1, CurPositionSec = _player.Position.TotalSeconds, DoneBy = "Mei"
                });
            }
            if (UserN)
            {
                _db.MuRateHists.Add(new MuRateHist {
                    DoneAt = now, MediaUnitID = CurMediaUnit.ID, LikeUnit = like1, CurPositionSec = _player.Position.TotalSeconds, DoneBy = "Nadine"
                });
            }
            if (UserZ)
            {
                _db.MuRateHists.Add(new MuRateHist {
                    DoneAt = now, MediaUnitID = CurMediaUnit.ID, LikeUnit = like1, CurPositionSec = _player.Position.TotalSeconds, DoneBy = "Zoe"
                });
            }

            var rows = DbSaveMsgBox.TrySaveAsk(_db);
        }
Exemplo n.º 4
0
        void onDelete0(object x)
        {
            var v = x; if (Debugger.IsAttached)

            {
                Debugger.Break();
            }

            Bpr.BeepOk();
            var now = DateTime.Now;

            CurMediaUnit.DeletedAt = now; //in case of exceptions at least the intent is recorded.
            var rows = DbSaveMsgBox.TrySaveAsk(_db);

            var ddir = @"C:\1\M.zDeleted";

            if (!Directory.Exists(ddir))
            {
                Directory.CreateDirectory(ddir);
            }
            var file = (string.IsNullOrEmpty(CurMediaUnit.PathName) && !string.IsNullOrEmpty(CurMediaUnit.FileName)) ? Path.Combine(CurMediaUnit.PathName, CurMediaUnit.FileName) : CurMediaUnit.PathFileExtOrg;
            var dest = Path.Combine(ddir, Path.GetFileName(file));

            Task.Run(() => Task.Delay(5000)).ContinueWith(_ => File.Move(file, dest));

            if (canMoveNext)
            {
                onMoveNext(x);
            }
            else if (canMovePrev)
            {
                onMovePrev(x);
            }
        }
Exemplo n.º 5
0
        void onSetGenre(object gi)
        {
            Bpr.BeepOk();
            var intGnr = Convert.ToInt16(gi);

            CurMediaUnit.GenreID = intGnr;
        }
Exemplo n.º 6
0
        void logAuditionCurPosn()
        {
            if (CurMediaUnit == null)
            {
                return;
            }

            if (CurMediaUnit.DurationSec > 0)
            {
                if ((CurMediaUnit.DurationSec < 600 && (CurMediaUnit.CurPositionSec / CurMediaUnit.DurationSec) > .5) || // if a muz piece - half counts as 1 audition
                    (CurMediaUnit.DurationSec >= 600 && (CurMediaUnit.DurationSec - CurMediaUnit.CurPositionSec) < 60))  // if a long muz piece or podcast - last minute could be advertising.
                {
                    safeAddAudition(CurMediaUnit.ID);
                    CurMediaUnit.CurPositionSec = 0;
                }
            }

            if (CurMediaUnit.CurPositionSec < 10)
            {
                VMPosn = CurMediaUnit.CurPositionSec = 0;
            }

            Bpr.BeepOk();

            saveAllToDb_Speak();
        }
Exemplo n.º 7
0
 void onMovePrev(object x)
 {
     Bpr.BeepOk(); savePosIfLong();
     if (canMovePrev)
     {
         CurMediaUnit = PlayList[PlayList.IndexOf(CurMediaUnit) - 1];
     }
 }
Exemplo n.º 8
0
        public HstProcessorVw() => InitializeComponent(); // KeyDown += (s, e) => { switch (e.Key) { case Key.Escape: Close(); break; } };
        async void onLoaded(object s, RoutedEventArgs e)
        {
            await reLoadTxCore();

            reload(0);

            //tSrch.Focus();
            Bpr.BeepOk();
        }
Exemplo n.º 9
0
 public static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
 {
     Bpr.BeepOk();
     if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
     {
         int vkCode = Marshal.ReadInt32(lParam);
         Debug.WriteLine(/*(Keys)*/ vkCode, ">>>>>>>>>>");
     }
     return(CallNextHookEx(_hookID, nCode, wParam, lParam));
 }
Exemplo n.º 10
0
 static void moveMePosTS(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     _prevTs = (TimeSpan)e.NewValue;
     Task.Run(async() => await Task.Delay(1125)).ContinueWith(_ =>
     {
         if (_prevTs == (TimeSpan)e.NewValue)
         {
             Bpr.BeepOk();
             ((xPositionCircularSlider)d).me1.Position = (TimeSpan)e.NewValue;
         }
     }, TaskScheduler.FromCurrentSynchronizationContext());
 }
Exemplo n.º 11
0
        async static void moveMePosnS(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            _prevSec = (double)e.NewValue;
            await Task.Delay(125);

            if (_prevSec != (double)e.NewValue)
            {
                return;
            }

            Bpr.BeepOk();
            ((xPositionCircularSlider)d).me1.Position = TimeSpan.FromSeconds((double)e.NewValue);
        }
Exemplo n.º 12
0
 void onTglPlayPause(object ___notUsed___)
 {
     CurMedUnInfo = "░░░░░░░░░░░░░░░";
     Bpr.BeepOk();
     if (isPlaying == true)
     {
         pauseAndLog();
     }
     else
     {
         playAndStartCounters();
     }
 }
Exemplo n.º 13
0
        private static async Task doPostDownloadProcessing(A0DbContext _db, System.Collections.Generic.IEnumerable <string> walkmanPlayableFiles)
        {
            foreach (var file in walkmanPlayableFiles)
            {
                var mp3CutDir = Path.Combine(MiscHelper.Dir1Cut, Path.GetFileNameWithoutExtension(file));
                if (!Directory.Exists(mp3CutDir)) // if audio is uncut yet...
                {
                    await DoPostDownloadProcessing(getDnldRow(_db, file));
                }

                Bpr.BeepOk();
            }
        }
Exemplo n.º 14
0
        async void wc_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            Bpr.BeepOk();
            lock (thisLock) { var i = TtlDnLds2Finish; Interlocked.Decrement(ref i); TtlDnLds2Finish = i; }

            var dr = getDnldRowFormDB(db, ((WebClient)(sender)).BaseAddress);

            if (dr.CastFileLength < dr.DownloadedLength)
            {
                dr.CastFileLength = dr.DownloadedLength;
            }

            if (e.Error != null && !string.IsNullOrEmpty(e.Error.Message))
            {
                InfoApnd =
                    $"Oops! Download of {dr.CastTitle} has failed with the error {e.Error.InnermostMessage()}. {TtlDnLds2Finish} downloads to go.";
                dr.DnldStatusId = "F"; // Failed to Download
                dr.ErrLog      += $"\nDnld failed: {e.Error}";
                if (dr.ErrLog.Length > 1020)
                {
                    dr.ErrLog = dr.ErrLog.Substring(0, 1020);                   // Trunkate(dr.ErrLog, 1000);
                }
                onSaveChanges(null);
                //reStart(); <- fails immediately => redo after the second round of FeedCheck and such.
            }
            else
            {
                await updateDb_doPostDnld(dr);

                if (TtlDnLds2Finish > 0)
                {
                    InfoApnd = $"download of {dr.CastTitle} has succeeded. {TtlDnLds2Finish} more to go.";
                }
                else
                {
                    InfoApnd = string.Format("All downloads have finished. Pausing for a bit to get cutting of the last download to start.");
                    await Task.Delay(10333); //let the last downloaded file to start creating cut folder (lest launch two cutters for the same file).

                    InfoApnd = string.Format("Pausing is over: movin on to final anons generation.");
                    await onGenerateAnonces(null);

                    InfoApnd = string.Format("Final anons generation is complete.");

                    if (IsAutoNextStep)
                    {
                        InfoApnd = string.Format("Re-Starting feeds check now.");
                        checkAllFeeds(_pnl1);
                    }
                }
            }
        }
Exemplo n.º 15
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var sw = Stopwatch.StartNew();

            _db.MediaUnits.Take(7).Load();

            ((System.Windows.Data.CollectionViewSource)(FindResource("mediaUnitViewSource"))).Source = _db.MediaUnits.Local;

            Title = sw.ElapsedMilliseconds.ToString();
            Bpr.BeepOk();
            System.Windows.Data.CollectionViewSource muAuditionViewSource = ((System.Windows.Data.CollectionViewSource)(FindResource("muAuditionViewSource")));
            // Load data by setting the CollectionViewSource.Source property:
            // muAuditionViewSource.Source = [generic data source]
        }
Exemplo n.º 16
0
        async void onFsToDb(object x)
        {
            ExceptionMsg = $"Checking  \"{TrgFolder}\"  for new & missing files ...  ";
            Bpr.BeepOk();

            var progressHandler = new Progress <string>(value => { ExceptionMsg = value; });
            var progress        = progressHandler as IProgress <string>;

            var   sw   = Stopwatch.StartNew();
            var   task = new FileSysProcessor().FsToDb(_db, TrgFolder, progress);
            await task;

            ExceptionMsg = $"{task.Result} new rows added in {sw.Elapsed:m\\:ss}, final status: {task.Status}.   ";
        }
Exemplo n.º 17
0
        void onTglGenre(object gi)
        {
            Bpr.BeepOk();
            var intGnr = Convert.ToInt16(gi);
            var genre  = GenreFilter.FirstOrDefault(r => r.ID == intGnr);

            if (genre != null)
            {
                GenreFilter.Remove(genre);
            }
            else
            {
                GenreFilter.Add(Genres.FirstOrDefault(r => r.ID == intGnr));
            }
        }
Exemplo n.º 18
0
        void onDnldOne(object dgD)
        {
            Bpr.BeepOk();

            SelectedDnLd.ReDownload = true;

            //Application.Current.Dispatcher.BeginInvoke(new Action(() =>			{
            if (!CurrentDnLds.Contains(SelectedDnLd))
            {
                CurrentDnLds.Add(SelectedDnLd);
            }
            //}));

            onStartDnlds(dgD);             // StartDownload(SelectedDnLd, ((DataGrid)dgD));
        }
Exemplo n.º 19
0
 void onMoveNext(object x)
 {
     Bpr.BeepOk(); savePosIfLong();
     if (LastPiece == true)
     {
         pauseAndLog();
     }
     else if (PlayList.IndexOf(CurMediaUnit) < PlayList.Count() - 1)
     {
         CurMediaUnit = PlayList[PlayList.IndexOf(CurMediaUnit) + 1];
     }
     else
     {
         pauseAndLog();
     }
 }
Exemplo n.º 20
0
        void onLoadExistingAudioFiles(object notUsed)
        {
            if (!Directory.Exists(MiscHelper.DirPlyr))
            {
                Directory.CreateDirectory(MiscHelper.DirPlyr);
            }

            foreach (var file in Directory.GetFiles(MiscHelper.DirPlyr))
            {
                if (!".m4a.mp3.wma.wav".Contains(Path.GetExtension(file).ToLower()))
                {
                    continue;
                }

                Debug.WriteLine(file, "Load FS exist-g");

                if (CurrentDnLds.FirstOrDefault(r => file.Contains(r.CastFilenameExt)) != null)
                {
                    continue;                                                                                             // already there
                }
                var t = Db.DnLds.FirstOrDefault(r => file.Contains(r.CastFilenameExt));
                if (t == null)
                {
                    Db.DnLds.Where(r => file.Contains(r.CastFilenameExt)).OrderByDescending(r => r.PublishedAt).Load();

                    t = Db.DnLds.FirstOrDefault(r => file.Contains(r.CastFilenameExt));
                    if (t == null)
                    {
                        t = Db.DnLds.FirstOrDefault(r => file.Contains(r.CastFilenameExt));
                    }
                    if (t == null)
                    {
                        Debug.WriteLine("   not in _db yet; strange.");
                    }
                }

                if (t != null)
                {
                    CurrentDnLds.Add(t);
                }
            }

            Bpr.BeepOk();
        }
Exemplo n.º 21
0
        public static async Task GenerateAllAndFolderAnons(A0DbContext _db, string path)
        {
            //if (Environment.MachineName == "LN1") return;

            try
            {
                //making sure no files left uncut:
                var walkmanPlayableFiles = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories).Where(f => MediaHelper.WalkmanPlayableExtDsv.Contains(Path.GetExtension(f).ToLower()) && !f.EndsWith(MediaHelper.AnonsExt));

                //todo: decide what to do with cutting in pieces for the new walkman: await doPostDownloadProcessing(_db, walkmanPlayableFiles);

                collectTotalTime(_db, walkmanPlayableFiles, out var ttlCasts, out var ttlDurnMin);
                AdvertCutter.CreateSummaryAnons(ttlDurnMin, path);

                var needReqson = isAnonGenNeeded(path);
                Debug.Write($"<<<<  {path,-80}: {walkmanPlayableFiles.Count(),4} media files, {ttlDurnMin,4:N0}  min \t {needReqson.reason}");

                if (needReqson.needed)
                {
                    foreach (var file in walkmanPlayableFiles) // add anonses for each cast:
                    {
                        var dr = getDnldRow(_db, file);        // Path.GetFileName(dir)); //
                        if (dr == null)
                        {
                            continue;
                        }

                        await getUpdateSaveMediaDuration(_db, file, dr);

#if !DEBUG
                        AdvertCutter.CreateOverwriteAnons(dr.Feed == null ? "Unknown feed" : dr.Feed.Name, dr.PublishedAt, dr.CastTitle, ttlCasts, ttlDurnMin, dr.DurationMin.Value, file);
#endif

                        ttlDurnMin -= dr.DurationMin.Value;
                        ttlCasts--;
                        Bpr.BeepOk();
                    }
                }
            }
            catch (Exception ex) { ex.Log(); }
            Debug.WriteLine($">>>>");
        }
Exemplo n.º 22
0
        async Task reLoad()
        {
            var sw = Stopwatch.StartNew();

            try
            {
                //Db.DnLds.Where(o => (DateTime.Now - o.PublishedAt).TotalDays < 10).OrderByDescending(o => o.PublishedAt).Load(); //loading all for the sake of order.

                var dnlds = Db.DnLds.Where(r => r.IsStillOnline == true).OrderByDescending(o => o.PublishedAt);
                Debug.WriteLine("{0} rows from {1}", dnlds.Count(), dnlds.ToString());
                dnlds.Load(); //loading all for the sake of order.

                var feeds = Db.Feeds.Where(r => /*string.Compare(r.HostMachineId, Environment.MachineName, true) == 0 &&*/ !r.IsDeleted
#if _DEBUG
                                           && r.IsActiveDbg
                                           //)					.Include(d => d.DnLds//?? no go	.OrderByDescending(                 o => o.PublishedAt)
                                           //both good, but overriden by feed compare:	//
                                           // .Where                 (r => r.ReDownload || (r.DownloadedAt == null && r.PublishedAt > new DateTime(2013, 11, 22) && string.Compare(r.Feed.HostMachineId , Environment.MachineName, true) == 0)				)
                                           //).Where(q => q.DnLds.Any(r => r.ReDownload || (r.DownloadedAt == null && r.PublishedAt > new DateTime(2013, 11, 22) && string.Compare(r.Feed.HostMachineId , Environment.MachineName, true) == 0))
                                           //).Where(q => q.DnLds.Any(r => r.IsStillOnline == true)
                                           //.Where                 (r => r.IsStillOnline == true)
#endif
                                           ).OrderBy(r => r.Name);
                feeds.Load();
                var feedsSql = feeds.ToString();

                //refilterLoaclToFiltered();
                //onLoadExistingAudioFiles(null); Debug.WriteLine("::>Loaded in {0:s\\.ff} sec: {1}, {2},   {3}, {4}, filt.dnld: {5}", sw.Elapsed, Db.Feeds.Count(), Db.Feeds.Count(), Db.DnLds.Count(), Db.DnLds.Count(), CurrentDnLds.Count);
                //await Task.Delay(1000); onLoadExisting(null); Debug.WriteLine("::>Loaded in {0:s\\.ff} sec: {1}, {2},   {3}, {4}, filt.dnld: {5}", sw.Elapsed, Db.Feeds.Count(), Db.Feeds.Count(), Db.DnLds.Count(), Db.DnLds.Count(), CurrentDnLds.Count); Bpr.Beep(999, 29);
                //await Task.Delay(1000); onLoadExisting(null); Debug.WriteLine("::>Loaded in {0:s\\.ff} sec: {1}, {2},   {3}, {4}, filt.dnld: {5}", sw.Elapsed, Db.Feeds.Count(), Db.Feeds.Count(), Db.DnLds.Count(), Db.DnLds.Count(), CurrentDnLds.Count); Bpr.Beep(999, 29);
                //await Task.Delay(1000); onLoadExisting(null); Debug.WriteLine("::>Loaded in {0:s\\.ff} sec: {1}, {2},   {3}, {4}, filt.dnld: {5}", sw.Elapsed, Db.Feeds.Count(), Db.Feeds.Count(), Db.DnLds.Count(), Db.DnLds.Count(), CurrentDnLds.Count); Bpr.Beep(999, 29);

                InfoApnd =
                    $"Loaded in {sw.Elapsed:s\\.ff} sec. glb/lcl feed,dlnl: {feeds.Count()} / {Db.Feeds. Count()},  {"dnlds.Count()"}/{Db.DnLds. Count()},  filt.dnld:{CurrentDnLds.Count}";
            }
            catch (Exception ex) { ex.Log(); InfoApnd +=
                                       $"::>Loaded in {sw.Elapsed:s\\.ff} sec: {ex.Message}"; }

            await Task.Delay(10);

            Bpr.BeepOk();
        }
Exemplo n.º 23
0
        void onDeleteOne(object dgH)
        {
            Bpr.BeepOk();

            //Application.Current.Dispatcher.BeginInvoke(new Action(() =>			{
            if (CurrentDnLds.Contains(SelectedDnLd))
            {
                CurrentDnLds.Remove(SelectedDnLd);
            }

            var td = db.DnLds.FirstOrDefault(r => r.Id == SelectedDnLd.Id);

            if (td != null)
            {
                db.DnLds.Remove(td);
            }

            SelectedDnLd = null;
            //}));
        }
Exemplo n.º 24
0
        void safeAddAudition(int id)
        {
            var now = DateTime.Now;

            if ((now - _prevSaveTime).TotalSeconds < 10)
            {
                return;
            }

#if !DEBUG
            var partyMode = false;
#else
            var partyMode = true;
#endif
            Bpr.BeepOk();
            if (UserA)
            {
                _db.MuAuditions.Add(new MuAudition {
                    DoneAt = now, PartyMode = partyMode, MediaUnitID = id, DoneBy = "Alex"
                });
            }
            if (UserM)
            {
                _db.MuAuditions.Add(new MuAudition {
                    DoneAt = now, PartyMode = partyMode, MediaUnitID = id, DoneBy = "Mei"
                });
            }
            if (UserN)
            {
                _db.MuAuditions.Add(new MuAudition {
                    DoneAt = now, PartyMode = partyMode, MediaUnitID = id, DoneBy = "Nadine"
                });
            }
            if (UserZ)
            {
                _db.MuAuditions.Add(new MuAudition {
                    DoneAt = now, PartyMode = partyMode, MediaUnitID = id, DoneBy = "Zoe"
                });
            }
        }
        async void wc_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
            var dr = await getDnldRowFromUrl(((WebClient)(sender)).BaseAddress);

            if (dr == null)
            {
                return;
            }

            if (dr.CastFileLength < dr.DownloadedLength)
            {
                dr.CastFileLength = dr.DownloadedLength;
            }

            if (e.Error != null && !string.IsNullOrEmpty(e.Error.Message))
            {
                Appender       += $"Oops! Download of {dr.CastTitle} has failed with the error {e.Error.InnermostMessage()}.";
                dr.DnldStatusId = "F"; // Failed to Download
                dr.ErrLog      += $"\r\nDnld failed: {e.Error}";
                if (dr.ErrLog.Length > 1020)
                {
                    dr.ErrLog = dr.ErrLog.Substring(0, 1020);                   // Trunkate(dr.ErrLog, 1000);
                }
            }
            else
            {
                dr.DnldStatusId     = "H"; // HasBeenDownloaded
                dr.ReDownload       = false;
                dr.DownloadedAt     = DateTime.Now;
                dr.DownloadedByPC   = Environment.MachineName;
                dr.DownloadedToDir  = MiscHelper.DirPlyr;
                dr.DownloadedLength = new FileInfo(dr.FullPathFile(MiscHelper.DirPlyr)).Length;
                File.SetCreationTime(dr.FullPathFile(MiscHelper.DirPlyr), dr.PublishedAt);
            }

            dr.ModifiedAt = DateTime.Now;

            Bpr.BeepOk();
        }
Exemplo n.º 26
0
 void onMoveToEnd(object x)
 {
     Bpr.BeepOk(); _player.Position = _player.NaturalDuration.TimeSpan.Subtract(TimeSpan.FromSeconds(1.5));
 }
Exemplo n.º 27
0
 void onMoveToStart(object x)
 {
     Bpr.BeepOk(); _player.Position = TimeSpan.FromSeconds(0);
 }
Exemplo n.º 28
0
 async Task <int> onLoadList(object ___notUsed___)
 {
     Bpr.BeepOk(); return(await LoadList());
 }
Exemplo n.º 29
0
 void onSeeDupes(object ___notUsed___)
 {
     Bpr.BeepOk(); new AudioCompareMain(CurMediaUnit.FileName).Show();
 }
Exemplo n.º 30
0
 void onSaveChanges(object x)
 {
     Bpr.BeepOk();
     InfoApnd = $"{db.TrySaveReport().rowsSavedCnt} rows saved";
     Bpr.BeepOk();
 }