Exemple #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();
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="icon"></param>
        private void SetIcon(MessageBoxIcon icon)
        {
            switch (icon)
            {
            case MessageBoxIcon.Error:
                Icon      = SystemIcons.Error;
                mSysSound = System.Media.SystemSounds.Hand;
                break;

            case MessageBoxIcon.Information:
                Icon      = SystemIcons.Information;
                mSysSound = System.Media.SystemSounds.Asterisk;
                break;

            case MessageBoxIcon.None:
                ShowIcon = false;
                break;

            case MessageBoxIcon.Question:
                Icon      = SystemIcons.Question;
                mSysSound = System.Media.SystemSounds.Question;
                break;

            case MessageBoxIcon.Warning:
                Icon      = SystemIcons.Warning;
                mSysSound = System.Media.SystemSounds.Exclamation;
                break;

            default:
                throw new ArgumentException("Invalid icon option especified for " + this.GetType().ToString());
            }
        }
        private void InitializeClass(System.Media.SystemSound sound, string emailAddress, SqlConnectionStringBuilder csb)
        {
            playSound = (sound != null);
            sysSound  = sound;

            sendEmail         = !string.IsNullOrEmpty(emailAddress);
            this.emailAddress = emailAddress;

            if (sendEmail)
            {
                if (csb == null)
                {
                    throw new Exception("Parameter csb (SqlConnectionStringBuilder) cannot be nulll.");
                }
                else
                {
                    this.csb = csb;
                    conn     = new SqlConnection();
                    conn.ConnectionString = csb.ConnectionString;
                    conn.Open();
                    cmd             = new SqlCommand();
                    cmd.Connection  = conn;
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.CommandText = "msdb.dbo.sp_send_dbmail";
                    recipient       = new SqlParameter("@recipients", System.Data.SqlDbType.VarChar, -1);
                    recipient.Value = this.emailAddress;
                }
            }
        }
        private void ConfirmCanvasSize(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return)
            {
                UpdateCanvasSize();
            }
            else
            {
                System.Windows.Input.Key k = e.Key;
                if (Key.D0 <= k && k <= Key.D9 ||
                    Key.NumPad0 <= k && k <= Key.NumPad9 ||
                    k == Key.OemMinus || k == Key.Subtract ||
                    k == Key.Decimal || k == Key.OemPeriod)
                {
                }
                else
                {
                    e.Handled = true;


                    System.Media.SystemSound ss = System.Media.SystemSounds.Beep;
                    ss.Play();
                }
            }
        }
        internal static void PlaySystemSound(string sound)
        {
            System.Media.SystemSound s = null;
            switch (sound.ToLower().Trim())
            {
            case "hand":
                s = System.Media.SystemSounds.Hand;
                break;

            case "exclamation":
                s = System.Media.SystemSounds.Exclamation;
                break;

            case "asterisk":
                s = System.Media.SystemSounds.Asterisk;
                break;

            case "question":
                s = System.Media.SystemSounds.Question;
                break;
            }

            if (s != null)
            {
                s.Play();
                System.Threading.Thread.Sleep(1000);
                s.Play();
                System.Threading.Thread.Sleep(1000);
                s.Play();
            }
        }
