private void btnLogIn_Click(object sender, EventArgs e) // בדיקה האם פרטי ההתחברות  של העובד נכונים
        {
            Workers[] worker = dataB.GetWorkerData();
            checkmanager = txtboxLogIn.Text;
            checkuser    = txtboxLogIn.Text;
            lblPasswordWarningMessage.Location = new Point(758, 717);
            int flag         = 0;             // משתנה עזר לבדיקה האם העובד נמצא במאגר העובדים
            int WorkerLength = worker.Length; //שומר את אורך רשימת העובדים

            if (txtboxPassword.Text == "")    // בדיקה שהזנו שם משתמש וגם סיסמא
            {
                MessageBox.Show("Please Enter A Password ", "Error");
                return;
            }

            if (WorkerLength > 0)//אם אורך רשימת העובדים גדול מ0
            {
                for (int i = 0; i < worker.Length; i++)
                {
                    if (txtboxLogIn.Text != "" && txtboxPassword.Text != "")
                    {
                        if (txtboxLogIn.Text.Equals(worker[i].Worker_UserName) && txtboxPassword.Text.Equals(worker[i].Worker_Password)) // בדיקה שהעובד שמנסה להתחבר קיים במאגר העובדים
                        {
                            flag = 1;
                        }
                    }
                }
            }
            if (flag == 1) // העובד קיים במאגר העובדים ולכן הוא יקבל גישה למערכת
            {
                player.SoundLocation = Application.StartupPath + @"\sound\access_granted.wav";
                player.Load();
                player.PlaySync();
                txtboxLogIn.Text       = "";
                txtboxPassword.Text    = "";
                this.Visible           = false;
                picboxBack.Visible     = false;
                txtboxPassword.Visible = false;
                btnLogIn.Visible       = false;
                frmPcStore pc = new frmPcStore();
                pc.Show();
            }

            else // העובד לא קיים במאגר העובדים ולכן הוא  לא יקבל גישה למערכת
            {
                player.SoundLocation = Application.StartupPath + @"\sound\access_denied.wav";
                player.Load();
                player.PlaySync();
                txtboxPassword.Text                 = "";
                lblPasswordWarningMessage.Text      = "                 Password Not Found , Please Try Again";
                lblPasswordWarningMessage.BackColor = Color.Transparent;
                lblPasswordWarningMessage.ForeColor = Color.Red;
                lblPasswordWarningMessage.Font      = new Font(lblPasswordWarningMessage.Font, FontStyle.Bold);
                lblPasswordWarningMessage.Font      = new Font("", 14);
                return;
            }
        }
		public static void Main()
		{
			var Error1 = File.ReadAllBytes("MySounds.WaveComponent/Error1.wav");
			var Error1Player = new SoundPlayer(new MemoryStream(Error1));

			Error1Player.PlaySync();
			Error1Player.PlaySync();
			Error1Player.PlaySync();

			Console.WriteLine("other projects: ");
			Console.WriteLine("# http://naudio.codeplex.com/sourcecontrol/changeset/view/28884?projectName=naudio#");

			Console.WriteLine();

			var MyContent = new MyContent();


			MyContent.WriteTo((sender, args) => ShowProperties((MyContent.WriteToArguments)args));

			Console.WriteLine();
			// you really should not use headphones with PC speakers

			TestMemoryStream();


			Console.ForegroundColor = ConsoleColor.Yellow;

			Action<string> f = logo;

			f("hi");

			Console.WriteLine("got music?");



			var a = WaveExampleType.ExampleSquareWave.ToSoundPlayer(68);
			var b = WaveExampleType.ExampleSawtoothWave.ToSoundPlayer(115);
			var c = WaveExampleType.ExampleSquareWave.ToSoundPlayer(168);

			a.PlaySync();
			a.Stream.WriteTo("a.wav");


			b.PlaySync();
			c.PlaySync();

			//b.Stream.WriteTo("b.wav");
			//c.Stream.WriteTo("c.wav");

			//return 0;
		}
Exemple #3
0
        static void Main(string[] args)
        {
            string soundFile = @"c:\Windows\Media\notify.wav";
            string message = "Time to make the donuts.";
            int minutes = 0;
            int count = 3;

            if (args.Length == 0)
                Console.WriteLine(usage);

            if (args.Length > 3 && File.Exists(args[3]))
                soundFile = args[3];

            if (args.Length > 2)
                Int32.TryParse(args[2], out count);

            if (args.Length > 1)
                message = args[1];

            if (args.Length > 0 && Int32.TryParse(args[0], out minutes))
                Thread.Sleep(minutes * 60 * 1000);

            ThreadPool.QueueUserWorkItem((state) =>
                {
                    using (SoundPlayer simpleSound = new SoundPlayer(soundFile))
                    {
                        for (int i = 0; i < count; i++)
                            simpleSound.PlaySync();
                    }

                });

            new Alert(message).ShowDialog();
        }
        // Conversion extracted from the sample voice_synthesis.cs (RSSDK\framework\CSharp\voice_synthesis.cs)
        // To understand a little bit more about the WAV file format, acess the following links: 
        //     - http://www-mmsp.ece.mcgill.ca/documents/AudioFormats/WAVE/WAVE.html
        //     - http://www.sonicspot.com/guide/wavefiles.html
        public static void Play(PXCMAudio.AudioData audioData, PXCMAudio.AudioInfo audioInfo) {
            using (var memoryStream = new MemoryStream()) {
                using (var bw = new BinaryWriter(memoryStream)) {
                    bw.Write(0x46464952);  // chunkIdRiff:'FFIR'
                    bw.Write(0);           // chunkDataSizeRiff
                    bw.Write(0x45564157);  // riffType:'EVAW'
                    bw.Write(0x20746d66);  // chunkIdFmt:' tmf'
                    bw.Write(0x12);        // chunkDataSizeFmt
                    bw.Write((short)1);         // compressionCode
                    bw.Write((short)audioInfo.nchannels);  // numberOfChannels
                    bw.Write(audioInfo.sampleRate);   // sampleRate
                    bw.Write(audioInfo.sampleRate * 2 * audioInfo.nchannels); // averageBytesPerSecond
                    bw.Write((short)(audioInfo.nchannels * 2));   // blockAlign
                    bw.Write((short)16);        // significantBitsPerSample
                    bw.Write((short)0);         // extraFormatSize
                    bw.Write(0x61746164);  // chunkIdData:'atad'
                    bw.Write(0);           // chunkIdSizeData

                    bw.Write(audioData.ToByteArray());
                    long pos = bw.Seek(0, SeekOrigin.Current);
                    bw.Seek(0x2a, SeekOrigin.Begin); // chunkDataSizeData
                    bw.Write((int)(pos - 46));
                    bw.Seek(0x04, SeekOrigin.Begin); // chunkDataSizeRiff
                    bw.Write((int)(pos - 8));
                    bw.Seek(0, SeekOrigin.Begin);

                    using (var soundPlayer = new SoundPlayer(memoryStream)) {
                        soundPlayer.PlaySync();
                    }
                }
            }
        }
Exemple #5
0
        static void Main(string[] args)
        {
            int randomSeconds = 0;
            bool isTimeProvided = false;

            int flag = 0;

            //default values for time start and end
            const int DEFAULT_RANGE_START = 1800000;  //30 minutes
            const int DEFAULT_RANGE_END = 2400000;  //40 minutes

            //time range variables
            int customStart = DEFAULT_RANGE_START;
            int customEnd = DEFAULT_RANGE_END;

            while(flag == 0)
            {

                //play sound
                var Player = new System.Media.SoundPlayer();
                Player.SoundLocation = @"D:\Programs\knmp_win\meow.wav";
                Player.PlaySync();

                //waits a random time within the specified range
                System.Threading.Thread.Sleep(Utility.Random(customStart, customEnd));

                //using System.Linq;
                //using System.Threading.Tasks;
            }
        }
Exemple #6
0
        public void playSecret()
        {
            var wavSecret = new System.Media.SoundPlayer();

            wavSecret.SoundLocation = @".\Secret.wav";
            wavSecret.PlaySync();
        }
