示例#1
0
        public formOptions()
        {
            InitializeComponent();

            // Load PauseMusic settings
            checkBoxAutoPauseMusic.Checked = FormMusicPlayer.getConfigurationValue("PauseMusicEnabled", "TRUE").ToUpper() == "TRUE";
            try
            {   //Try do parse delay value.
                numericUpDownPause.Value = decimal.Parse(FormMusicPlayer.getConfigurationValue("PauseMusicDelay", "0"));
            }
            catch (Exception)
            {//Do nothing
            }
            try
            {   //Try do parse volume value.
                volumeSliderPause.Volume = float.Parse(FormMusicPlayer.getConfigurationValue("PauseVolume", "0,1"));
            }
            catch (Exception)
            {//Do nothing
            }

            // Load music folders for Warmup music and Break music
            tbWarmupDir.Text = FormMusicPlayer.getConfigurationValue("WarmupMusicDirectory", string.Empty);
            tbBreakDir.Text  = FormMusicPlayer.getConfigurationValue("BreakMusicDirectory", string.Empty);
        }
示例#2
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     using (FormMusicPlayer FMP = new FormMusicPlayer())
     {
         Application.Run(FMP);
     }
 }
        public FormEditParticipants(FormMusicPlayer Owner, string defaultCategory)
        {
            if (Owner != null)
            {
                InitializeComponent();

                fmp = Owner;
                // Load the categories to the combobox
                FormMusicPlayer.loadCategories(fmp.doc, this.comboBoxCategory);

                try
                {
                    comboBoxCategory.SelectedIndex = comboBoxCategory.FindStringExact(defaultCategory);
                }
                catch (Exception)
                {
                }
            }
        }
        private void dataGridViewParticipants_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            // Initialize audioreader so we can verify if the files found are playable
            AudioFileReader audioFileReaderTest = null;
            var             senderGrid          = (DataGridView)sender;

            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn &&
                e.RowIndex >= 0 && e.RowIndex < senderGrid.Rows.Count - 1)
            {
                //Button Clicked - Execute Code Here
                openFileDialog1.Title    = "Select musicfile for:" + senderGrid[1, e.RowIndex].Value.ToString() + " " + senderGrid[2, e.RowIndex].Value.ToString();
                openFileDialog1.FileName = string.Empty;
                if (openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        // Make the path relative if possible.
                        if (openFileDialog1.FileName.Substring(0, Application.StartupPath.Length) == Application.StartupPath)
                        {                                                                                                      // Remove startpath
                            openFileDialog1.FileName = openFileDialog1.FileName.Substring(Application.StartupPath.Length + 1); //Also remove the backslash from path
                        }

                        // Calculate MD5 for musicfile to verify that no other participant already has this file
                        string MD5 = FormMusicPlayer.getMD5HashFromFile(openFileDialog1.FileName);

                        // First check so no other participant already has this file
                        for (int i = 0; i < senderGrid.Rows.Count - 1; i++)
                        {
                            if ((i != e.RowIndex && senderGrid[9, i].Value.ToString() == openFileDialog1.FileName) || (senderGrid[12, i].Value.ToString() == openFileDialog1.FileName))
                            {
                                MessageBox.Show("File already connected to participant " + senderGrid[1, i].Value + " " + senderGrid[2, i].Value + "\n\nFile not connected to this participant!", Properties.Resources.CAPTION_DUPLICATE_USE, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                                MD5 = string.Empty;  //Remove MD5 to indicate that the file isn't connected
                            }
                        }

                        // Check MD5 for musicfile so no other participant already has this file
                        for (int i = 0; i < senderGrid.Rows.Count - 1; i++)
                        {
                            if (!string.IsNullOrEmpty(MD5))
                            {
                                if ((i != e.RowIndex && senderGrid[10, i].Value.ToString() == MD5) || (senderGrid[13, i].Value.ToString() == MD5))
                                {
                                    MessageBox.Show("Identical file content already connected to participant " + senderGrid[1, i].Value + " " + senderGrid[2, i].Value + "\n\nFile not connected to this participant!", Properties.Resources.CAPTION_DUPLICATE_USE, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                                    MD5 = string.Empty;  //Remove MD5 to indicate that the file isn't connected
                                }
                            }
                        }

                        //Try to load the file to see if NAudio can read it. Gives an exception if we can't read it
                        audioFileReaderTest = new AudioFileReader(openFileDialog1.FileName);

                        // Do we have a MD5? If so connect file to participant
                        if (!string.IsNullOrEmpty(MD5))
                        {
                            senderGrid[8, e.RowIndex].Value  = string.Format("{0:00}:{1:00}", (int)audioFileReaderTest.TotalTime.TotalMinutes, audioFileReaderTest.TotalTime.Seconds);
                            senderGrid[9, e.RowIndex].Value  = openFileDialog1.FileName;
                            senderGrid[10, e.RowIndex].Value = FormMusicPlayer.getMD5HashFromFile(openFileDialog1.FileName);
                            senderGrid.Rows[e.RowIndex].DefaultCellStyle.ForeColor = SystemColors.ControlText;  // Restore color if it wasn't correct
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Can't verify file as a music file\n\n\n" + "Errormessage:" + ex.Message, Properties.Resources.CAPTION_INVALID_FILE, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    finally
                    {
                        if (audioFileReaderTest != null)
                        {
                            // Dispose of the reader
                            audioFileReaderTest.Dispose();
                            audioFileReaderTest = null;
                        }
                    }
                }
            }
        }
 private void comboBoxCategory_SelectedIndexChanged(object sender, EventArgs e)
 {
     FormMusicPlayer.loadParticipantsDV(fmp.doc, comboBoxCategory.SelectedItem.ToString(), dataGridViewParticipants);
 }