Exemple #6
0
        /*
         * // Methods
         * public static void ShowModal(string text)
         * {
         *  form1.Dispose();
         *  form1 = new Form();
         *  InitializeComponent();
         *
         *  if (form1.ParentForm == null)
         *      form1.StartPosition = FormStartPosition.CenterScreen;
         *
         *  label1.Location = new Point(12, label1.Location.Y);
         *
         *  btnNames = AsignButtons(buttons);
         *
         *  label1.Text = text;
         *  FormAutoHeigh();
         *
         *  CenterButtons(btnNames.Length);
         *
         *  MakeButtons(btnNames, selNoBtn);
         *  AddSound(icon);
         *
         *  form1.Show();
         * }
         * public static void ShowModal(string text, string head)
         * {
         *  form1.Dispose();
         *  form1 = new Form();
         *  InitializeComponent();
         *
         *  if (form1.ParentForm == null)
         *      form1.StartPosition = FormStartPosition.CenterScreen;
         *
         *  label1.Location = new Point(12, label1.Location.Y);
         *
         *  btnNames = AsignButtons(buttons);
         *
         *  form1.Text = head;
         *  label1.Text = text;
         *  FormAutoHeigh();
         *
         *  CenterButtons(btnNames.Length);
         *
         *  MakeButtons(btnNames, selNoBtn);
         *  AddSound(icon);
         *
         *  form1.Show();
         * }
         * public static void ShowModal(string text, string head, MessageBoxButtons buttons)
         * {
         *  form1.Dispose();
         *  form1 = new Form();
         *  InitializeComponent();
         *
         *  if (form1.ParentForm == null)
         *      form1.StartPosition = FormStartPosition.CenterScreen;
         *
         *  label1.Location = new Point(12, label1.Location.Y);
         *
         *  btnNames = AsignButtons(buttons);
         *
         *  form1.Text = head;
         *  label1.Text = text;
         *  FormAutoHeigh();
         *
         *  CenterButtons(btnNames.Length);
         *
         *  MakeButtons(btnNames, selNoBtn);
         *  AddSound(icon);
         *
         *  form1.Show();
         * }
         * public static void ShowModal(string text, string head, MessageBoxButtons buttons, MessageBoxIcon icon)
         * {
         *  form1.Dispose();
         *  form1 = new Form();
         *  InitializeComponent();
         *
         *  if (form1.ParentForm == null)
         *      form1.StartPosition = FormStartPosition.CenterScreen;
         *
         *  if (icon == MessageBoxIcon.None)
         *      label1.Location = new Point(12, label1.Location.Y);
         *
         *  btnNames = AsignButtons(buttons);
         *
         *  form1.Text = head;
         *  label1.Text = text;
         *  FormAutoHeigh();
         *
         *  CenterButtons(btnNames.Length);
         *
         *  MakeButtons(btnNames, selNoBtn);
         *  AddSound(icon);
         *
         *  form1.Show();
         * }
         * public static void ShowModal(string text, string head, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defBtn)
         * {
         *  form1.Dispose();
         *  form1 = new Form();
         *  InitializeComponent();
         *
         *  if (form1.ParentForm == null)
         *      form1.StartPosition = FormStartPosition.CenterScreen;
         *
         *  if (icon == MessageBoxIcon.None)
         *      label1.Location = new Point(12, label1.Location.Y);
         *
         *  btnNames = AsignButtons(buttons);
         *
         *
         *  form1.Text = head;
         *  label1.Text = text;
         *  FormAutoHeigh();
         *
         *  CenterButtons(btnNames.Length);
         *
         *  selNoBtn = int.Parse(defBtn.ToString()[defBtn.ToString().Length - 1].ToString());
         *
         *  MakeButtons(btnNames, selNoBtn);
         *  AddSound(icon);
         *
         *  form1.Show();
         * }
         * public static void ShowModal(IWin32Window owner, string text)
         * {
         *  form1.Dispose();
         *  form1 = new Form();
         *  InitializeComponent();
         *
         *  if (form1.ParentForm == null)
         *      form1.StartPosition = FormStartPosition.CenterParent;
         *
         *  label1.Location = new Point(12, label1.Location.Y);
         *
         *  btnNames = AsignButtons(buttons);
         *
         *  label1.Text = text;
         *  FormAutoHeigh();
         *
         *  CenterButtons(btnNames.Length);
         *
         *  MakeButtons(btnNames, selNoBtn);
         *  AddSound(icon);
         *
         *  try
         *  {
         *      if (((Form)owner).WindowState == FormWindowState.Minimized)
         *          ((Form)owner).WindowState = FormWindowState.Normal;
         *  }
         *  catch { }
         *
         *  form1.Show(owner);
         * }
         * public static void ShowModal(IWin32Window owner, string text, string head)
         * {
         *  form1.Dispose();
         *  form1 = new Form();
         *  InitializeComponent();
         *
         *  if (form1.ParentForm == null)
         *      form1.StartPosition = FormStartPosition.CenterParent;
         *
         *  label1.Location = new Point(12, label1.Location.Y);
         *
         *  btnNames = AsignButtons(buttons);
         *
         *  form1.Text = head;
         *  label1.Text = text;
         *  FormAutoHeigh();
         *
         *  CenterButtons(btnNames.Length);
         *
         *  MakeButtons(btnNames, selNoBtn);
         *  AddSound(icon);
         *
         *  try
         *  {
         *      if (((Form)owner).WindowState == FormWindowState.Minimized)
         *          ((Form)owner).WindowState = FormWindowState.Normal;
         *  }
         *  catch { }
         *
         *  form1.Show(owner);
         * }
         * public static void ShowModal(IWin32Window owner, string text, string head, MessageBoxButtons buttons)
         * {
         *  form1.Dispose();
         *  form1 = new Form();
         *  InitializeComponent();
         *
         *  if (form1.ParentForm == null)
         *      form1.StartPosition = FormStartPosition.CenterParent;
         *
         *  label1.Location = new Point(12, label1.Location.Y);
         *
         *  btnNames = AsignButtons(buttons);
         *
         *  form1.Text = head;
         *  label1.Text = text;
         *  FormAutoHeigh();
         *
         *  CenterButtons(btnNames.Length);
         *
         *  MakeButtons(btnNames, selNoBtn);
         *  AddSound(icon);
         *
         *  try
         *  {
         *      if (((Form)owner).WindowState == FormWindowState.Minimized)
         *          ((Form)owner).WindowState = FormWindowState.Normal;
         *  }
         *  catch { }
         *
         *  form1.Show(owner);
         * }
         * public static void ShowModal(IWin32Window owner, string text, string head, MessageBoxButtons buttons, MessageBoxIcon icon)
         * {
         *  form1.Dispose();
         *  form1 = new Form();
         *  InitializeComponent();
         *
         *  if (form1.ParentForm == null)
         *      form1.StartPosition = FormStartPosition.CenterParent;
         *
         *  if (icon == MessageBoxIcon.None)
         *      label1.Location = new Point(12, label1.Location.Y);
         *
         *  btnNames = AsignButtons(buttons);
         *
         *  form1.Text = head;
         *  label1.Text = text;
         *  FormAutoHeigh();
         *
         *  CenterButtons(btnNames.Length);
         *
         *  MakeButtons(btnNames, selNoBtn);
         *  AddSound(icon);
         *
         *  try
         *  {
         *      if (((Form)owner).WindowState == FormWindowState.Minimized)
         *          ((Form)owner).WindowState = FormWindowState.Normal;
         *  }
         *  catch { }
         *
         *  form1.Show(owner);
         * }
         * public static void ShowModal(IWin32Window owner, string text, string head, MessageBoxButtons buttons, MessageBoxIcon icon, MessageBoxDefaultButton defBtn)
         * {
         *  form1.Dispose();
         *  form1 = new Form();
         *  InitializeComponent();
         *
         *  if (form1.ParentForm == null)
         *      form1.StartPosition = FormStartPosition.CenterParent;
         *
         *  if (icon == MessageBoxIcon.None)
         *      label1.Location = new Point(12, label1.Location.Y);
         *
         *  btnNames = AsignButtons(buttons);
         *
         *
         *  form1.Text = head;
         *  label1.Text = text;
         *  FormAutoHeigh();
         *
         *  CenterButtons(btnNames.Length);
         *
         *  selNoBtn = int.Parse(defBtn.ToString()[defBtn.ToString().Length - 1].ToString());
         *
         *  MakeButtons(btnNames, selNoBtn);
         *  AddSound(icon);
         *
         *  try
         *  {
         *      if (((Form)owner).WindowState == FormWindowState.Minimized)
         *          ((Form)owner).WindowState = FormWindowState.Normal;
         *  }
         *  catch { }
         *
         *  form1.Show(owner);
         * }
         */
        #endregion

        // Events
        private static void MMessageBox_Load(object sender, EventArgs e)
        {
            if (form1.Owner != null)
            {
                Point oC  = new Point(form1.Owner.Location.X + (form1.Owner.Width / 2), form1.Owner.Location.Y + (form1.Owner.Height / 2));
                Point tC  = new Point((form1.Width / 2), (form1.Height / 2));
                Point loc = new Point(oC.X - tC.X, oC.Y - tC.Y);
                form1.Location = loc;
            }
            System.Media.SystemSound snd = sound;
            snd.Play();
        }
 public SecretDialog(Int32 Type, System.Media.SystemSound sound, String title, String message, Exception ex)
 {
     try
     {
         SoundToPlay = sound;
         InitializeComponent();
         if (!Properties.Settings.Default.ButterBoy)
         {
             if (Type == 0)
             {
                 CurrentIcon.Image = Properties.Resources.infoicon;
             }
             else if (Type == 1)
             {
                 CurrentIcon.Image = Properties.Resources.erroricon;
             }
             else
             {
                 CurrentIcon.Image = Properties.Resources.erroricon;
             }
         }
         else
         {
             if (Type == 0)
             {
                 CurrentIcon.Image = Properties.Resources.bbhappy;
             }
             else if (Type == 1)
             {
                 CurrentIcon.Image = Properties.Resources.bbcrying;
             }
             else
             {
                 CurrentIcon.Image = Properties.Resources.bbsad;
             }
         }
         Text             = String.Format("Keppy's Synthesizer - {0}", title);
         MessageText.Text = String.Format("{0}", message);
         try { DebugInfoText.Text = ex.ToString(); } catch { DebugInfo.Visible = false; DebugInfoText.Visible = false; }
     }
     catch (Exception ex2)
     {
         CurrentIcon.Image = Properties.Resources.wi;
         Text             = "Keppy's Synthesizer - Dialog error";
         MessageText.Text = "An unknown error has occurred while initializing the window.\nPlease try again later.\n\nPress OK to close this window.";
         Program.DebugToConsole(true, MessageText.Text, ex2);
     }
 }