Exemple #7
0
        static void Main(string[] args)
        {
            SoundPlayer myPlayer = new System.Media.SoundPlayer();

            myPlayer.SoundLocation = @"C:\1118.wav";
            myPlayer.PlaySync();
        }
        //public enum SoundFlags : int
        //{
        //    SND_SYNC = 0x0000,  /* play synchronously (default) */
        //    SND_ASYNC = 0x0001,  /* play asynchronously */
        //    SND_NODEFAULT = 0x0002,  /* silence (!default) if sound not found */
        //    SND_MEMORY = 0x0004,  /* pszSound points to a memory file */
        //    SND_LOOP = 0x0008,  /* loop the sound until next sndPlaySound */
        //    SND_NOSTOP = 0x0010,  /* don't stop any currently playing sound */
        //    SND_NOWAIT = 0x00002000, /* don't wait if the driver is busy */
        //    SND_ALIAS = 0x00010000, /* name is a registry alias */
        //    SND_ALIAS_ID = 0x00110000, /* alias is a predefined ID */
        //    SND_FILENAME = 0x00020000, /* name is file name */
        //    SND_RESOURCE = 0x00040004  /* name is resource name or atom */
        //}

        //[DllImport("winmm.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
        //static extern bool PlaySound(string pszSound, IntPtr hMod, SoundFlags sf);

        //[DllImport("winmm.dll")]
        //static extern bool PlaySound(string lpszName, int hModule, int dwFlags);

        static void PlaySound(string lpszName)
        {
            var player = new System.Media.SoundPlayer();

            player.SoundLocation = lpszName;
            player.PlaySync();
        }
Exemple #9
0
        public static void BeepBeep(int Amplitude, int Frequency, int Duration)
        {
            double A = ((Amplitude * (System.Math.Pow(2, 15))) / 1000) - 1;
            double DeltaFT = 2 * Math.PI * Frequency / 44100.0;

            int Samples = 441 * Duration / 10;
            int Bytes = Samples * 4;
            int[] Hdr = { 0X46464952, 36 + Bytes, 0X45564157, 0X20746D66, 16, 0X20001, 44100, 176400, 0X100004, 0X61746164, Bytes };
            using (MemoryStream MS = new MemoryStream(44 + Bytes))
            {
                using (BinaryWriter BW = new BinaryWriter(MS))
                {
                    for (int I = 0; I < Hdr.Length; I++)
                    {
                        BW.Write(Hdr[I]);
                    }
                    for (int T = 0; T < Samples; T++)
                    {
                        short Sample = System.Convert.ToInt16(A * Math.Sin(DeltaFT * T));
                        BW.Write(Sample);
                        BW.Write(Sample);
                    }
                    BW.Flush();
                    MS.Seek(0, SeekOrigin.Begin);
                    using (SoundPlayer SP = new SoundPlayer(MS))
                    {
                        SP.PlaySync();
                    }
                }
            }
        }
        static void Main(string[] args)
        {

            string[] soundUrls = new string[] {
                "http://www.wavsource.com/snds_2016-01-10_6357263721580594/movies/2001/disconnect_me.wav",
                "http://www.wavsource.com/snds_2016-01-10_6357263721580594/movies/star_trek/2needs_of_the_many.wav",
                "http://www.wavsource.com/snds_2016-01-10_6357263721580594/movies/terminator/t2_hasta_la_vista.wav"
            };

            Random rand = new Random();
            var sound = soundUrls[rand.Next(0, soundUrls.Length)];
            var playSound = new SoundPlayer(sound);


            try
            {
                playSound.PlaySync();
                Console.WriteLine();
                Console.ReadLine();
            }
            catch (WebException)
            {
                Console.WriteLine("Sorry, no available internet connection at this time");
                throw;
            }
            
        }
Exemple #11
0
 public void Play(string src)
 {
     using(SoundPlayer sp = new SoundPlayer(src)) {
         sp.PlaySync ();
         sp.Dispose ();
     }
 }
Exemple #12
0
        public void playUp()
        {
            var wavUp = new System.Media.SoundPlayer();

            wavUp.SoundLocation = @".\Up.wav";
            wavUp.PlaySync();
        }
Exemple #13
0
        public void playHey()
        {
            var wavHey = new System.Media.SoundPlayer();

            wavHey.SoundLocation = @".\Hey.wav";
            wavHey.PlaySync();
        }
Exemple #14
0
        private static void OnDraw(EventArgs args)
        {
            if (test > Game.Time) Drawing.DrawText(textx, texty, Color.Red, "MORE THAN ONE Enemy detected");
            if (dangers.pos.X == 0) return;
            if (dangers.time < Game.Time || (skip % 5 == 0 && dangers.pos.Distance(dangers.hero.Position) > range + 1000))
            {
                delay = 0;
                dangers.pos.X = 0;
            }
            string g = "";
            if (dangers.count) g = "MORE THAN ONE ";
            if ((int)(Game.Time * 2) % 2 == 1) Drawing.DrawText(textx, texty, Color.Red, g+"Enemy detected");
            Drawing.DrawCircle(dangers.pos, 1400, Color.Crimson);
            delay++;

                if (delay == 10 && sound.GetValue<Boolean>() && lastbeep < Game.Time)
                    ThreadPool.QueueUserWorkItem(ignoredState =>
                    {
                        lastbeep = Game.Time + lb.GetValue<Slider>().Value;
                        using (var player = new SoundPlayer(Resources.b))
                        {
                            player.PlaySync();
                        }
                    });
        }
Exemple #15
0
        public void playDown()
        {
            var wavDown = new System.Media.SoundPlayer();

            wavDown.SoundLocation = @".\Down.wav";
            wavDown.PlaySync();
        }
        public OpenPullRequestMonitor(TimeSpan timespan, ItemState state=ItemState.Open)
        {
            var pollingPeriod = timespan.TotalMilliseconds;
            _timer = new Timer(pollingPeriod) {AutoReset = true};
            _timer.Elapsed += (sender, eventArgs) =>
            {
                var prs = 0;
                Task.Run(async () =>
                {
                    var requests = await PollGitHub(state);
                    prs = requests.Count;
                    _pr = requests.FirstOrDefault();
                    Console.WriteLine("Polled PR count:" + prs);
                }).Wait();

                if (prs > OpenPrs)
                {
                    var soundPlayer = new SoundPlayer("fanfare3.wav");
                    soundPlayer.PlaySync();
                    if (_pr != null)
                    {
                        var speech = new SpeechSynthesizer();
                        speech.Speak("New pull request.");
                        speech.Speak(_pr.Title);
                    }

                    OpenPrs = prs;
                }
                else if (prs < OpenPrs)
                {
                    OpenPrs = prs;
                }
            };
        }
Exemple #17
0
        /// <summary>
        /// 播放叫号语音
        /// </summary>
        /// <param name="call_number">号码</param>
        /// <param name="service_num">服务窗口号</param>
        public void Call(string call_number, string service_num)
        {
            int iWinNum = 0;

            int.TryParse(service_num, out iWinNum); //窗口号转换成数字
            if (iWinNum == 10)                      //如果等于10
            {
                service_num = "X";
            }
            else if (iWinNum > 10 && iWinNum < 20)
            {
                service_num = "X" + iWinNum % 10; //语音十几
            }
            string code = "Q" + call_number + "M" + service_num + "H";

            code = code.ToUpper();
            foreach (var ch in code)
            {
                var file = findResource(ch);
                if (file != "")
                {
                    player.SoundLocation = file;
                    // player.Play();
                    player.PlaySync();
                    System.Threading.Thread.Sleep(_span);
                }
            }
        }
