static void Main(string[] args) { Rekordbox6Paths.RekordboxBinariesFolder = ProgramSettings.RekordboxBinariesFolder; if (!ProgramSettings.IsRekordbox6Configured) { Messages.WarningMessage("The Rekordbox 6 executable could not be found. Be sure to configure it in the Options menu before proceeding : Tools / Options."); } // We can start the application even if the exe could not be found because we have to configure it anyway if (ProgramSettings.IsRekordbox6Configured || Rekordbox6Paths.IsRekordbox6Installed()) { Configuration = new ConfigurationBuilder() .AddEnvironmentVariables() .AddUserSecrets(System.Reflection.Assembly.GetExecutingAssembly()) .AddCommandLine(args) .Build(); // Cleaning output files if (ProgramSettings.CleanFilesAtStartup) { OBSExport.Clean(); } Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } else { Messages.ErrorMessage("Rekordbox 6 is required to run this program. Please install this software and try again."); } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (exportThread != null && exportThread.IsAlive) { StopExport(); e.Cancel = true; var timer = new System.Timers.Timer(); timer.AutoReset = false; timer.SynchronizingObject = this; timer.Interval = 1000; timer.Elapsed += (sender, args) => { // Do a fast check to see if the worker thread is still running. if (exportThread.Join(0)) { // Reissue the form closing event. Close(); } else { // Keep restarting the timer until the worker thread ends. timer.Start(); } }; timer.Start(); } if (ProgramSettings.CleanFilesAtShutDown) { OBSExport.Clean(); } }
private void OneTimeExport() { LastTrack lt; OBSExport.Clean(); if (!radEditMode.Checked) { lt = h.GetLastTrack(); } else { lt = new LastTrack(); lt.Artist = txtArtist.Text; lt.Title = txtTitle.Text; } OBSExport.ExportLastTrack(lt); }
private void ContinuousExport() { string key = ProgramSettings.Key; MasterDB masterDB = null; try { masterDB = new MasterDB(Paths.DbPath, key); } catch (FileNotFoundException e) { Messages.ErrorMessage(e.Message); Messages.ErrorMessage("Exiting program..."); this.Close(); } Helpers h = new Helpers(masterDB); while (!IsDisposed && !stopExport) { LastTrack lt = h.GetLastTrack(); if (lt != null) { OBSExport.ExportLastTrack(lt); txtArtist.Invoke((Action) delegate { txtArtist.Text = lt.Artist; }); txtTitle.Invoke((Action) delegate { txtTitle.Text = lt.Title; }); lnkFilename.Invoke((Action) delegate { lnkFilename.Text = lt.FolderPath; }); picArtwork.Invoke((Action) delegate { if (!string.IsNullOrEmpty(lt.ImagePath)) { picArtwork.Image = Image.FromFile(Paths.AnalysisDataRootPath + lt.ImagePath); } else { if (!string.IsNullOrEmpty(ProgramSettings.DefaultArtwork)) { picArtwork.Image = Image.FromFile(ProgramSettings.DefaultArtwork); } else { picArtwork.Image = null; } } } ); txtHistory.Invoke((Action) delegate { txtHistory.Text = lt.created_at.ToString(); }); txtLastExport.Invoke((Action) delegate { txtLastExport.Text = OBSExport.PreviousUpdate.ToString(); }); } Thread.Sleep(ProgramSettings.Timer * 1000); } // Allow the process to be restarted now it's been stopped stopExport = false; }
private void ContinuousExport() { while (!IsDisposed && !stopExport) { // If normal mode (= not edit mode), the file is read from Rekordbox // otherwise we export what's written in the text boxes if (!radEditMode.Checked) { lt = h.GetLastTrack(); } else { lt = new LastTrack(); lt.Artist = txtArtist.Text; lt.Title = txtTitle.Text; } localHistory.Add(lt); if (lt != null) { if (radContinuousExport.Checked) { OBSExport.ExportLastTrack(lt); } txtArtist.Invoke((Action) delegate { txtArtist.Text = lt.Artist; }); txtTitle.Invoke((Action) delegate { txtTitle.Text = lt.Title; }); lnkFilename.Invoke((Action) delegate { lnkFilename.Text = lt.FolderPath; }); picArtwork.Invoke((Action) delegate { if (!string.IsNullOrEmpty(lt.ImagePath)) { picArtwork.Image = Image.FromFile(Rekordbox6Paths.AnalysisDataRootPath + lt.ImagePath); } else { if (!string.IsNullOrEmpty(ProgramSettings.DefaultArtwork)) { picArtwork.Image = Image.FromFile(ProgramSettings.DefaultArtwork); } else { picArtwork.Image = null; } } } ); txtHistory.Invoke((Action) delegate { txtHistory.Text = lt.created_at.ToString(); }); txtLastExport.Invoke((Action) delegate { txtLastExport.Text = OBSExport.PreviousUpdate.ToString(); }); } Thread.Sleep(ProgramSettings.Timer * 1000); } // Allow the process to be restarted now it's been stopped stopExport = false; }
private void toolStripMenuItem3_Click(object sender, EventArgs e) { OBSExport.Clean(); }