Exemple #8
0
        private ResponseOptions GetResponses()
        {
            System.Media.SystemSound sound = null;
            string email = null;

            #region Assign the system sound.
            if (ckPlaySysSound.Checked)
            {
                switch (cboSounds.SelectedItem.ToString())
                {
                case "Asterisk":
                    sound = System.Media.SystemSounds.Asterisk;
                    break;

                case "Beep":
                    sound = System.Media.SystemSounds.Beep;
                    break;

                case "Exclamation":
                    sound = System.Media.SystemSounds.Exclamation;
                    break;

                case "Hand":
                    sound = System.Media.SystemSounds.Hand;
                    break;

                case "Question":
                    sound = System.Media.SystemSounds.Question;
                    break;

                default:
                    break;
                }
            }
            #endregion

            if (ckSendEmail.Checked)
            {
                email = txtEmail.Text;
            }

            return(new ResponseOptions(sound, email, scd.ConnectionStringBuilder));
        }
Exemple #9
0
        public SecretDialog(Int32 Type, System.Media.SystemSound sound, String title, String message, Exception ex)
        {
            try
            {
                SoundToPlay = sound;
                InitializeComponent();

                if (Type == 0)
                {
                    CurrentIcon.Image = Properties.Resources.infoicon;
                }
                else if (Type == 1)
                {
                    CurrentIcon.Image = Properties.Resources.erroricon;
                }
                else
                {
                    CurrentIcon.Image = Properties.Resources.erroricon;
                }

                Text             = String.Format("OmniMIDI - {0}", title);
                MessageText.Text = String.Format("{0}", message);
                try { DebugInfoText.Text = ex.ToString(); }
                catch
                {
                    ExGroup.Visible = false;
                    SaveLog.Visible = false;
                    Size            = new Size(444, 166);
                }
            }
            catch (Exception ex2)
            {
                CurrentIcon.Image = Properties.Resources.wi;
                Text             = "OmniMIDI - Dialog error";
                MessageText.Text = "An unknown error has occurred while initializing the window.\nPlease try again later.\n\nPress OK to close this window.";
                Program.DebugToConsole(true, MessageText.Text, ex2);
            }
        }