Exemple #18
0
        public async void playSound(int x)
        {
            try
            {
                CoffeeBackButton.Visible = false;
                await Task.Delay(0100);

                if (x == 1)
                {
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer(CoffeeMachine2._0.Properties.Resources.PouringDrinkSound1);
                    player.PlaySync();
                    ServingLable.Text        = "  Coffee is ready";
                    TakeCoffeeButton.Visible = true;
                }

                if (x == 2)
                {
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer(CoffeeMachine2._0.Properties.Resources.PourGlassWaterSound);
                    player.PlaySync();
                    ServingLable.Text        = "  Drink is ready";
                    TakeCoffeeButton.Visible = true;
                }
                if (x == 3)
                {
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer(CoffeeMachine2._0.Properties.Resources.PouringHotTea);
                    player.PlaySync();
                    ServingLable.Text        = "  Drink is ready";
                    TakeCoffeeButton.Visible = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemple #19
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(richTextBox1.Text))
            {
                MessageBox.Show("DEBE LLENAR EL CAMPO CON POR LO MENOS UN NUMERO", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            String letras = "";

            String[] split = trad_txt.Text.Split(' ');


            System.Media.SoundPlayer sound = new System.Media.SoundPlayer();



            for (int i = 0; i < split.Length; i++)
            {
                letras = @"C:\Users\lenovo\Documents\Sound recordings\Numeros\" + split[i] + ".wav";


                sound.SoundLocation = letras;

                sound.PlaySync();
            }
        }
Exemple #20
0
        public void playListen()
        {
            var wavListen = new System.Media.SoundPlayer();

            wavListen.SoundLocation = @".\Listen.wav";
            wavListen.PlaySync();
        }
Exemple #21
0
        // Överskuggar basklassens version av MakeNoise med en egen.
        public override void MakeNoise()
        {
            SoundPlayer sp = new SoundPlayer(@"..\..\Sound\Wolf.wav");

            Console.Write("En varg...");
            sp.PlaySync();
            Console.WriteLine("...ylar");
        }
 /// <summary>
 /// Function in <see cref="GPIOPin"/> to play a sound.
 /// </summary>
 /// <param name="pin">The Pin of the Buzzer (GPIO PIN!)</param>
 /// <param name="duration">The time how long a single tone should last for.</param>
 /// <param name="repeats">The humber of repeats</param>
 public static void playsound(int repeats)
 {
     for(int i=0;i<repeats;i++)
     {
         SoundPlayer sp = new SoundPlayer(System.IO.Directory.GetCurrentDirectory() + "/beep.wav");
         sp.PlaySync();
     }
 }
Exemple #23
0
 static void Main(string[] args)
 {
     using (var file = new FileStream(args[0], FileMode.Open, FileAccess.Read))
     {
         var player = new SoundPlayer(new OggDecodeStream(file));
         player.PlaySync();
     }
 }
Exemple #24
0
 static void Play(string path)
 {
     using (var file = new FileStream(path, FileMode.Open, FileAccess.Read))
     {
         var player = new SoundPlayer(new OggDecodeStream(file));
         player.PlaySync();
     }
 }
Exemple #25
0
        // Överskuggar basklassens version av MakeNoise med en egen.
        public override void MakeNoise()
        {
            SoundPlayer sp = new SoundPlayer(@"..\..\Sound\CatMeow.wav");

            Console.Write("En katt säger...");
            sp.PlaySync();
            Console.WriteLine("...mjau");
        }
Exemple #26
0
 public void ProduceSound()
 {
     using (SoundPlayer s = new SoundPlayer())
     {
         s.SoundLocation = "Sounds/dog_bark_x.wav";
         s.PlaySync();
     }
 }
Exemple #27
0
 public void ProduceSound()
 {
     using (SoundPlayer s = new SoundPlayer())
     {
         s.SoundLocation = "Sounds/cat_growl.wav";
         s.PlaySync();
     }
 }
Exemple #28
0
        // Överskuggar basklassens version av MakeNoise med en egen.
        public override void MakeNoise()
        {
            SoundPlayer sp = new SoundPlayer(@"..\..\Sound\DogBark.wav");

            Console.Write("En hund...");
            sp.PlaySync();
            Console.WriteLine("...skäller");
        }
Exemple #29
0
        // Överskuggar basklassens version av MakeNoise med en egen.
        public override void MakeNoise()
        {
            SoundPlayer sp = new SoundPlayer(@"..\..\Sound\Tiger.wav");

            Console.Write("En tiger...");
            sp.PlaySync();
            Console.WriteLine("...ryter");
        }
Exemple #30
0
        // Överskuggar basklassens version av MakeNoise med en egen.
        public override void MakeNoise()
        {
            SoundPlayer sp = new SoundPlayer(@"..\..\Sound\LionRoar.wav");

            Console.Write("Ett lejon...");
            sp.PlaySync();
            Console.WriteLine("...ryter");
        }
 private static void doMusic()
 {
     using (SoundPlayer player = new SoundPlayer("../../Spooky Music Instrumental - Twilight Hollow.wav"))
     {
         // Use PlaySync to load and then play the sound.
         // ... The program will pause until the sound is complete.
         player.PlaySync();
     }
 }
Exemple #32
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     SoundPlayer sp = new SoundPlayer("Resources\\s.wav");
     lblPlayer.Text = "";
     lbl1.Text = "Время вышло!!!";
     sp.PlaySync();
     btnYes.DialogResult = DialogResult.No;
     timer1.Stop();
 }
Exemple #33
0
 static void Main(string[] args)
 {
     using (var file = new FileStream("audio.wav",
         FileMode.Open, FileAccess.Read, FileShare.Read))
     {
         var player = new SoundPlayer(file);
         player.PlaySync();
     }
 }
Exemple #34
0
        private async void PlaySoundAsync(string filename)
        {
            using (var player = new System.Media.SoundPlayer(filename))
            {
                await Task.Run(() => { player.Load(); player.PlaySync(); });

                IsSoundPlaying = false;
            }
        }
 public void Play(string resourcesPlayPoliceSWav)
 {
     using (var file = new FileStream(resourcesPlayPoliceSWav, FileMode.Open, FileAccess.Read))
     {
         using (var player = new SoundPlayer(file))
         {
             player.PlaySync();
         }
     }
 }
        public void PlayOnce(string file)
        {
            if (_alarmSound == null)
            {
                _playingOnce = true;
                _alarmSound = new SoundPlayer(file);
                _alarmSound.PlaySync();
                _alarmSound = null;

            }
        }
Exemple #37
0
 private static bool PlaySingleSound(string path)
 {
     try
     {
         var ply = new System.Media.SoundPlayer(path);
         ply.PlaySync();
     }
     catch (Exception e)
     {  MessageBox.Show(e.Message, "音の再生に失敗しました");  return false; }
     return(true);
 }
Exemple #38
0
        /// <summary>
        /// if run as sudo, the SSH session hangs and eed to start a new one. 
        /// </summary>
        public void PlayWithSoundPlayer()
        {

            //using (var file = new FileStream(WavFile, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                Log.Info(m => m("SoundPlayer Sync: {0}", WavFile));
                var player = new SoundPlayer();
                player.SoundLocation = WavFile;
                player.PlaySync();
            }
        }
Exemple #39
0
        private void button2_Click(object sender, EventArgs e)
        {
            //Stopwatch sw = new Stopwatch();
            //sw.Start();
            //获取声调名称
            int toneindex = listBox1.SelectedIndex;

            if (toneindex < 0)
            {
                return;
            }
            string tonename = sounds[toneindex].name;
            double pitch    = sounds[toneindex].pitch;

            pitch = SemitoneTransfer.getTN(pitch);

            //获取声调包络
            int pit     = int.Parse(numericUpDown1.Value.ToString());
            var pitdata = getZipDatas(pit);

            //获取长度比例
            int len = int.Parse(numericUpDown2.Value.ToString());

            //初始化音调信息
            //NNTone tmp = sounds[toneindex];
            //int begin = tmp.begin;
            //int length = tmp.length;
            //int head = tmp.inibegin;
            //int foot = tmp.tailbegin;
            //double rbegin = double.Parse(textBox7.Text);
            //double rend = double.Parse(textBox8.Text);

            //合成

            SynTone synt = new SynTone(tonename, pitdata, len, new double[] { 1 }, 0, pitch);

            int[] res = sa.getSoundTone(synt);
            this.pictureBox2.Image = getPPImage(res);
            //this.pictureBox4.Image = getFFTImage(res);
            //sw.Stop();
            //sw = new Stopwatch();
            //sw.Start();
            WAVControl.writeWAV(res, outputTone);

            //播放合成结果wav
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(outputTone);
            player.PlaySync();

            //sw.Stop();
            //double tbegin = double.Parse(textBox5.Text);
            //double tend = double.Parse(textBox6.Text);
            //pictureBox2.Image = getImage(outputTone, tbegin, tend);
            //pictureBox4.Image = getFFTImage(SoundAnalysis.getSample(outputTone));
        }
Exemple #40
0
        public void Play(SoundPlayer player)
        {
           playing = true;

            new Thread(new ParameterizedThreadStart(
                delegate
                {
                    player.PlaySync();
                    playing = false;
                }
                )).Start();
        }
Exemple #41
0
 static void Main(string[] args)
 {
     int n = args.Length;
     if (n < 1)
     {
         Console.WriteLine("Usage: wavplayer wavfile");
     }
     else
     {
         SoundPlayer wavePlayer = new SoundPlayer(args[0]);
         wavePlayer.PlaySync();
     }
 }
        static void Main(string[] args)
        {
            mciSendString("open new Type waveaudio Alias recsound", "", 0, 0);
            mciSendString("record recsound", "", 0, 0);
            Console.WriteLine("recording, press Enter to stop and save ...");
            Console.ReadLine();

            mciSendString("save recsound C:/result.wav", "", 0, 0);
            mciSendString("close recsound ", "", 0, 0);

            System.Media.SoundPlayer player = new System.Media.SoundPlayer("C:\\result.wav");
            player.PlaySync();
        }
        public void playMenuSound()
        {
            player = new SoundPlayer(menuUri);
            player.Load();

            bool soundFinished = true;

            if (soundFinished)
            {
                soundFinished = false;
                Task.Factory.StartNew(() => { player.PlaySync(); soundFinished = true; });
            }
        }
    static void Main()
    {
        // Create new SoundPlayer in the using statement.
        using (SoundPlayer player = new SoundPlayer("C:\\Sound.wav"))
        {
            // Use PlaySync to load and then play the sound.
            // ... The program will pause until the sound is complete.
            player.PlaySync();
        }
        FileStream fs = new FileStream(@"c:\Sound2.wav", FileMode.Open, FileAccess.Read);

        System.Media.SoundPlayer sp = new System.Media.SoundPlayer(fs);
        sp.PlaySync();
    }
        public static void CommandHandler(object sender, ExecutedRoutedEventArgs ea)
        {
            ea.Handled = true;
            if (Settings.Default.Chirp == false || _playing) return;

            _playing = true;
            Task.Run(() =>
            {
                var player = new SoundPlayer {Stream = Resources.Notify};
                player.PlaySync();
                Thread.Sleep(200);
                _playing = false;
            }).LogAggregateExceptions();
        }
        public void Play(WaveAudio a, bool bAsync)
        {
            m = new MemoryStream();
            bw = new BinaryWriter(m);
            a.SaveWaveFile(bw);

            SoundPlayer pl = new SoundPlayer(m);
            pl.Stream.Position = 0; // This line is necessary 
           
            if (bAsync)
                pl.Play();
            else
                pl.PlaySync();
        }
Exemple #47
0
        private void BootLogo_Load(object sender, EventArgs e)
        {
            this.Focus();
            //add this to the medai player

            //pictureBox1.Image = MakeTransparentGif(Properties.Resources.PS2_Logo, Color.Black);
            //pictureBox1.Image = MakeTransparentGif(Properties.Resources.PS2_Logo, Color.Gray);
            new Thread(() =>
            {
                System.IO.Stream str         = Properties.Resources.BootLogo;
                System.Media.SoundPlayer snd = new System.Media.SoundPlayer(str);
                snd.PlaySync();

                this.Invoke(new Action(() => this.Close()));
            }).Start();
        }
Exemple #48
0
 public void Play(bool async = false)
 {
     try
     {
         if (async)
         {
             audioPlayer.Play();
         }
         else
         {
             audioPlayer.PlaySync();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine("An error occured: {0}", e);
     }
 }
Exemple #49
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (radioButton1.Checked == true)
     {
         Console.Beep(350, 500);
     }
     if (radioButton2.Checked == true)
     {
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.F);
         player.Load();
         player.PlaySync();
     }
     if (radioButton3.Checked == true)
     {
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.F_Drum);
         player.Load();
         player.PlaySync();
     }
 }
