Beispiel #1
27
 public void PlayWAV(String Location, Boolean Repeat)
 {
     //Declare player as a new SoundPlayer with SoundLocation as the sound location
     player = new System.Media.SoundPlayer(Location);
     //If the user has Repeat equal to true
     if (Repeat == true)
     {
         //Play the sound continuously
         player.PlayLooping();
     }
     else
     {
         //Play the sound once
         player.Play();
         sound = System.Media.SystemSounds.Beep;
         sound.Play();
     }
 }
Beispiel #2
0
        /// <summary>
        /// Show dialog with title, content, type, align and sound.
        /// </summary>
        /// <param name="title">Title of message box.</param>
        /// <param name="content">Content of message box.</param>
        /// <param name="onlyOK">0 = YES/NO buttons, 1 = OK.</param>
        /// <param name="sound">Sound to be played when message box shows.</param>
        /// <returns>Dialog result Yes/No or OK(Yes)</returns>
        public DialogResult ShowDialog(string title, string content, bool onlyOK = false, System.Media.SystemSound sound = null)
        {
            TopMost = true;
            if (sound == null)
            {
                sound = System.Media.SystemSounds.Beep;
            }
            TITLE.Text   = title;
            CONTENT.Text = content;
            Size tlinSize = TextRenderer.MeasureText(title, TITLE.Font);

            TITLE.Width = tlinSize.Width + 8;
            Size lineSize     = TextRenderer.MeasureText(CONTENT.Text, CONTENT.Font);
            var  captionWidth = 1 + TITLE.Width + X.Width + _.Width + 1;

            if (captionWidth < lineSize.Width)
            {
                Width = lineSize.Width + 1;
            }
            else
            {
                Width = captionWidth;
            }
            CONTENT.Height = lineSize.Height - CONTENT.Font.Height;
            CONTENT.Width  = lineSize.Width - 1;
            Height         = 1 + TITLE.Height + CONTENT.Height + OK.Height + 1;
            Reposition();
            if (onlyOK)
            {
                NO.Visible  = false;
                OK.Text     = "OK";
                OK.Location = new Point((Width - OK.Width) / 2, Height - 24);
            }
            TITLE.Width   = Width - 1 - X.Width - 1 - _.Width;
            CONTENT.Width = Width - 2;
            sound.Play();
            return(base.ShowDialog());
        }
Beispiel #3
0
 private void UpdateYesNo_Load(object sender, EventArgs e)
 {
     SoundToPlay.Play();
 }