Exemple #10
0
 private static void AddSound(MessageBoxIcon icon)
 {
     switch (icon.ToString())
     {
         case "Asterisk":
             {
                 pictureBox1.Image = System.Drawing.SystemIcons.Asterisk.ToBitmap();
                 sound = System.Media.SystemSounds.Asterisk;
                 break;
             }
         case "Error":
             {
                 pictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
                 sound = System.Media.SystemSounds.Beep;
                 break;
             }
         case "Exclamation":
             {
                 pictureBox1.Image = System.Drawing.SystemIcons.Exclamation.ToBitmap();
                 sound = System.Media.SystemSounds.Exclamation;
                 break;
             }
         case "Hand":
             {
                 pictureBox1.Image = System.Drawing.SystemIcons.Hand.ToBitmap();
                 sound = System.Media.SystemSounds.Exclamation;
                 break;
             }
         case "Information":
             {
                 pictureBox1.Image = System.Drawing.SystemIcons.Information.ToBitmap();
                 sound = System.Media.SystemSounds.Exclamation;
                 break;
             }
         case "None":
             {
                 sound = System.Media.SystemSounds.Asterisk;
                 break;
             }
         case "Question":
             {
                 pictureBox1.Image = System.Drawing.SystemIcons.Question.ToBitmap();
                 sound = System.Media.SystemSounds.Question;
                 break;
             }
         case "Stop":
             {
                 pictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
                 sound = System.Media.SystemSounds.Hand;
                 break;
             }
         case "Warning":
             {
                 pictureBox1.Image = System.Drawing.SystemIcons.Warning.ToBitmap();
                 sound = System.Media.SystemSounds.Asterisk;
                 break;
             }
     }
 }