Exemple #50
0
 /* Functionality for Upper C note */
 private void button8_Click(object sender, EventArgs e)
 {   /* Console Note Sound */
     if (radioButton1.Checked)
     {
         Console.Beep(600, 500);
     }
     /* Music Note Sound */
     if (radioButton2.Checked)
     {
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.C1);
         player.Load();
         player.PlaySync();
     }
     /* Steel Drum Sound */
     if (radioButton4.Checked)
     {
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.C1_Drum);
         player.Load();
         player.PlaySync();
     }
 }
Exemple #51
0
        /// <summary>
        /// This method is called once the audio returned from the service.
        /// It will then attempt to play that audio file.
        /// Note that the playback will fail if the output audio format is not pcm encoded.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="args">The <see cref="GenericEventArgs{Stream}"/> instance containing the event data.</param>
        ///
        // readStream is the stream you need to read
        // writeStream is the stream you want to write to

        private void PlayAudio(object sender, GenericEventArgs <Stream> args)
        {
            Stream readStream = args.EventData;

            try
            {
                string saveTo = Path.GetDirectoryName(Application.ExecutablePath) + @"\SaveMP3File";                  //Folder to Save
                if (!Directory.Exists(saveTo))
                {
                    Directory.CreateDirectory(saveTo);
                }
                string filename = saveTo + @"\Shanu" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".mp3";                 //Save the speech as mp3 file in root folder

                FileStream writeStream = File.Create(filename);

                int    Length      = 256;
                Byte[] buffer      = new Byte[Length];
                int    bytestoRead = readStream.Read(buffer, 0, Length);
                // write the required bytes
                while (bytestoRead > 0)
                {
                    writeStream.Write(buffer, 0, bytestoRead);
                    bytestoRead = readStream.Read(buffer, 0, Length);
                }

                readStream.Close();
                writeStream.Close();
                SoundPlayer player = new System.Media.SoundPlayer(filename);
                player.PlaySync();
            }
            catch (Exception EX)
            {
                txtstatus.Text = EX.Message;
            }
            args.EventData.Dispose();
        }