Exemple #11
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());
        }
 public void PlaySystemSound(System.Media.SystemSound systemSound)
 {
 }
Exemple #13
0
        private static void AddSound(MessageBoxIcon icon)
        {
            switch (icon.ToString())
            {
            case "Asterisk":
            {
                pictureBox1.Image = System.Drawing.SystemIcons.Asterisk.ToBitmap();
                sound             = System.Media.SystemSounds.Asterisk;
                break;
            }

            case "Error":
            {
                pictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
                sound             = System.Media.SystemSounds.Beep;
                break;
            }

            case "Exclamation":
            {
                pictureBox1.Image = System.Drawing.SystemIcons.Exclamation.ToBitmap();
                sound             = System.Media.SystemSounds.Exclamation;
                break;
            }

            case "Hand":
            {
                pictureBox1.Image = System.Drawing.SystemIcons.Hand.ToBitmap();
                sound             = System.Media.SystemSounds.Exclamation;
                break;
            }

            case "Information":
            {
                pictureBox1.Image = System.Drawing.SystemIcons.Information.ToBitmap();
                sound             = System.Media.SystemSounds.Exclamation;
                break;
            }

            case "None":
            {
                sound = System.Media.SystemSounds.Asterisk;
                break;
            }

            case "Question":
            {
                pictureBox1.Image = System.Drawing.SystemIcons.Question.ToBitmap();
                sound             = System.Media.SystemSounds.Question;
                break;
            }

            case "Stop":
            {
                pictureBox1.Image = System.Drawing.SystemIcons.Error.ToBitmap();
                sound             = System.Media.SystemSounds.Hand;
                break;
            }

            case "Warning":
            {
                pictureBox1.Image = System.Drawing.SystemIcons.Warning.ToBitmap();
                sound             = System.Media.SystemSounds.Asterisk;
                break;
            }
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="sound">The system sound to be played when responding to an event.</param>
 public ResponseOptions(System.Media.SystemSound sound)
 {
     InitializeClass(sound, null, null);
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="sound">The system sound to be played when responding to an event.</param>
 /// <param name="emailAddress">Email address to send mail to when responding to an event.</param>
 /// <param name="csb">Connection to SQL for [msdb].[dbo].[sp_send_dbmail]</param>
 public ResponseOptions(System.Media.SystemSound sound, string emailAddress, SqlConnectionStringBuilder csb)
 {
     InitializeClass(sound, emailAddress, csb);
 }