Exemple #52
0
        static void Main(string[] args)
        {
            string m_start;
            string m_mission;

            //string m_trans;
            //string m_option;

            Console.Title = "King of Battle!!!"; //Labels the title of the Window to King of Balltle!!!


            string t1 = "╔═════════════════════════════════════════════════════════╗";
            string t2 = "║  *****   *******  ***         *        ******* ******** ║";
            string t3 = "║  *    *  *        *   *       *        *       *        ║";
            string t4 = "║  *    *  ******   *    *      *        *****   *        ║";
            string t5 = "║  *****   *        *    *      *        *       *   **** ║";
            string t6 = "║  *    *  *        *   *       *        *       *      * ║";   //creates title screen
            string t7 = "║  *     * *******  ***         ******** ******* ******** ║";
            string t8 = "╚═════════════════════════════════════════════════════════╝";
            string s1 = "King of Battle!!!"; // subtitle


            Console.BackgroundColor = ConsoleColor.DarkRed; // changes title on screen to artillery colors
            Console.ForegroundColor = ConsoleColor.DarkYellow;



            Console.SetCursorPosition((Console.WindowWidth - t1.Length) / 2, Console.CursorTop);  // centers and writes title screen
            Console.WriteLine(t1);
            Console.SetCursorPosition((Console.WindowWidth - t2.Length) / 2, Console.CursorTop);
            Console.WriteLine(t2);
            Console.SetCursorPosition((Console.WindowWidth - t3.Length) / 2, Console.CursorTop);
            Console.WriteLine(t3);
            Console.SetCursorPosition((Console.WindowWidth - t4.Length) / 2, Console.CursorTop);
            Console.WriteLine(t4);
            Console.SetCursorPosition((Console.WindowWidth - t5.Length) / 2, Console.CursorTop);
            Console.WriteLine(t5);
            Console.SetCursorPosition((Console.WindowWidth - t6.Length) / 2, Console.CursorTop);
            Console.WriteLine(t6);
            Console.SetCursorPosition((Console.WindowWidth - t7.Length) / 2, Console.CursorTop);
            Console.WriteLine(t7);
            Console.SetCursorPosition((Console.WindowWidth - t8.Length) / 2, Console.CursorTop);
            Console.WriteLine(t8);


            Console.SetCursorPosition((Console.WindowWidth - s1.Length) / 2, Console.CursorTop);  // centers and writes subtitle
            Console.WriteLine(s1);


            Console.BackgroundColor = ConsoleColor.Black; // changes back to default colors
            Console.ForegroundColor = ConsoleColor.White;

            StartMenu();

            void StartMenu()
            {
                string m1 = "ENTER:(1) | Exit:(2)";                                                  // subtitle menu text

                Console.SetCursorPosition((Console.WindowWidth - m1.Length) / 2, Console.CursorTop); // centers and writes subtitle menu text
                Console.WriteLine(m1);

                m_start = Console.ReadLine();

                switch (m_start) // provides argument to start or exit

                {
                case "1":     // if user input == "1" then start method is called

                    Intro();

                    break;

                case "2":    // if user input == "2" then exit method is called

                    Exit();

                    break;

                default:

                    Console.WriteLine($"Standing orders are press 1 to enter or 2 to exit!");     // default message displayed when user input does not follow instructions

                    break;
                }
            }

            void Exit()
            {
                Environment.Exit(0);
            }

            void Intro()
            {
                string i1  = "╔═════════════════════╗";
                string i2  = "║                     ║";
                string i3  = "║ CHOOSE YOUR MISSION ║";
                string i4  = "║                     ║";   //  ┌  └    ┬    ─    ┤    ┼     ├     ┐╟╟│   ┐  └  ┘
                string i5  = "╚═════════════════════╝";
                string i6  = "┌─────────────────────┐";
                string i7  = "│ Air Assault Raid(1) │";
                string i8  = "├─────────────────────┤";
                string i9  = "│  Fire For Effect(2) │";
                string i10 = "└─────────────────────┘";


                Console.BackgroundColor = ConsoleColor.DarkRed; // changes Intro Menu to artillery colors
                Console.ForegroundColor = ConsoleColor.DarkYellow;



                Console.SetCursorPosition((Console.WindowWidth - i1.Length) / 2, Console.CursorTop);  // centers and writes intro menu
                Console.WriteLine(i1);
                Console.SetCursorPosition((Console.WindowWidth - i2.Length) / 2, Console.CursorTop);
                Console.WriteLine(i2);
                Console.SetCursorPosition((Console.WindowWidth - i3.Length) / 2, Console.CursorTop);
                Console.WriteLine(i3);
                Console.SetCursorPosition((Console.WindowWidth - i4.Length) / 2, Console.CursorTop);
                Console.WriteLine(i4);
                Console.SetCursorPosition((Console.WindowWidth - i5.Length) / 2, Console.CursorTop);
                Console.WriteLine(i5);
                Console.SetCursorPosition((Console.WindowWidth - i6.Length) / 2, Console.CursorTop);
                Console.WriteLine(i6);
                Console.SetCursorPosition((Console.WindowWidth - i7.Length) / 2, Console.CursorTop);
                Console.WriteLine(i7);
                Console.SetCursorPosition((Console.WindowWidth - i8.Length) / 2, Console.CursorTop);
                Console.WriteLine(i8);
                Console.SetCursorPosition((Console.WindowWidth - i9.Length) / 2, Console.CursorTop);
                Console.WriteLine(i9);
                Console.SetCursorPosition((Console.WindowWidth - i10.Length) / 2, Console.CursorTop);
                Console.WriteLine(i10);


                Console.BackgroundColor = ConsoleColor.Black; // changes console back to default colors
                Console.ForegroundColor = ConsoleColor.White;

                m_mission = Console.ReadLine();

                switch (m_mission)
                {
                case ("1"):

                    Aaslt();


                    break;

                case ("2"):

                    FireMission();

                    break;

                default:

                    Console.WriteLine("Standing Orders are Press (1) for Air Assault or (2) for Fire For Effect");
                    break;
                }
            }

            void Aaslt()
            {
                var myPlayer = new System.Media.SoundPlayer();

                myPlayer.SoundLocation = @"C:\Users\micha\source\repos\exercise6MilitaryUnit\exercise6MilitaryUnit\Resources\helicopter.wav";
                myPlayer.PlaySync();

                Console.WriteLine();

                Soldier Pilots = new Soldier();      //CREATES NEW PILOTS

                Pilots.Loading("Pilot Loaded");      //PILOTS LOADING INTO HELICOPTER

                Helicopter UH60s = new Helicopter(); //CREATES UH60S

                UH60s.StartEngine("WOP WOP WOP");

                UH60s.Land();                    //HELICOPTERS LAND FOR PERSONNELL PICK UP

                Soldier RedLegs = new Soldier(); //CREATES ADVANCE PARTY

                RedLegs.Loading("Advance Party Loads The Bird");

                UH60s.Hover();                         //HELICOPTERS HOVER OVER LOADS

                Equipment A22bags   = new Equipment(); //CREATES A22 BAGS TO CARRY AMMO
                Weapons   Howitzers = new Weapons();   //CREATES GUNS

                UH60s.Loading("Hooking Up Guns And Equipment");
                UH60s.Unloading("Dropping Equipment");
                UH60s.Land();

                RedLegs.Unloading("Derigging Guns And Placing Into Action!");

                UH60s.StopEngine("Buuuuurrrrrrr");

                Soldier FO = new Soldier();

                FO.Cff();

                Soldier FDC = new Soldier();

                FDC.Compute();
                FDC.Transmit();


                Soldier Gunline = new Soldier();

                Gunline.Loading("C L A N K");
                Gunline.Ready();
                FO.Fire();

                var myPlayer2 = new System.Media.SoundPlayer();

                myPlayer.SoundLocation = @"C:\Users\micha\source\repos\exercise6MilitaryUnit\exercise6MilitaryUnit\Resources\Boom.wav";
                myPlayer.PlaySync();
            }

            void FireMission()
            {
                Console.WriteLine();

                Soldier FO = new Soldier();

                FO.Cff();

                Soldier FDC = new Soldier();

                FDC.Compute();
                FDC.Transmit();


                Soldier Gunline = new Soldier();

                Gunline.Loading("C L A N K");
                Gunline.Ready();
                FO.Fire();

                var myPlayer = new System.Media.SoundPlayer();

                myPlayer.SoundLocation = @"C:\Users\micha\source\repos\exercise6MilitaryUnit\exercise6MilitaryUnit\Resources\Boom.wav";
                myPlayer.PlaySync();
            }
        }
        private void btn_Check_Click(object sender, EventArgs e)
        {
            Regex Digital = new Regex("^[0-9]{1,}$"); //正则表达式 表示数字的范围 ^符号是开始,$是关闭

            if (string.IsNullOrEmpty(txt_NumOrName.Text) || !sgClass.DbHelperSQL.Exists("select * from [user] where ID='" + txt_NumOrName.Text + "' or Name='" + txt_NumOrName.Text + "'"))
            {
                try
                {
                    SoundPlayer sndPlayer = new System.Media.SoundPlayer(Application.StartupPath + @"\sound\NumOrName_Null.wav");
                    sndPlayer.Play();
                    MessageBox.Show("工号或姓名不存在!");
                    txt_NumOrName.Text = "";
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                string ID    = null;
                string Sound = null;
                //string btnTime = null;

                //DateTime dt1, dt2;
                //TimeSpan ts;

                if (Digital.IsMatch(txt_NumOrName.Text.Trim()))
                {
                    ID = txt_NumOrName.Text.Trim();
                }
                else
                {
                    ID = sgClass.DbHelperSQL.Query("select ID from [user] where Name='" + txt_NumOrName.Text.Trim() + "'").Tables[0].Rows[0][0].ToString();
                }


                try
                {
                    Sound = sgClass.DbHelperSQL.Query("select Sound from [user] where ID=" + ID).Tables[0].Rows[0][0].ToString();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }

                string sqlIn = "insert into [check](checkDate,ID,checkContent) values(@checkDate,@ID,@checkContent)";
                string sqlUp = "update [check] set checkContent=checkContent+';'+@checkContent where checkDate=@checkDate and ID=@ID";

                SqlParameter[] sp = new SqlParameter[]
                {
                    new SqlParameter("@checkDate", System.DateTime.Now.ToShortDateString()),
                    new SqlParameter("@ID", ID),
                    new SqlParameter("@checkContent", System.DateTime.Now.ToString())
                };

                if (sgClass.DbHelperSQL.Exists("select * from [check] where checkDate='" + System.DateTime.Now.ToShortDateString() + "' and ID='" + ID + "'"))
                {
                    string CheckContent = sgClass.DbHelperSQL.Query("select checkContent from [check] where checkDate='" + System.DateTime.Now.ToShortDateString() + "' and ID='" + ID + "'").Tables[0].Rows[0][0].ToString();

                    int CheckCount = CheckContent.Split(new string[] { ";" }, StringSplitOptions.None).Length + 1;

                    string sMes = sgClass.DbHelperSQL.ExecuteSql(sqlUp, sp);
                    if (sMes == "1")
                    {
                        labNote.Text = "工号" + ID + "当日第" + CheckCount + "次考勤,考勤时间:" + System.DateTime.Now.ToString();
                        string[] wav = new string[] { Sound, "WorkNum.wav", "Num" + ID + ".wav", "CheckSusscess.wav" };
                        for (int i = 0; i < wav.Length; i++)
                        {
                            try
                            {
                                SoundPlayer sndPlayer = new System.Media.SoundPlayer(Application.StartupPath + @"\sound\" + wav[i] + "");
                                sndPlayer.PlaySync();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.ToString());
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(sMes);
                    }
                }
                else
                {
                    string sMes = sgClass.DbHelperSQL.ExecuteSql(sqlIn, sp);
                    if (sMes == "1")
                    {
                        labNote.Text = "工号" + ID + "当日第1次考勤,考勤时间:" + System.DateTime.Now.ToString();
                        string[] wav = new string[] { Sound, "WorkNum.wav", "Num" + ID + ".wav", "CheckSusscess.wav" };
                        for (int i = 0; i < wav.Length; i++)
                        {
                            try
                            {
                                SoundPlayer sndPlayer = new System.Media.SoundPlayer(Application.StartupPath + @"\sound\" + wav[i] + "");
                                sndPlayer.PlaySync();
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.ToString());
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show(sMes);
                    }
                }
            }
            txt_NumOrName.Text = string.Empty;
        }
Exemple #54
0
        static void callTime(int t)
        {
            //    .Show("got here11111111");
            System.Media.SoundPlayer pl = new System.Media.SoundPlayer();
            int  count = 0;
            bool tens = false, and = false, much = false;

            if (t == 0)
            {
                pl.SoundLocation = "עכשיו";
            }
            else
            {
                pl.SoundLocation = "בעוד.wav";
            }
            pl.PlaySync();
            switch (t / 10)
            {
            case 1:
                //      .Show("got here");5
                //       pl.SoundLocation = "עשר.wav";
                //      .Show("got here");
                //     pl.PlaySync();
                tens = true;
                break;

            case 2:
                // .Show("got here");
                pl.SoundLocation = "עשרים.wav"; //11 and 1
                pl.PlaySync();                  //2
                much = true;
                and  = true;
                break;

            case 3:
                //  .Show("got here");
                pl.SoundLocation = "שלושים.wav"; //11 and 1
                pl.PlaySync();                   //3
                much = true;
                and  = true;
                break;

            case 4:
                //    .Show("got here");
                pl.SoundLocation = "ארבעים.wav"; //11 and 1
                pl.PlaySync();                   //4
                much = true;
                and  = true;
                break;

            case 5:
                //  .Show("got here");
                pl.SoundLocation = "חמישים.wav"; //11 and 1
                pl.PlaySync();                   //5
                much = true;
                and  = true;
                break;

            case 6:
                // .Show("got here");
                pl.SoundLocation = "שישים.wav"; //11 and 1
                pl.PlaySync();                  //6
                much = true;
                and  = true;
                break;

            case 7:
                pl.SoundLocation = "שבעים.wav"; //11 and 1
                pl.PlaySync();                  //7
                and  = true;
                much = true;
                break;

            case 8:
                pl.SoundLocation = "שמונים.wav"; //11 and 1
                pl.PlaySync();                   //8
                much = true;
                and  = true;
                break;

            case 9:
                pl.SoundLocation = "תשעים.wav"; //11 and 1
                pl.PlaySync();                  //9
                much = true;
                and  = true;
                break;

            default:
                break;
            }
            if (and)
            {
                pl.SoundLocation = "ו.wav";
            }
            else
            {
                pl.SoundLocation = "_.wav";
            }
            switch (t % 10)
            {
            case 1:
                pl.PlaySync();
                //   .Show("got here");
                if (!and && !tens)
                {
                    pl.SoundLocation = "דקה.wav";    //daka
                    pl.PlaySync();
                }
                pl.SoundLocation = tens ? "אחת עשרה.wav" : "אחת.wav";    //11 and 1
                pl.PlaySync();
                break;

            case 2:
                pl.PlaySync();
                // .Show("got here");
                pl.SoundLocation = tens ? "שתיים עשרה.wav" :and? "שתיים.wav":"שתי.wav"; //11 and 1
                pl.PlaySync();                                                          //2
                much = true;
                break;

            case 3:
                pl.PlaySync();
                //  .Show("got here");
                pl.SoundLocation = tens ? "שלוש עשרה.wav" : "שלוש.wav"; //11 and 1
                pl.PlaySync();                                          //3
                much = true;
                break;

            case 4:
                pl.PlaySync();
                //    .Show("got here");
                pl.SoundLocation = tens ? "ארבע עשרה.wav" : "ארבע.wav"; //11 and 1
                pl.PlaySync();                                          //4
                much = true;
                break;

            case 5:
                pl.PlaySync();
                //  .Show("got here");
                pl.SoundLocation = tens ? "חמש עשרה.wav" : "חמש.wav"; //11 and 1
                pl.PlaySync();                                        //5
                much = true;
                break;

            case 6:
                pl.PlaySync();
                // .Show("got here");
                pl.SoundLocation = tens ? "שש עשרה.wav" : "שש.wav"; //11 and 1
                pl.PlaySync();                                      //6
                much = true;
                break;

            case 7:
                pl.PlaySync();
                pl.SoundLocation = tens ? "שבע עשרה.wav" : "שבע.wav"; //11 and 1
                pl.PlaySync();                                        //7
                much = true;
                break;

            case 8:
                pl.PlaySync();
                pl.SoundLocation = tens ? "שמונה עשרה.wav" : "שמונה.wav"; //11 and 1
                pl.PlaySync();                                            //8
                much = true;
                break;

            case 9:
                pl.PlaySync();
                pl.SoundLocation = tens ? "תשע עשרה.wav" : "תשע.wav"; //11 and 1
                pl.PlaySync();                                        //9
                much = true;
                break;

            default:
                if (tens)
                {
                    pl.SoundLocation = "עשר.wav";
                    pl.PlaySync();
                }
                count++;
                break;
            }
            if (and || tens || much)
            {
                pl.SoundLocation = "דקות.wav";
                pl.PlaySync();
            }
        }
Exemple #55
0
        static void linenum(int num)
        {
            //  .Show(num.ToString());
            System.Media.SoundPlayer pl = new System.Media.SoundPlayer();
            pl.SoundLocation = "קו.wav";
            pl.PlaySync();
            //string st = "";
            int  n    = 0;
            bool and  = false;
            bool tens = false;

            n = num / 100;
            switch (n)
            {
            case 1:
                pl.SoundLocation = "מאה.wav";    //meah
                pl.PlaySync();
                and = true;
                break;

            /*        case 2:
             *         pl.SoundLocation = "sound.wav";//200
             *          pl.PlaySync();
             *          and = true;
             *          break;
             *      case 3:
             *         pl.SoundLocation = "sound.wav";//300
             *          pl.PlaySync();
             *          and = true;
             *          break;
             *      case 4:
             *         pl.SoundLocation = "sound.wav";//400
             *          pl.PlaySync();
             *          and = true;
             *          break;*/
            /*case 5:
             *    st += " חמישים";
             *    break;
             * case 6:
             *    st += " שישים";
             *    break;
             * case 7:
             *    st += " שבעים";
             *    break;
             * case 8:
             *    st += " שמונים";
             *    break;
             * case 9:
             *    st += " תשעים";
             *    break;*/
            default:
                break;
            }
            num = num % 100;
            n   = num / 10;
            switch (n)
            {
            case 1:
                //     .Show("");
                tens = true;
                break;

            case 2:
                pl.SoundLocation = "עשרים.wav";
                pl.PlaySync();    //20
                and = true;
                break;

            case 3:
                pl.SoundLocation = "שלושים.wav";
                pl.PlaySync();    //30
                and = true;
                break;

            case 4:
                pl.SoundLocation = "ארבעים.wav";
                pl.PlaySync();    //40
                and = true;
                break;

            case 5:
                pl.SoundLocation = "חמישים.wav";
                pl.PlaySync();    //50
                and = true;
                break;

            case 6:
                pl.SoundLocation = "שישים.wav";
                pl.PlaySync();    //60
                and = true;
                break;

            case 7:
                pl.SoundLocation = "שבעים.wav";
                pl.PlaySync();    //70
                and = true;
                break;

            case 8:
                pl.SoundLocation = "שמונים.wav";
                pl.PlaySync();    //80
                and = true;
                break;

            case 9:
                pl.SoundLocation = "תשעים.wav";
                pl.PlaySync();    //90
                and = true;
                break;

            default:
                break;
            }
            if (and)
            {
                pl.SoundLocation = "ו.wav";
                //pl.PlaySync();//veeeeee!!!!
            }
            // .Show((num % 10).ToString());
            n = num % 10;
            switch (n)
            {
            case 1:
                pl.PlaySync();                                        //veeeeee!!!!
                pl.SoundLocation = tens ? "אחת עשרה.wav" : "אחת.wav"; //11 and 1
                pl.PlaySync();
                break;

            case 2:
                pl.PlaySync();                                            //veeeeee!!!!
                pl.SoundLocation = tens ? "שתיים עשרה.wav" : "שתיים.wav"; //11 and 1
                pl.PlaySync();                                            //2
                break;

            case 3:
                // .Show("");
                pl.PlaySync();                                          //veeeeee!!!!
                pl.SoundLocation = tens ? "שלוש עשרה.wav" : "שלוש.wav"; //11 and 1
                pl.PlaySync();                                          //3
                break;

            case 4:
                pl.PlaySync();                                          //veeeeee!!!!
                pl.SoundLocation = tens ? "ארבע עשרה.wav" : "ארבע.wav"; //11 and 1
                pl.PlaySync();                                          //4
                break;

            case 5:
                pl.PlaySync();                                        //veeeeee!!!!
                pl.SoundLocation = tens ? "חמש עשרה.wav" : "חמש.wav"; //11 and 1
                pl.PlaySync();                                        //5
                break;

            case 6:
                pl.PlaySync();                                      //veeeeee!!!!
                pl.SoundLocation = tens ? "שש עשרה.wav" : "שש.wav"; //11 and 1
                pl.PlaySync();                                      //6
                break;

            case 7:
                pl.PlaySync();                                        //veeeeee!!!!
                pl.SoundLocation = tens ? "שבע עשרה.wav" : "שבע.wav"; //11 and 1
                pl.PlaySync();                                        //7
                break;

            case 8:
                pl.PlaySync();                                            //veeeeee!!!!
                pl.SoundLocation = tens ? "שמונה עשרה.wav" : "שמונה.wav"; //11 and 1
                pl.PlaySync();                                            //8
                break;

            case 9:
                pl.PlaySync();                                        //veeeeee!!!!
                pl.SoundLocation = tens ? "תשע עשרה.wav" : "תשע.wav"; //11 and 1
                pl.PlaySync();                                        //9
                break;

            default:
                break;
            }
        }
        static void Main(string[] args)
        {
            string playerInput;
            int    randInt;
            string cpuInput;
            bool   playAgain = true;

            Console.WriteLine("Lets play ROCK PAPER SCISSORS! Best three out of five to win!!");

            while (playAgain)
            {
                int cpuScore    = 0;
                int playerScore = 0;
                while (playerScore < 3 && cpuScore < 3)
                {
                    Console.WriteLine("Press any key....");

                    Console.ReadKey();
                    Console.Clear();
                    Console.WriteLine("Choose ROCK, PAPER, or SCISSORS!!!");

                    playerInput = Console.ReadLine();
                    playerInput = playerInput.ToUpper();
                    Random   rng  = new Random();
                    Random   tt   = new Random();
                    string[] talk = { "Is that best you got?!", "I can do this in my sleep", "My dog can play better than you!", "Let me know when you want to quit!" };
                    Random   bl   = new Random();
                    string[] luck = { "That's just beginners luck", "We all get lucky once in awhile", "I know you're cheating!" };

                    randInt = rng.Next(1, 3);


                    if (playerInput == "ROCK" || playerInput == "PAPER" || playerInput == "SCISSORS")
                    {
                        switch (randInt)
                        {
                        case 1:
                            cpuInput = "ROCK";
                            Console.WriteLine("CPU Chose ROCK!");
                            if (playerInput == "ROCK")
                            {
                                Console.WriteLine("The round was a tie!!!\n");
                                Console.WriteLine($"Your score: {playerScore}\n");
                                Console.WriteLine($"CPU score: {cpuScore}\n");
                            }
                            else if (playerInput == "PAPER")
                            {
                                Console.WriteLine("You won the round!\n");
                                playerScore = playerScore + 1;

                                Console.WriteLine(luck[bl.Next(0, luck.Length)], "\n");
                                Console.WriteLine($"Your score: {playerScore} \n");
                                Console.WriteLine($"CPU score: {cpuScore}");
                            }
                            else if (playerInput == "SCISSORS")
                            {
                                Console.WriteLine("The CPU won the round!!!\n");
                                cpuScore = cpuScore + 1;

                                Console.WriteLine(talk[tt.Next(0, talk.Length)], "\n");
                                Console.WriteLine($"Your score: {playerScore} \n");
                                Console.WriteLine($"CPU score: {cpuScore}");
                            }
                            break;

                        case 2:
                            cpuInput = "PAPER";
                            Console.WriteLine("CPU Chose PAPER!");
                            if (playerInput == "PAPER")
                            {
                                Console.WriteLine("The round was a tie!!!\n");
                                Console.WriteLine($"Your score: {playerScore}\n ");
                                Console.WriteLine($"CPU score: {cpuScore} ");
                            }
                            else if (playerInput == "SCISSORS")
                            {
                                Console.WriteLine("You won the round!\n");
                                playerScore = playerScore + 1;

                                Console.WriteLine(luck[bl.Next(0, luck.Length)], "\n");

                                Console.WriteLine($"Your score: {playerScore} \n");
                                Console.WriteLine($"CPU score: {cpuScore} ");
                            }
                            else if (playerInput == "ROCK")
                            {
                                Console.WriteLine("The CPU won the round!!!\n");
                                cpuScore = cpuScore + 1;

                                Console.WriteLine(talk[tt.Next(0, talk.Length)]);
                                Console.WriteLine($"Your score: {playerScore} \n");
                                Console.WriteLine($"CPU score: {cpuScore} ");
                            }
                            break;

                        case 3:
                            cpuInput = "SCISSORS";
                            Console.WriteLine("CPU Chose SCISSORS!");
                            if (playerInput == "SCISSORS")
                            {
                                Console.WriteLine("The round was a tie!!!\n");
                                Console.WriteLine($"Your score: {playerScore} \n");
                                Console.WriteLine($"CPU score: {cpuScore} ");
                            }
                            else if (playerInput == "ROCK")
                            {
                                Console.WriteLine("You won the round!\n");
                                playerScore = playerScore + 1;

                                Console.WriteLine(luck[bl.Next(0, luck.Length)], "\n");
                                Console.WriteLine($"Your score: {playerScore} \n");
                                Console.WriteLine($"CPU score: {cpuScore} ");
                            }
                            else if (playerInput == "PAPER")
                            {
                                Console.WriteLine("The CPU won the round!!!\n");
                                cpuScore = cpuScore + 1;

                                Console.WriteLine(talk[tt.Next(0, talk.Length)]);
                                Console.WriteLine($"Your score: {playerScore} \n");
                                Console.WriteLine($"CPU score: {cpuScore} ");
                            }
                            break;

                        default:
                            Console.WriteLine("Sorry, I don't understand");
                            break;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Sorry I don't understand....\n");
                    }

                    if (playerScore >= 3 || cpuScore >= 3)
                    {
                        if (playerScore >= 3)
                        {
                            Console.WriteLine("You beat the CPU!!!\n");
                            var myPlayer = new System.Media.SoundPlayer();
                            myPlayer.SoundLocation = @"C:\Users\mdski\OneDrive\Desktop\ElevenFiftyProjects\RockPaperScissors\celebration.wav";
                            myPlayer.PlaySync();
                        }

                        if (cpuScore >= 3)
                        {
                            Console.WriteLine("You lost to the CPU!!!\n");
                            var myPlayer = new System.Media.SoundPlayer();
                            myPlayer.SoundLocation = @"C:\Users\mdski\OneDrive\Desktop\ElevenFiftyProjects\RockPaperScissors\thirsty.wav";
                            myPlayer.PlaySync();
                        }
                        Console.WriteLine("Play Again? (Y/N)");
                        string repeat = Console.ReadLine();
                        repeat = repeat.ToUpper();
                        if (repeat == "Y")
                        {
                            playAgain = true;
                        }
                        else if (repeat == "N")
                        {
                            playAgain = false;
                        }
                        else
                        {
                        }
                    }
                }
            }
        }
Exemple #57
0
 private void button17_Click(object sender, EventArgs e)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.la_1);
     player.Load();
     player.PlaySync();
 }
Exemple #58
0
        public void Battle(ref BattleBot battleBot)
        {
            if (!blnIsBattleSoundPlaying)
            {
                BattleSFX.PlayLooping();
                blnIsBattleSoundPlaying = true;
            }

            if (battleBot.FuelLevel > 0 && battleBot.ConditionLevel > 0)
            {
                intBattleStartTime = intTimeSinceGameStart;
                string computerWeapon = WEAPONS[rGen.Next(WEAPONS.Length)];
                //////////////////////////////////
                Console.ForegroundColor = GetColorForWeapon(battleBot.Weapon);
                Console.WriteLine("███████████████████████████");
                SpeakingConsole.WriteLine("\n\t\t" + battleBot.Weapon + "           ");

                Console.ForegroundColor = ConsoleColor.White;
                SpeakingConsole.WriteLine("\n\t\t----- VS -----   ");

                Console.ForegroundColor = GetColorForWeapon(computerWeapon);
                SpeakingConsole.WriteLine("\n\t\t" + computerWeapon);    // Pokemon
                Console.WriteLine("███████████████████████████");

                Console.ForegroundColor = ConsoleColor.White;
                //////////////////////////////////
                //SpeakingConsole.WriteLine("\nYou are being attacked by a " + computerWeapon + ". What do you do?");
                bool blnValidAction = false;
                char charReadKey    = '\0';
                while (!blnValidAction)
                {
                    bool blnCheatCodeWorked = false;
                    SpeakingConsole.WriteLine("\nAttack, Defend, or Retreat");
                    for (int i = 0; i < KONAMI_CODE.Length; i++)
                    {
                        ConsoleKeyInfo key = Console.ReadKey();
                        charReadKey = key.KeyChar;
                        if (key.Key != KONAMI_CODE[i])
                        {
                            break;
                        }
                        if (i == KONAMI_CODE.Length - 1)
                        {
                            battleBot.GainPoints(20);
                            SpeakingConsole.WriteLine("\nYou have cheated, trainer!! But you will get 20 extra points because that's just how the world is (unfair)");
                            PokeBallOpenSFX.PlaySync();

                            blnCheatCodeWorked = true;
                            BattleSFX.PlayLooping();
                        }
                    }
                    if (blnCheatCodeWorked)
                    {
                        continue;
                    }

                    string strAction = SpeakingConsole.SpeakAndReturn(charReadKey + Console.ReadLine());
                    switch (strAction.Trim().ToLower())
                    {
                    case "attack":
                        blnValidAction = true;
                        if (CanBeat(battleBot.Weapon, computerWeapon))
                        {
                            if (IsCriticalTo(battleBot.Weapon, computerWeapon))
                            {
                                battleBot.GainPoints(rGen.Next(6, 11));
                                SpeakingConsole.WriteLine("Professor Oak: You have critically destroyed your opponent!!");

                                //////////////////////////////////
                                ///////////////////////////////////
                                /////////////////////////////////
                            }
                            else
                            {
                                battleBot.GainPoints(5);
                                SpeakingConsole.WriteLine("Professor Oak: You have destroyed your opponent!!");
                            }
                        }
                        else
                        {
                            if (IsCriticalTo(battleBot.Weapon, computerWeapon))
                            {
                                battleBot.HandleDamage(rGen.Next(6, 11));
                                SpeakingConsole.WriteLine("Professor Oak: You have tragically lost!!");
                            }
                            else
                            {
                                battleBot.HandleDamage(5);
                                SpeakingConsole.WriteLine("Professor Oak: You have lost!!");
                            }
                        }
                        battleBot.ConsumeFuel(2 * intTimeElapsed);
                        break;

                    case "defend":
                        blnValidAction = true;
                        if (CanBeat(battleBot.Weapon, computerWeapon))
                        {
                            battleBot.GainPoints(2);
                            SpeakingConsole.WriteLine("Professor Oak: You have defended yourself like a noble man!!");
                        }
                        else
                        {
                            if (IsCriticalTo(battleBot.Weapon, computerWeapon))
                            {
                                battleBot.HandleDamage(rGen.Next(3, 5));
                                SpeakingConsole.WriteLine("Professor Oak: Whoops, your shield has completely failed!!");
                            }
                            else
                            {
                                battleBot.HandleDamage(2);
                                SpeakingConsole.WriteLine("Professor Oak: Whoops, your shield has failed!!");
                            }
                        }
                        battleBot.ConsumeFuel(intTimeElapsed);
                        break;

                    case "retreat":
                        blnValidAction = true;
                        if (rGen.Next(0, 4) == 0)
                        {
                            SpeakingConsole.WriteLine("Professor Oak: Unfortunately, you couldn't escape in time!!");
                            battleBot.HandleDamage(7);
                        }
                        else
                        {
                            SpeakingConsole.WriteLine("Professor Oak: You have succesfully escaped from the battle like a coward!! No points for you!!");
                        }
                        battleBot.ConsumeFuel(3 * intTimeElapsed);
                        break;

                    case "absorb":
                        if (battleBot.Weapon == computerWeapon)
                        {
                            blnValidAction = true;
                            SpeakingConsole.WriteLine("You have succesfully absorbed the opponent's power!! This tastes yummy OwO");
                            SpeakingConsole.WriteLine("Professor Oak: Mmmmm... Fried " + computerWeapon);
                            battleBot.Refuel(10);
                            battleBot.Heal(10);
                        }
                        break;
                    }

                    if (blnValidAction)
                    {
                        GetSoundForWeapon(battleBot.Weapon).PlaySync();
                        BattleSFX.Play();
                    }
                }
                Thread.Sleep(1000);
                SpeakingConsole.WriteLine("\nBot stats:");

                if (battleBot.Name == "PokeBall")
                {
                    Console.WriteLine("────────▄███████████▄────────");
                    Console.WriteLine("─────▄███▓▓▓▓▓▓▓▓▓▓▓███▄─────");
                    Console.WriteLine("────███▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓███────");
                    Console.WriteLine("───██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██───");
                    Console.WriteLine("──██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██──");
                    Console.WriteLine("─██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██─");
                    Console.WriteLine("██▓▓▓▓▓▓▓▓▓███████▓▓▓▓▓▓▓▓▓██");
                    Console.WriteLine("██▓▓▓▓▓▓▓▓██░░░░░██▓▓▓▓▓▓▓▓██");
                    Console.WriteLine("██▓▓▓▓▓▓▓██░░███░░██▓▓▓▓▓▓▓██");
                    Console.WriteLine("███████████░░███░░███████████");
                    Console.WriteLine("██░░░░░░░██░░███░░██░░░░░░░██");
                    Console.WriteLine("██░░░░░░░░██░░░░░██░░░░░░░░██");
                    Console.WriteLine("██░░░░░░░░░███████░░░░░░░░░██");
                    Console.WriteLine("─██░░░░░░░░░░░░░░░░░░░░░░░██─");
                    Console.WriteLine("──██░░░░░░░░░░░░░░░░░░░░░██──");
                    Console.WriteLine("───██░░░░░░░░░░░░░░░░░░░██───");
                    Console.WriteLine("────███░░░░░░░░░░░░░░░███────");
                    Console.WriteLine("─────▀███░░░░░░░░░░░███▀─────");
                    Console.WriteLine("────────▀███████████▀────────");
                }

                SpeakingConsole.WriteLine("Trainers Name: " + battleBot.Name + ",");

                // Color Desiders
                if (battleBot.Weapon == "Pickachu")
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                }
                else if (battleBot.Weapon == "Geodude")
                {
                    Console.ForegroundColor = ConsoleColor.Gray;
                }
                else if (battleBot.Weapon == "Squirtle")
                {
                    Console.ForegroundColor = ConsoleColor.Blue;
                }
                else if (battleBot.Weapon == "Swadloon")
                {
                    Console.ForegroundColor = ConsoleColor.Green;
                }
                else if (battleBot.Weapon == "Charmander")
                {
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                }



                SpeakingConsole.WriteLine("Pokemon: " + battleBot.Weapon + ",");
                Console.ForegroundColor = ConsoleColor.White;
                SpeakingConsole.WriteLine("Condition Level: " + battleBot.ConditionLevel + ",");
                SpeakingConsole.WriteLine("Power Points:" + battleBot.FuelLevel + ",\nTurn Time: " + intTimeElapsed + ",\nTotal Battle Time: " + intTimeSinceGameStart + ",\nPoints: " + battleBot.Score + ",\nHighest Score: " + battleBot.HighScore);

                SpeakingConsole.WriteLine("\n Health Left: ##");
                SpeakingConsole.WriteLine("\n Power Left: ");
                //Console.WriteLine("\n Next Move: ");

                Thread.Sleep(1000);
                Battle(ref battleBot);
            }
            else
            {
                battleBot.UpdateHighScore(battleBot.Score);
                SpeakingConsole.WriteLine("Your pokemon has lost. Do you want to play again?");
                if (SpeakingConsole.ReadLine().Trim().ToLower()[0] == 'y')
                {
                    battleBot = PromptUserForBot(battleBot.HighScore);
                    Battle(ref battleBot);
                }
            }
        }
 // Synchronously plays the selected .wav file once.
 // If the file is large, UI response will be visibly
 // affected.
 private void playOnceSyncButton_Click(object sender, System.EventArgs e)
 {
     ReportStatus("Playing .wav file synchronously.");
     sound.PlaySync();
     ReportStatus("Finished playing .wav file synchronously.");
 }
Exemple #60
0
        //请求定时器
        private void timer1_Tick(object sender, EventArgs e)
        {
            string url    = GetAppConfig("GetUrl");
            string userId = GetAppConfig("UserId");



            if (url == "" || userId == "")
            {
                MessageBox.Show("请在配置文件中配置请求url和用户UserId");
            }
            else
            {
                string responseVal = HttpGet(url);

                if (responseVal == "")
                {
                    // MessageBox.Show("请求异常");
                    return;
                }

                ToJsonMy obj = ToObj(responseVal);

                if (obj.code != "00")
                {
                    // MessageBox.Show("请求异常");
                    return;
                }

                if (obj.data.total == "0")
                {
                    type = 0;
                    this.richTextBox1.Text = "";
                    this.richTextBox1.AppendTextColorful("暂无待办", Color.Black, 16);
                }
                else
                {
                    System.Media.SoundPlayer player = new System.Media.SoundPlayer();
                    player.SoundLocation = Application.StartupPath + "\\yinpin.wav";
                    player.LoadAsync();
                    player.PlaySync();

                    type = 1;

                    this.timer.Enabled = true;

                    this.richTextBox1.Text = "";

                    string msg = "总消息数:" + obj.data.total + "\r\n";


                    //this.richTextBox1.AppendTextColorful(msg, Color.Black, 16);

                    int index = 1;
                    List <ToJsonItem> items = obj.data.items;

                    foreach (ToJsonItem item in items)
                    {
                        msg += index + "、" + item.title + "\r\n";
                        // this.richTextBox1.AppendTextColorful(index+"、" + item.title, Color.Black, 16);

                        //this.richTextBox1.AppendTextColorful("申请人:" + item.apply + "    时间:" + item.date, Color.Black, 14);
                        msg += "申请人:" + item.apply + "    时间:" + item.date + "\r\n";
                        index++;
                    }
                    this.richTextBox1.AppendTextColorful(msg, Color.Black, 14);

                    richTextBox1.SelectionStart = 0;
                    richTextBox1.Focus();
                }
            }
        }