private void move(TableLayoutPanelCellPosition newPos) { TableLayoutPanelCellPosition temp = tableLayoutPanel1.GetPositionFromControl(snake[0]); if (newPos == tableLayoutPanel1.GetPositionFromControl(panelF)) { med.SoundPlayer sp = new med.SoundPlayer("add.WAV"); sp.Play(); panelF.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(128))))); snake.Add(panelF); putFood(); tableLayoutPanel1.SetCellPosition(snake[0], newPos); movePos(temp); sp.Dispose(); } else if (tableLayoutPanel1.GetControlFromPosition(newPos.Column, newPos.Row) == null) { tableLayoutPanel1.SetCellPosition(snake[0], newPos); movePos(temp); label2.Text = "Started"; } else if (newPos == tableLayoutPanel1.GetPositionFromControl(snake[1])) { GameOver = false; label2.Text = "Paused"; } else { GameOver = true; } labelLen.Text = CountLen(); }
public void Play(string src) { using(SoundPlayer sp = new SoundPlayer(src)) { sp.PlaySync (); sp.Dispose (); } }
private void PlayWaverFile(string filePath, bool playLooping) { if (_soundPlay != null) { _soundPlay.Stop(); _soundPlay.Dispose(); _soundPlay = null; } if (string.IsNullOrEmpty(filePath)) { return; } _soundPlay = new SM.SoundPlayer(filePath); if (playLooping) { _soundPlay.PlayLooping(); } else { _soundPlay.Play(); } }
/// <summary> /// Reading .wav file chosen by user and prepare data array for further processing /// </summary> /// <param name="ts">Parameter deciding which track should be loaded (either first or second one)</param> private void LoadFile(TrackSelector ts) { using (var dialog = new OpenFileDialog()) { dialog.Title = "Choose wisely"; dialog.Filter = "Sound tracks (*.wav) | *.wav"; if (dialog.ShowDialog() == DialogResult.OK) { PreprocessRawData(ts, dialog.FileName); switch (ts) { case TrackSelector.First: Label_OfTrack1.Text = dialog.FileName; _player1?.Dispose(); _player1 = new SoundPlayer(dialog.FileName); break; case TrackSelector.Second: Label_OfTrack2.Text = dialog.FileName; _player2?.Dispose(); _player2 = new SoundPlayer(dialog.FileName); break; } } } }
public void Dispose() { if (player != null) { player.Dispose(); } }
private void PlayMusic() { { med.SoundPlayer sp = new med.SoundPlayer("onthe.wav"); sp.Play(); sp.Dispose(); } }
public static void PlayVoice(string path) { if (File.Exists(path)) { SoundPlayer player = new SoundPlayer(path); player.Play(); player.Dispose(); } }
public static void ServerStuff() { if (inUse) { Console.WriteLine("SERVER ERROR: ALREADY LISTENING IN OTHER THREAD. ABORTING..."); return; } else { inUse = true; } myList = new TcpListener(IPAddress.Any, port); myList.Start(); Console.WriteLine("Starting at port: " + port); Console.WriteLine("The local End point is: " + myList.LocalEndpoint); Console.WriteLine("Waiting for a connection....."); s = myList.AcceptSocket(); Console.WriteLine("Connection accepted from " + s.RemoteEndPoint); SoundPlayer simpleSound2 = new SoundPlayer(@"c:\inmessage.wav"); simpleSound2.Play(); simpleSound2.Dispose(); try { while (dflag) { byte[] b = new byte[100]; s.Receive(b); short pick = Convert.ToInt16(b[0]); if ((pick > 0) && (pick != 127)) { Console.WriteLine("Got {0}", pick); ASCIIEncoding asen = new ASCIIEncoding(); try { Console.WriteLine("SENDING: " + data[pick - 1].ToString()); } catch (Exception e) { Console.WriteLine(e); } s.Send(asen.GetBytes(data[pick - 1].ToString())); } else if (pick == 127) { inUse = false; break; } } } catch { inUse = false; } s.Close(); myList.Stop(); }
public void PlaySound(string resourceName) { var assembly = Assembly.GetExecutingAssembly(); using (Stream stream = assembly.GetManifestResourceStream(resourceName)) { System.Media.SoundPlayer player = new System.Media.SoundPlayer(stream); player.Play(); player.Dispose(); } }
//************************************************** private void labelQ_Click(object sender, EventArgs e) { med.SoundPlayer sp = new med.SoundPlayer("Leave.wav"); sp.Play(); sp.Dispose(); for (int i = 0; i < 209999999; i++) { ; } Application.Exit(); }
private void Form1_Load(object sender, EventArgs e) { System.IO.Stream strm = Properties.Resources.Yukari; System.Media.SoundPlayer player = new System.Media.SoundPlayer(strm); player.Play(); player.Dispose(); //時報判定用(後同期の方) DateTime dt = DateTime.Now; checkTime = dt.Hour; timer1.Start(); }
private void button2_Click(object sender, EventArgs e) { if (player == null) { button2.Text = "Stop"; player = new SoundPlayer("bgm2.wav"); player.PlayLooping(); } else { button2.Text = "Start"; player.Stop(); player.Dispose(); player = null; } }
public void Close() { 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); SoundPlayer sp = new SoundPlayer(fs); sp.PlaySync(); sp.Dispose(); bw.Close(); fs.Close(); }
private void StreamVideo(ImageCodecInfo codecInfo, EncoderParameters encoderParams) { MemoryStream m = new MemoryStream(20000); Bitmap image = null; IntPtr ip = IntPtr.Zero; Font fontOverlay = new Font("Times New Roman", 14, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point); DateTime lastMotion = DateTime.Now; int interval = 5; _isRecording = false; _player = new SoundPlayer(); _player.LoadCompleted += new System.ComponentModel.AsyncCompletedEventHandler((obj, arg) => _player.PlayLooping()); Task.Factory.StartNew(() => { _device.Start(); while (_requested) { try { // capture image ip = _device.GetBitMap(); image = new Bitmap(_device.Width, _device.Height, _device.Stride, System.Drawing.Imaging.PixelFormat.Format24bppRgb, ip); image.RotateFlip(RotateFlipType.RotateNoneFlipY); _currentSensor.ProcessFrame(ref image); if (_currentSensor.IsAlarming) { if (!_isRecording && (DateTime.Now.Second % interval == 0)) _messenger.SendMessage("record"); lastMotion = DateTime.Now; } else { if (DateTime.Now.Subtract(lastMotion).Seconds > interval) { if (_isRecording) { _messenger.SendMessage("stop-record"); _isRecording = false; } if (_isAlarming) { _player.Stop(); _isAlarming = false; } } } // add text that displays date time to the image image.AddText(fontOverlay, 10, 10, DateTime.Now.ToString()); // save it to jpeg using quality options image.Save(m, codecInfo, encoderParams); // send the jpeg image if server requests it if (_messenger != null) _messenger.SendMessage(m.GetBuffer(), MessageType.Image); } catch (SocketException) { _messenger.Dispose(); _messenger = null; _requested = false; } catch { } finally { // clean up m.SetLength(0); if (image != null) image.Dispose(); if (ip != IntPtr.Zero) { Marshal.FreeCoTaskMem(ip); ip = IntPtr.Zero; } } } _device.Pause(); _player.Stop(); _player.Dispose(); fontOverlay.Dispose(); disposeReady.Set(); }); }
public void UpRand(int x, MyBoard board) { if (_curEnd == 0) board.arrSquares[curIndex].status = 0; if (x > _curEnd) { board.arrEndSquares[nType - 1].empty[_curEnd] = true; _curEnd = x - 1; board.arrEndSquares[nType - 1].empty[_curEnd] = false; _curPoint = board.arrEndSquares[nType - 1].p[_curEnd]; SoundPlayer sound = new SoundPlayer(@"Resources\Audio\UpRand.wav"); sound.LoadAsync(); sound.Play(); sound.Dispose(); if (_curEnd >= 2) { int dem = 0; for (int i = 5; i > _curEnd; i--) { if (!board.arrEndSquares[nType - 1].empty[i]) dem++; } if (dem == (5 - _curEnd)) this._isFinish = true; } } }
public vicPiece MoveSteponStep(MyBoard board, int index) { vicPiece vic = new vicPiece(); vic.index = -1; vic.nType = 0; IsChoice = true; board.arrSquares[curIndex].status = 0; board.arrSquares[curIndex].curIndex = -1; board.arrSquares[curIndex].shadow = 0; board.arrSquares[curIndex].shield = 0; curIndex = (curIndex + 1) % 56; if (board.arrSquares[_curIndex].bomb != 0 && board.arrSquares[_curIndex].bomb != nType && Buff != 6 && Buff != 2) //Co bomb k fai cua doi minh { board.arrSquares[_startIndex].shield = 0; board.arrSquares[_startIndex].shadow = 0; board.arrSquares[_curIndex].bomb = 0; InCage(); vic.nType = -2; SoundPlayer sound1 = new SoundPlayer(@"Resources\Audio\ExClose.wav"); sound1.LoadAsync(); sound1.Play(); Started = false; Ended = false; sound1.Dispose(); return vic; } if (board.arrSquares[_curIndex].shadow != 1 && board.arrSquares[_curIndex].status != nType) { vic.nType = board.arrSquares[_curIndex].status; vic.index = board.arrSquares[_curIndex].curIndex; } if (board.arrSquares[curIndex].status == nType) // nguoi doi minh curIndex = (curIndex + 1) % 56; _curPoint = board.arrSquares[curIndex].square; board.arrSquares[_curIndex].status = nType; board.arrSquares[_curIndex].curIndex = index; if (curIndex == _endIndex) _ended = true; return vic; }
internal void Say(string what) { if (!Enabled) return; if (cachedSpeech.ContainsKey(what)) { var thisMs = cachedSpeech[what]; if (!thisMs.Ready) return; Console.WriteLine(thisMs.Length); thisMs.WavStream.Seek(0, SeekOrigin.Begin); var sp = new SoundPlayer(thisMs.WavStream); sp.Play(); sp.Dispose(); } }
private void playSoundFromResource(int SoundFileId) { try { if ((DateTime.Now - LastSoundPlayed).TotalSeconds < 4 || mGeneralSettings.SoundSettings.MuteSounds || SoundFileId == 0) { return; } else { SoundList.Find(x => x.SoundId == SoundFileId).SoundStream.Position = 0; SoundPlayer player = new SoundPlayer(SoundList.Find(x => x.SoundId == SoundFileId).SoundStream); player.Play(); player.Dispose(); LastSoundPlayed = DateTime.Now; } }catch(Exception ex){LogError(ex);} }
private void button1_Click(object sender, EventArgs e) { //TakeScreenShot = true; //snapped = false; SoundPlayer simpleSound = new SoundPlayer(Properties.Resources.camera_clic_with_flash); simpleSound.Play(); simpleSound.Dispose(); getScreehShot(); }
public void playNewTitanic() { System.Media.SoundPlayer newTitanic = new System.Media.SoundPlayer("../../sounds/titanic.wav"); newTitanic.Play(); newTitanic.Dispose(); }
//接收到视频呼叫请求处理 private void VideoCall_Request_Handler(int dwUserId, int dwParam, string lpUserStr) { if (this.WindowState == FormWindowState.Minimized) this.WindowState = FormWindowState.Normal; timer_call.Stop();//关闭计时器,确认状态 ConversationMode = new ConversationInfo(); ConversationMode.SuserId = dwUserId; ConversationMode.TuserId = m_UserId; UserInfo userItem = GetUserInfoByUserId(dwUserId); if (userItem != null) { ShowCallMessage(Properties.Resources._14, userItem.Name + "向您发起视频会话邀请..."); Button btn_accepted = new Button(); btn_accepted.Font = new Font("微软雅黑", 20); btn_accepted.Size = new Size(140, 50); btn_accepted.Location = new Point(pan_call.Width / 2 - btn_accepted.Width - 10, pic_call.Top + pic_call.Height + 30); btn_accepted.Text = "接受"; btn_accepted.Tag = "btn"; btn_accepted.BackColor = Color.Lime; btn_accepted.ForeColor = Color.White; btn_accepted.Click += new EventHandler(btn_accepted_Click); pan_call.Controls.Add(btn_accepted); Button btn_refuse = new Button(); btn_refuse.Font = new Font("微软雅黑", 20); btn_refuse.Size = new Size(140, 50); btn_refuse.Location = new Point(pan_call.Width / 2 + 10, pic_call.Top + pic_call.Height + 30); btn_refuse.Text = "拒绝"; btn_refuse.Tag = "btn"; btn_refuse.BackColor = Color.Red; btn_refuse.ForeColor = Color.White; btn_refuse.Click += new EventHandler(btn_refuse_Click); pan_call.Controls.Add(btn_refuse); SoundPlayer Player = new SoundPlayer(); Player.Stream = Properties.Resources.ring; Player.Play(); Player.Dispose(); } }
//呼叫等待 private void VideoCall_WaitCall_Handler() { try { intCallTimer = 60; ShowCallMessage(Properties.Resources._15, "呼叫请求中,等待用户响应..."); //timer_call.Start(); timer_call.Stop();//关闭计时器,确认状态 Button btn_cancall = new Button(); btn_cancall.Font = new Font("微软雅黑", 20); btn_cancall.Size = new Size(140, 50); btn_cancall.Location = new Point(pan_call.Width / 2 - btn_cancall.Width / 2, pic_call.Top + pic_call.Height + 30); btn_cancall.Text = "取消"; btn_cancall.Tag = "btn"; btn_cancall.BackColor = Color.Red; btn_cancall.ForeColor = Color.White; btn_cancall.Click += new EventHandler(btn_cancall_Click); pan_call.Controls.Add(btn_cancall); SoundPlayer Player = new SoundPlayer(); Player.Stream = Properties.Resources.ring; Player.Play(); Player.Dispose(); } catch (Exception ex) { Log.SetLog("VideoChat.Hall.WaitCall WaitCall:" + ex.Message.ToString()); } }
public void playReloading() { System.Media.SoundPlayer reloading = new System.Media.SoundPlayer("../../sounds/reloading.wav"); reloading.Play(); reloading.Dispose(); }
public static void PlaySound(string file) { SoundPlayer player = new SoundPlayer(file); player.Play(); player.Dispose(); }
public static void PlaySound(Stream sound) { SoundPlayer player = new SoundPlayer(sound); player.Play(); player.Dispose(); }
private void tf() { //時報判定用時刻(Hourのみ)を取得 //必要な関数を宣言 DateTime dt = DateTime.Now; //int型のh変数へ時刻(Hourのみを挿入) h = dt.Hour; if (h != checkTime) { //時報時にエラーが起きたら下記のコードを有効化 //timer1の一時停止 timer1.Enabled = false; if (MuteCHK == true) { switch (h) { case 1: //1時のときのボイスを指定 System.IO.Stream strm1 = Properties.Resources._1; System.Media.SoundPlayer player1 = new System.Media.SoundPlayer(strm1); player1.Play(); player1.Dispose(); break; case 2: //2時のときのボイスを指定 System.IO.Stream strm2 = Properties.Resources._2; System.Media.SoundPlayer player2 = new SoundPlayer(strm2); player2.Play(); player2.Dispose(); break; case 3: //3時のときのボイスを指定 System.IO.Stream strm3 = Properties.Resources._3; System.Media.SoundPlayer player3 = new SoundPlayer(strm3); player3.Play(); player3.Dispose(); break; case 4: //4時のときのボイスを指定 System.IO.Stream strm4 = Properties.Resources._4; System.Media.SoundPlayer player4 = new SoundPlayer(strm4); player4.Play(); player4.Dispose(); break; case 5: //5時のときのボイスを指定 System.IO.Stream strm5 = Properties.Resources._5; System.Media.SoundPlayer player5 = new SoundPlayer(strm5); player5.Play(); player5.Dispose(); break; case 6: //6時のときのボイスを指定 System.IO.Stream strm6 = Properties.Resources._6; System.Media.SoundPlayer player6 = new SoundPlayer(strm6); player6.Play(); player6.Dispose(); break; case 7: //7時のときのボイスを指定 System.IO.Stream strm7 = Properties.Resources._7; System.Media.SoundPlayer player7 = new SoundPlayer(strm7); player7.Play(); player7.Dispose(); break; case 8: //8時のときのボイスを指定 System.IO.Stream strm8 = Properties.Resources._8; System.Media.SoundPlayer player8 = new SoundPlayer(strm8); player8.Play(); player8.Dispose(); break; case 9: //9時のときのボイスを指定 System.IO.Stream strm9 = Properties.Resources._9; System.Media.SoundPlayer player9 = new SoundPlayer(strm9); player9.Play(); player9.Dispose(); break; case 10: //10時のときのボイスを指定 System.IO.Stream strm10 = Properties.Resources._10; System.Media.SoundPlayer player10 = new SoundPlayer(strm10); player10.Play(); player10.Dispose(); break; case 11: //11時のときのボイスを指定 System.IO.Stream strm11 = Properties.Resources._11; System.Media.SoundPlayer player11 = new SoundPlayer(strm11); player11.Play(); player11.Dispose(); break; case 12: //12時のときのボイスを指定 System.IO.Stream strm12 = Properties.Resources._12; System.Media.SoundPlayer player12 = new SoundPlayer(strm12); player12.Play(); player12.Dispose(); break; case 13: //13時のときのボイスを指定 System.IO.Stream strm13 = Properties.Resources._13; System.Media.SoundPlayer player13 = new SoundPlayer(strm13); player13.Play(); player13.Dispose(); break; case 14: //14時のときのボイスを指定 System.IO.Stream strm14 = Properties.Resources._14; System.Media.SoundPlayer player14 = new SoundPlayer(strm14); player14.Play(); player14.Dispose(); break; case 15: //15時のときのボイスを指定 System.IO.Stream strm15 = Properties.Resources._15; System.Media.SoundPlayer player15 = new SoundPlayer(strm15); player15.Play(); player15.Dispose(); break; case 16: //16時のときのボイスを指定 System.IO.Stream strm16 = Properties.Resources._16; System.Media.SoundPlayer player16 = new SoundPlayer(strm16); player16.Play(); player16.Dispose(); break; case 17: //17時のときのボイスを指定 System.IO.Stream strm17 = Properties.Resources._17; System.Media.SoundPlayer player17 = new SoundPlayer(strm17); player17.Play(); player17.Dispose(); break; case 18: //18時のときのボイスを指定 System.IO.Stream strm18 = Properties.Resources._18; System.Media.SoundPlayer player18 = new SoundPlayer(strm18); player18.Play(); player18.Dispose(); break; case 19: //19時のときのボイスを指定 System.IO.Stream strm19 = Properties.Resources._19; System.Media.SoundPlayer player19 = new SoundPlayer(strm19); player19.Play(); player19.Dispose(); break; case 20: //20時のときのボイスを指定 System.IO.Stream strm20 = Properties.Resources._20; System.Media.SoundPlayer player20 = new SoundPlayer(strm20); player20.Play(); player20.Dispose(); break; case 21: //21時のときのボイスを指定 System.IO.Stream strm21 = Properties.Resources._21; System.Media.SoundPlayer player21 = new SoundPlayer(strm21); player21.Play(); player21.Dispose(); break; case 22: //22時のときのボイスを指定 System.IO.Stream strm22 = Properties.Resources._22; System.Media.SoundPlayer player22 = new SoundPlayer(strm22); player22.Play(); player22.Dispose(); break; case 23: //23時のときのボイスを指定 System.IO.Stream strm23 = Properties.Resources._23; System.Media.SoundPlayer player23 = new SoundPlayer(strm23); player23.Play(); player23.Dispose(); break; case 0: //24時のときのボイスを指定 System.IO.Stream strm24 = Properties.Resources._0; System.Media.SoundPlayer player24 = new SoundPlayer(strm24); player24.Play(); player24.Dispose(); break; //お疲れ様でした(;´∀`) }//switchの終わり } //ifでfalseだった場合、switch処理後にhを同期 checkTime = h; //再開用 timer1.Enabled = true; } //ifの終わり } //tfの終わり
public void playNewSkiff() { System.Media.SoundPlayer newSkiff = new System.Media.SoundPlayer("../../sounds/cartmanrespect.wav"); newSkiff.Play(); newSkiff.Dispose(); }
private void TrayNotifiy(string title, string msg, bool makesound) { if (instance.State.IsBusy) return; if (System.Text.RegularExpressions.Regex.IsMatch(msg.ToLower(CultureInfo.CurrentCulture).Trim(), "autopilot", System.Text.RegularExpressions.RegexOptions.IgnoreCase)) return; notifyIcon1.Text = UpdateIconTitle(); BeginInvoke(new MethodInvoker(delegate() { ////chatConsole.ChatManager.PrintMsg("\n" + msg + "\n"); ////chatConsole.ChatManager.PrintMsg(Environment.NewLine + getTimeStamp() + msg); //chatConsole.ChatManager.PrintMsg(Environment.NewLine + msg); chatConsole.ChatManager.PrintMsg(msg); })); if (!stopnotify) { notifyIcon1.BalloonTipText = msg; notifyIcon1.BalloonTipTitle = title + " [" + avname + "]"; notifyIcon1.ShowBalloonTip(2000); if (this.instance.Config.CurrentConfig.PlaySound && makesound) { //System.Media.SystemSounds..Play(); SoundPlayer simpleSound = new SoundPlayer(Properties.Resources.notify); simpleSound.Play(); simpleSound.Dispose(); } } }
private void HandleIM(InstantMessageEventArgs e) { if (instance.IsAvatarMuted(e.IM.FromAgentID, e.IM.FromAgentName)) return; if (e.IM.Message.Contains(this.instance.Config.CurrentConfig.CommandInID)) return; if (e.IM.Message.Contains(this.instance.Config.CurrentConfig.IgnoreUID)) return; if (instance.IsGiveItem(e.IM.Message.ToLower(CultureInfo.CurrentCulture), e.IM.FromAgentID)) { return; } if (e.IM.Dialog == InstantMessageDialog.SessionSend) { lock (this.instance.State.GroupStore) { if (this.instance.State.GroupStore.ContainsKey(e.IM.IMSessionID)) { //if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Group && (me.ID == e.IM.IMSessionID || me.ID == e.IM.FromAgentID))) return; // Check to see if group IMs are disabled if (instance.Config.CurrentConfig.DisableGroupIMs) return; if (instance.State.IsBusy) return; if (TabExists(this.instance.State.GroupStore[e.IM.IMSessionID])) { METAboltTab tab = tabs[this.instance.State.GroupStore[e.IM.IMSessionID].ToLower(CultureInfo.CurrentCulture)]; if (!tab.Selected) { tab.Highlight(); tabs["imbox"].PartialHighlight(); } return; } else { IMTabWindowGroup imTab = AddIMTabGroup(e); tabs[imTab.TargetName.ToLower()].Highlight(); tabs["imbox"].IMboxHighlight(); if (tabs[imTab.TargetName.ToLower(CultureInfo.CurrentCulture)].Selected) tabs[imTab.TargetName.ToLower(CultureInfo.CurrentCulture)].Highlight(); return; } } } return; } if (TabExists(e.IM.FromAgentName)) //if (tabs.ContainsKey(e.IM.FromAgentName.ToLower())) { if (!tabs[e.IM.FromAgentName.ToLower(CultureInfo.CurrentCulture)].Selected) { tabs["imbox"].PartialHighlight(); } } else { tabs["imbox"].IMboxHighlight(); } if (this.instance.MainForm.WindowState == FormWindowState.Minimized) { if (!stopnotify) { string ttl = string.Empty; avname = netcom.LoginOptions.FullName; if (this.instance.State.GroupStore.ContainsKey(e.IM.IMSessionID)) { ttl = "Group IM notification [" + avname + "]"; } else { ttl = "IM notification [" + avname + "]"; } string imsg = e.IM.Message; if (imsg.Length > 125) { imsg = imsg.Substring(0, 125) + "..."; } string body = e.IM.FromAgentName + ": " + imsg; Notification notifForm = new Notification(); notifForm.Message = body; notifForm.Title = ttl; notifForm.Show(); } } lock (this.instance.State.GroupStore) { if (this.instance.State.GroupStore.ContainsKey(e.IM.IMSessionID)) { //if (null != client.Self.MuteList.Find(me => me.Type == MuteType.Group && (me.ID == e.IM.IMSessionID || me.ID == e.IM.FromAgentID))) return; // Check to see if group IMs are disabled if (instance.Config.CurrentConfig.DisableGroupIMs) { Group grp = this.instance.State.Groups[e.IM.IMSessionID]; client.Self.RequestLeaveGroupChat(grp.ID); return; } if (instance.State.IsBusy) { Group grp = this.instance.State.Groups[e.IM.IMSessionID]; client.Self.RequestLeaveGroupChat(grp.ID); return; } if (TabExists(this.instance.State.GroupStore[e.IM.IMSessionID])) { METAboltTab tab = tabs[this.instance.State.GroupStore[e.IM.IMSessionID].ToLower(CultureInfo.CurrentCulture)]; if (!tab.Selected) tab.PartialHighlight(); //Logger.Log("Stored|ExistingGroupTab:: " + e.IM.Message, Helpers.LogLevel.Debug); return; } else { //create a new tab IMTabWindowGroup imTab = AddIMTabGroup(e); tabs[imTab.TargetName.ToLower(CultureInfo.CurrentCulture)].Highlight(); if (instance.Config.CurrentConfig.PlayGroupIMreceived) { SoundPlayer simpleSound = new SoundPlayer(Properties.Resources.Group_Im_received); simpleSound.Play(); simpleSound.Dispose(); } //Logger.Log("Stored|NewGroupTab:: " + e.IM.Message, Helpers.LogLevel.Debug); return; } } else { if (TabExists(e.IM.FromAgentName)) { METAboltTab tab = tabs[e.IM.FromAgentName.ToLower(CultureInfo.CurrentCulture)]; if (!tab.Selected) tab.PartialHighlight(); return; } else { IMTabWindow imTab = AddIMTab(e); tabs[imTab.TargetName.ToLower(CultureInfo.CurrentCulture)].Highlight(); if (instance.Config.CurrentConfig.InitialIMReply.Length > 0) { client.Self.InstantMessage(e.IM.FromAgentID, instance.Config.CurrentConfig.InitialIMReply); } if (instance.Config.CurrentConfig.PlayIMreceived) { SoundPlayer simpleSound = new SoundPlayer(Properties.Resources.IM_received); simpleSound.Play(); simpleSound.Dispose(); } } } } }
//开始会话 private void VideoCall_SessionStart_Handler(int roomId) { AnyChatCoreSDK.EnterRoom(roomId, "", 0); SoundPlayer Player = new SoundPlayer(); Player.Stream = Properties.Resources.system; Player.Play(); Player.Dispose(); }
private static void StartClient() { // Connect to a remote device. try { IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName()); IPAddress ipAddress = ipHostInfo.AddressList[0]; IPEndPoint remoteEP = new IPEndPoint(ipAddress, port); // Create a TCP/IP socket. Socket client = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp); // Connect to the remote endpoint. client.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), client); connectDone.WaitOne(); // Send login Console.Write("Enter username: "******"Enter password: "******"username: "******" password: "******"<EOF>"); sendDone.WaitOne(); ////////////////////// MY AUTHENTICATION /////////////////////// if (username.Equals("LOGIN1234") && password.Equals("1234")) { Send(client, "...ACCESS GRANTED.....WELCOME.., " + username); } else { Send(client, "Login Failed"); System.Environment.Exit(1); /// if invalid login EXIT } Console.Write("Loading...... Prees ENTER to retrieve files"); string request = Console.ReadLine(); sendDone.WaitOne(); Console.Write("Files successfully Obtained........ENTER to open file"); string requestfile = Console.ReadLine(); ////// LIST OF FILES /////// Console.WriteLine(".................................LIST OF AUDIO FILES........................................."); Console.WriteLine(" 1: Wanna go shopping "); Console.WriteLine(" 2: Yummy "); Console.WriteLine(" 3: Thats it"); Console.Write("Send a request: "); msg = Console.ReadLine(); if (request.ToLower() == "exit") { System.Environment.Exit(1); } ///////////////////////// PLAY AUDIO /////////////////////////// var myPlayer = new System.Media.SoundPlayer(); if (msg == "Play") { myPlayer.SoundLocation = @"C:\Users\100430264\source\repos\SERVER\SERVER\bin\Debug\wanna-go-shopping.WAV"; myPlayer.Play(); } if (msg == "stop") { myPlayer.Stop(); myPlayer.Dispose(); } // Receive the response from the remote device. Receive(client); receiveDone.WaitOne(); // Get list of wav files // E.g. Get List string input = Console.ReadLine(); Send(client, input + "<EOF>"); sendDone.WaitOne(); // Receive the response from the remote device. Receive(client); receiveDone.WaitOne(); // Write the response to the console. Console.WriteLine("Response received : {0}", response); // Release the socket. client.Shutdown(SocketShutdown.Both); client.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
/// <summary> /// Update spike waveform window in Spike Scope /// </summary> public void DrawSpikes() { int i, j; int numSpikes; // Clear drawing area and draw simple grid lines myPanelBuffer.Graphics.Clear(SystemColors.Control); myPanelBuffer.Graphics.DrawLine(Pens.LightGray, 48, 0, 48, 300); myPanelBuffer.Graphics.DrawLine(Pens.LightGray, 98, 0, 98, 300); myPanelBuffer.Graphics.DrawLine(Pens.LightGray, 148, 0, 148, 300); myPanelBuffer.Graphics.DrawLine(Pens.LightGray, 198, 0, 198, 300); myPanelBuffer.Graphics.DrawLine(Pens.LightGray, 0, 150, 248, 150); if (mySpikeRecord.NumSpikesToShow == 0) numSpikes = 10; else if (mySpikeRecord.NumSpikesToShow == 1) numSpikes = 20; else numSpikes = 30; if (mySpikeRecord.SpikeCount < numSpikes) numSpikes = mySpikeRecord.SpikeCount; for (i = numSpikes - 1; i >= 0; i--) { mySpikeRecord.CopySpikeToArray(spikeSnippet, i); for (j = 0; j < 61; j++) { myPanelBuffer.Graphics.DrawLine(scopePens[mySpikeRecord.NumSpikesToShow, i], (float)(4 * j), 150.0F - YScaleFactors[yScaleIndex] * spikeSnippet[j], (float)(4 * j + 4), 150.0F - YScaleFactors[yScaleIndex] * spikeSnippet[j + 1]); } } // Draw spike detection threshold level myPanelBuffer.Graphics.DrawLine(Pens.Red, 0.0F, 150.0F - YScaleFactors[yScaleIndex] * mySpikeRecord.GetThreshold(), (float)(4 * 61 + 4), 150.0F - YScaleFactors[yScaleIndex] * mySpikeRecord.GetThreshold()); myPanelBuffer.Render(); if (mySpikeRecord.AudioEnabled) { // Generate quick audio wave file of spike in memory binWaveWriter.Seek(44, SeekOrigin.Begin); spikeSnippet[0] *= 0.125F; spikeSnippet[1] *= 0.25F; spikeSnippet[2] *= 0.5F; spikeSnippet[3] *= 0.75F; spikeSnippet[61] *= 0.125F; spikeSnippet[60] *= 0.25F; spikeSnippet[59] *= 0.5F; spikeSnippet[58] *= 0.75F; float f; float vol = (float)mySpikeRecord.AudioVolume; for (int k = 0; k < 62; k++) { f = vol * vol * 10.0F * spikeSnippet[k]; if (f > 32767.0F) f = 32767.0F; else if (f < -32767.0F) f = -32767.0F; binWaveWriter.Write((Int16)f); } binWaveWriter.Seek(0, SeekOrigin.Begin); // Play wave file of spike from memory SoundPlayer smallSoundPlayer = new SoundPlayer(); smallSoundPlayer.Stream = memWave; smallSoundPlayer.Load(); smallSoundPlayer.Play(); smallSoundPlayer.Dispose(); } }
//float rotation = 0; //void Application_Idle(object sender, EventArgs e) //{ // double milliseconds = ComputeTimeSlice(); // Accumulate(milliseconds); // Animate(milliseconds); //} //private double ComputeTimeSlice() //{ // sw.Stop(); // double timeslice = sw.Elapsed.TotalMilliseconds; // sw.Reset(); // sw.Start(); // return timeslice; //} //private void Animate(double milliseconds) //{ // float deltaRotation = (float)milliseconds / 20.0f; // rotation += deltaRotation; // glControl.Invalidate(); // WorkPool.QueueUserWorkItem(sync => // { // if (client.Network.CurrentSim.ObjectsPrimitives.ContainsKey(RootPrimLocalID)) // { // UpdatePrimBlocking(client.Network.CurrentSim.ObjectsPrimitives[RootPrimLocalID]); // var children = client.Network.CurrentSim.ObjectsPrimitives.FindAll((Primitive p) => { return p.ParentID == RootPrimLocalID; }); // children.ForEach(p => UpdatePrimBlocking(p)); // } // } // ); //} //double accumulator = 0; //int idleCounter = 0; //private void Accumulate(double milliseconds) //{ // idleCounter++; // accumulator += milliseconds; // if (accumulator > 1000) // { // label1.Text = idleCounter.ToString(); // accumulator -= 1000; // idleCounter = 0; // don't forget to reset the counter! // } //} private void glControl_Paint(object sender, PaintEventArgs e) { if (!RenderingEnabled) return; //// A LL OpenTK.Graphics.OpenGL.GL.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit | OpenTK.Graphics.OpenGL.ClearBufferMask.DepthBufferBit); glControl.MakeCurrent(); Render(false); OpenTK.Graphics.OpenGL.GL.ClearColor(clearcolour); glControl.SwapBuffers(); // A LL if (TakeScreenShot) { if (snapped) { SoundPlayer simpleSound = new SoundPlayer(Properties.Resources.camera_clic_with_flash); simpleSound.Play(); simpleSound.Dispose(); capScreenBeforeNextSwap(); TakeScreenShot = false; snapped = false; } } }
private static void Func(SoundPlayer player) { player.Dispose(); }
public void playTorpedoFire() { System.Media.SoundPlayer torpedo = new System.Media.SoundPlayer("../../sounds/torpedoKort.wav"); torpedo.Play(); torpedo.Dispose(); }
private void RacingHorses_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Bitmap bmp = new Bitmap(@"Resources\background.png"); Graphics gTemp = Graphics.FromImage(bmp); dice.Draw(gTemp); if (vic.index != -1 && vic.nType != 0) { cage[vic.nType - 1].Update(vic.index); SoundPlayer snd = new SoundPlayer(@"Resources\Audio\kick.wav"); snd.LoadAsync(); snd.Play(); vic.index = -1; snd.Dispose(); vic.nType = 0; } for (int i = 0; i < nCage; i++) cage[i].Draw(gTemp, board); Bitmap bmpShield = new Bitmap(@"Resources\ImageIcon\shield.png"); for (int i = 0; i < 55; i++) if (board.arrSquares[i].shadow != 0) { Point pSquares = board.arrSquares[i].square; gTemp.DrawImage(bmpShield, pSquares.X, pSquares.Y - 10, 20, 20); } if (bombarr.Count > 0) { for (int i = 0; i < bombarr.Count; i++) { Point pBombarr = board.arrSquares[i].square; int team = board.arrSquares[i].bomb; if (team != 0) gTemp.DrawImage(imglstBomb.Images[team - 1], pBombarr.X, pBombarr.Y + 10); } } g.DrawImage(bmp, 0, 0, 800, 600); gTemp.Dispose(); bmp.Dispose(); bmpShield.Dispose(); win = cage[turn].Win(); if (win) { btnBomb.Enabled = true; btnCross.Enabled = true; btnGetTurn.Enabled = true; btnHide.Enabled = true; btnShield.Enabled = true; btnSpeedup.Enabled = true; pShake.Enabled = true; pString.Enabled = true; } }
static void StartGame(string question, string answer) { ModifyInfoBar(question, answer); var randomGenerator = new Random(); var player = new Player(consoleWidth / 2, consoleHeight - 4); PrintOnPosition(player.X, player.Y, player.Str, player.Color); var watch = Stopwatch.StartNew(); var watchBombs = Stopwatch.StartNew(); // Define dropping bombs in given time i.e how frequent will a new bomb drop. var watchLetters = Stopwatch.StartNew(); // Same for letters. var watchDels = Stopwatch.StartNew(); // Same for deletes. var fallingObjects = new List <FallingObject>(); ConsoleKeyInfo pressedKey; SoundPlayer soundPlayer = new System.Media.SoundPlayer(@"..\..\Data\Sounds\DropThat.wav"); soundPlayer.Load(); while (true) { #region Pressed Key, Moving Playes while (Console.KeyAvailable) { pressedKey = Console.ReadKey(true); oldPosition = player.X; if (pressedKey.Key == ConsoleKey.LeftArrow) { if ((player.X - 1) >= 1) // >= 1 Because of the boundaries of the user interface. { player.MovePlayer(-1); PrintOnPosition(oldPosition + 2, player.Y, " ", player.Color); } } else if (pressedKey.Key == ConsoleKey.RightArrow) { if (player.X + 2 < (consoleWidth - 2)) // < ConsoleWidth - 2, because of the boundaries of the user interface. { player.MovePlayer(1); PrintOnPosition(oldPosition, player.Y, " ", player.Color); } } if (pressedKey.Key == ConsoleKey.Q) { if (questions.Count >= 1 && answers.Count >= 1) { indexOfCatchedLetter = 0; Console.SetCursorPosition(0, 4); RedrawQuestionBar(DrawNewQuestion()); Console.SetCursorPosition(0, 8); RedrawAnswerBar(container); } } if (pressedKey.Key == ConsoleKey.P) { soundPlayer.Play(); } if (pressedKey.Key == ConsoleKey.S) { soundPlayer.Stop(); } if (pressedKey.Key == ConsoleKey.T) //Only for the presentation. REMOVE AFTER { PauseGame(); } PrintOnPosition(player.X, player.Y, player.Str, player.Color); } #endregion #region Adding falling objects to list #region Add bombs to list // Add bombs to list if (watchBombs.ElapsedMilliseconds >= 400) // Define how frequent bombs are droping { int randomXPosition = randomGenerator.Next(2, consoleWidth - 2); var bomb = new Bomb(randomXPosition, gameFieldTop); fallingObjects.Add(bomb); watchBombs.Restart(); } #endregion #region Add deletes to list // Add dels to list if (watchDels.ElapsedMilliseconds >= 2000) // Define how frequent deletes are droping { var del = new Del(randomGenerator.Next(2, consoleWidth - 2), gameFieldTop); fallingObjects.Add(del); watchDels.Restart(); } #endregion #endregion if (watch.ElapsedMilliseconds >= 200) { #region Add falling letters string currentAnswer = correctAnswer; string randomLetter = (currentAnswer[randomGenerator.Next(currentAnswer.Length)]).ToString(); int lettersPerRowMax = 2; int lettersCountNewRow = random.Next(0, lettersPerRowMax); for (int i = 0; i < lettersCountNewRow; i++) { int randomXPosition = randomGenerator.Next(2, consoleWidth - 2); var letter = new Letter(randomXPosition, gameFieldTop, randomLetter); fallingObjects.Add(letter); } #endregion // Move objects for (int i = 0; i < fallingObjects.Count; i++) { if (fallingObjects[i].Y < consoleHeight - 4) { PrintOnPosition(fallingObjects[i].X, fallingObjects[i].Y, " ", ConsoleColor.White); fallingObjects[i].FallDown(); PrintOnPosition(fallingObjects[i].X, fallingObjects[i].Y, fallingObjects[i].Str, fallingObjects[i].Color); CollisionDetection(fallingObjects[i], player); // TODO: call when player moves } // Remove objects from the playfield else if (fallingObjects[i].Y == consoleHeight - 4) { PrintOnPosition(fallingObjects[i].X, fallingObjects[i].Y, " ", fallingObjects[i].Color); fallingObjects[i].FallDown(); } } watch.Restart(); //falling objects garbage collection //CAUTION !1!!1ONE!!11 do not delete anything that hasn't been erased from the console yet //Side effects may include Falling Snow Effect (the object sticks to the bottom of the screen) if (fallingObjects.Count > 70 && fallingObjects[40].Y >= consoleHeight - 4) { fallingObjects.RemoveRange(0, 30); } } //End Game handling #region Game end handling if (container[container.Length - 1] != '*') { container = container.ToUpper(); if (container.Equals(correctAnswer) && questions.Count >= 1 && answers.Count >= 1) { score += (correctAnswer.Length * 20); livesCount++; indexOfCatchedLetter = 0; Console.SetCursorPosition(0, 1); RedrawLivesBar(); Console.SetCursorPosition(0, 4); RedrawQuestionBar(DrawNewQuestion()); Console.SetCursorPosition(0, 8); RedrawAnswerBar(container); isGameOver = false; } else if (container.Equals(correctAnswer) && (questions.Count == 0 || answers.Count == 0)) { score += (correctAnswer.Length * 20); livesCount++; Console.SetCursorPosition(0, 1); RedrawLivesBar(); isGameOver = true; } else if ((!container.Equals(correctAnswer) && (questions.Count == 0 || answers.Count == 0))) { livesCount--; Console.SetCursorPosition(0, 1); RedrawLivesBar(); isGameOver = true; } else if (questions.Count >= 1 && answers.Count >= 1) { indexOfCatchedLetter = 0; livesCount--; if (livesCount == 0) { Console.SetCursorPosition(0, 1); RedrawLivesBar(); isGameOver = true; } else { Console.SetCursorPosition(0, 1); RedrawLivesBar(); Console.SetCursorPosition(0, 4); RedrawQuestionBar(DrawNewQuestion()); Console.SetCursorPosition(0, 8); RedrawAnswerBar(container); isGameOver = false; } } else { isGameOver = true; } } if (isGameOver) { container = container.ToUpper(); if (correctAnswer.Equals(container)) { GameOverScreen(); soundPlayer.Dispose(); Console.ReadLine(); return; } else if (livesCount == 0) { GameOverScreen(); soundPlayer.Dispose(); Console.ReadLine(); return; } } #endregion } }
//+++++++++++++++ Button ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// private void btnShake_Click(object sender, EventArgs e) { SoundPlayer sound = new SoundPlayer(@"Resources\Audio\Click.wav"); sound.LoadAsync(); sound.Play(); sound.Dispose(); btnShake.Visible = false; pShake.Visible = true; go = Shaking(); changeTurn(go); if (cage[turn].CanAction(go)) { if (!useProp) // chưa dùng đạo cụ { bool[] buffs = props.getState(); for (int i = 0; i < 6; i++) btnBuff[i].Enabled = buffs[i]; } for (int i = 0; i < cage[turn].nPieces; i++) { cage[turn].Pieces[i].IsChoice = false; } isClick = true; } else { if (go == 1 || go == 6) { btnShake.Visible = true; pShake.Visible = false; } if (go != 1 && go != 6) //Khong them luot { if (!cage[turn].GetTurn) { if (!useProp && hasProp) { for (int i = 0; i < 6; i++) btnBuff[i].Enabled = false; } for (int i = 0; i < cage[turn].nPieces; i++) { if (cage[turn].Pieces[i].IsChoice) cage[turn].Pieces[i].IsChoice = false; } //Xoa cross hoac speedup neu co buff if (cage[turn].Cross) { cage[turn].Cross = false; cage[turn].clearbuff(board); } if (cage[turn].SpeedUp) { cage[turn].SpeedUp = false; cage[turn].clearbuff(board); } if (cage[nextturn].Hide) // Xoa dao cu cua dich { for (int i = 0; i < cage[nextturn].nPieces; i++) { MyPieces p = cage[nextturn].Pieces[i]; if (p.Started && !p.Ended) { int t = board.arrSquares[p.curIndex % 56].status; if (t != nextturn + 1) { if (t != 0) { int team = board.arrSquares[p.curIndex % 56].status - 1; int index = board.arrSquares[p.curIndex % 56].curIndex; cage[team].Update(index); sound = new SoundPlayer(@"Resources\Audio\Kick.wav"); sound.LoadAsync(); sound.Play(); sound.Dispose(); this.Invoke(new AntiCrossThreadNoArgument(Refresh)); //Thread.Sleep(20); } board.arrSquares[p.curIndex % 56].status = nextturn + 1; board.arrSquares[p.curIndex % 56].curIndex = i; } } } cage[nextturn].Hide = false; cage[nextturn].clearbuff(board); } if (cage[nextturn].Shield) // Xoa dao cu cua dich { cage[nextturn].Shield = false; cage[nextturn].clearbuff(board); } int dem = 0; for (int i = 0; i < cage[turn].nPieces; i++) if (cage[turn].Pieces[i].Started && !cage[turn].Pieces[i].Ended) dem++; useProp = false; if (!cage[nextturn].isPlayer) { Thread thread_AI = new Thread(Thread_AI); thread_AI.Start(); } else { changeImageTurn(); btnShake.Visible = true; pShake.Visible = false; } } else { //Co them luot cage[turn].GetTurn = false; MessageBox.Show("Thêm lượt! Tiến hành lượt quay tiếp theo"); btnShake.Visible = true; nextturn = turn; pShake.Visible = false; } } } }
public vicPiece Start(MyBoard board, int index) { vicPiece vic = new vicPiece(); vic.index = -1; vic.nType = 0; //KT bomb if (board.arrSquares[_startIndex].bomb != 0 && board.arrSquares[_startIndex].bomb != nType && Buff != 2) //Co bomb k fai cua doi minh { board.arrSquares[_startIndex].shield = 0; board.arrSquares[_startIndex].shadow = 0; InCage(); board.arrSquares[_startIndex].bomb = 0; SoundPlayer sound1 = new SoundPlayer(@"Resources\Audio\ExClose.wav"); sound1.LoadAsync(); sound1.Play(); sound1.Dispose(); Started = false; Ended = false; return vic; } if (board.arrSquares[_startIndex].shadow != 1) { vic.nType = board.arrSquares[_startIndex].status; vic.index = board.arrSquares[_startIndex].curIndex; } _curPoint = start; _curIndex = _startIndex; board.arrSquares[_curIndex].status = nType; board.arrSquares[_curIndex].curIndex = index; SoundPlayer sound = new SoundPlayer(@"Resources\Audio\Start.wav"); sound.LoadAsync(); sound.Play(); sound.Dispose(); return vic; }
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //+++++++++++++++++++++++++++ Computer AI +++++++++++++++++++++++++++++++++++++++++++++++++++// private void comAI() { go = Shaking(); changeTurn(go); //Kiểm tra sử dụng Hổ báo if (hasProp) { isCrossUsed(); } if (cage[turn].CanAction(go)) { if (hasProp) { isActiveProp(); } int pieceindex; if ((cage[turn].Cross || cage[turn].SpeedUp || cage[turn].GetTurn) && cage[turn].PriP != -2) { pieceindex = cage[turn].PriP + 10; if (cage[turn].Pieces[pieceindex - 10].moveFail(go, board)) { pieceindex = cage[turn].CheckPieceAI(go); } cage[turn].PriP = -2; } else { pieceindex = cage[turn].CheckPieceAI(go); } if (pieceindex >= 10 && pieceindex <= 13) { if (cage[turn].SpeedUp) go = SpeedUp(turn, pieceindex - 10, go); Process(turn, pieceindex - 10); } else { if (pieceindex >= 20) { vic = cage[turn].Action_AI(go, pieceindex - 20); this.Invoke(new AntiCrossThreadNoArgument(Refresh)); if (win) goto exit; } if (pieceindex < 10) { vic = cage[turn].Action_AI(go, pieceindex); this.Invoke(new AntiCrossThreadNoArgument(Refresh)); } } } if (turn == nextturn) { comAI(); } else { if (!cage[turn].GetTurn) { pString.Image = imglstString.Images[nextturn]; if (!pString.InvokeRequired) pString.Visible = true; else pString.Invoke(new AntiCrossThread2Argument(SetVisible), pString, true); //Refresh(); //Xóa đạo cụ chủ động nếu có xài if (cage[turn].Cross) { cage[turn].Cross = false; cage[turn].clearbuff(board); } if (cage[turn].SpeedUp) { cage[turn].SpeedUp = false; cage[turn].clearbuff(board);//bug } if (cage[nextturn].Hide) //Xóa đạo cụ của địch { for (int i = 0; i < cage[nextturn].nPieces; i++) { MyPieces p = cage[nextturn].Pieces[i]; if (p.Started && !p.Ended) { int t = board.arrSquares[p.curIndex % 56].status; if (t != nextturn + 1) { if (t != 0) { int team = board.arrSquares[p.curIndex % 56].status - 1; int index = board.arrSquares[p.curIndex % 56].curIndex; cage[team].Update(index); SoundPlayer sound = new SoundPlayer(@"Resources\Audio\Kick.wav"); sound.LoadAsync(); sound.Play(); sound.Dispose(); this.Invoke(new AntiCrossThreadNoArgument(Refresh)); //Thread.Sleep(300); } board.arrSquares[p.curIndex % 56].status = nextturn + 1; board.arrSquares[p.curIndex % 56].curIndex = i; } } } cage[nextturn].Hide = false; cage[nextturn].clearbuff(board); } if (cage[nextturn].Shield) // Xóa đạo cụ của địch { cage[nextturn].Shield = false; cage[nextturn].clearbuff(board); } for (int i = 0; i < cage[turn].nPieces; i++) { if (cage[turn].Pieces[i].IsChoice) cage[turn].Pieces[i].IsChoice = false; } this.Invoke(new AntiCrossThreadNoArgument(Refresh)); if (cage[turn].Useprop) cage[turn].Useprop = false; //KT dùng passiveprop sau khi kết thúc lượt đi if (hasProp) { isPassiveProp(); } //Thread.Sleep(200); pString.Invoke(new AntiCrossThread2Argument(SetVisible), pString, false); pShake.Invoke(new AntiCrossThread3Argument(SetImage), pShake, imglstShake.Images[nextturn], 1); btnShake.Invoke(new AntiCrossThread3Argument(SetImage), btnShake, imglstShake.Images[nextturn], 0); turn = nextturn; if (cage[nextturn].isPlayer) { pShake.Invoke(new AntiCrossThread2Argument(SetVisible), pShake, false); btnShake.Invoke(new AntiCrossThread2Argument(SetVisible), btnShake, true); } else { comAI(); } } else { MessageBox.Show("Tiếp tục 1 lượt nữa."); cage[turn].GetTurn = false; nextturn = turn; //Refresh(); comAI(); } } exit: if (win && !first) { first = true; Congratulation(turn); this.Invoke(new AntiCrossThreadNoArgument(frmMenu.Show)); this.Invoke(new AntiCrossThreadNoArgument(Dispose)); } }
private void PlaySounds(Object objSignalList) { List<Signalod> signalList=(List<Signalod>)objSignalList; string strSound; byte[] rawData; MemoryStream stream=null; SoundPlayer simpleSound=null; try { //loop through each signal for(int s=0;s<signalList.Count;s++) { if(signalList[s].AckTime.Year>1880) { continue;//don't play any sounds for acks. } if(s>0) { Thread.Sleep(1000);//pause 1 second between signals. } //play all the sounds. for(int e=0;e<signalList[s].ElementList.Length;e++) { strSound=SigElementDefs.GetElement(signalList[s].ElementList[e].SigElementDefNum).Sound; if(strSound=="") { continue; } try { rawData=Convert.FromBase64String(strSound); stream=new MemoryStream(rawData); simpleSound = new SoundPlayer(stream); simpleSound.PlaySync();//sound will finish playing before thread continues } catch { //do nothing } } } } finally { if(stream!=null) { stream.Dispose(); } if(simpleSound!=null) { simpleSound.Dispose(); } } }
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //++++++++++++++++++++++++++++ Player +++++++++++++++++++++++++++++++++++++++++++++++++++++++// public void playerProcess() { if (turn != nextturn) { if (!cage[turn].GetTurn) { btnShake.Visible = false; pShake.Visible = true; if (!useProp && hasProp) { for (int i = 0; i < 6; i++) btnBuff[i].Enabled = false; } else { useProp = false; } for (int i = 0; i < cage[turn].nPieces; i++) { if (cage[turn].Pieces[i].IsChoice) cage[turn].Pieces[i].IsChoice = false; } if (cage[turn].Cross) { cage[turn].Cross = false; cage[turn].clearbuff(board); } if (cage[turn].SpeedUp) { cage[turn].SpeedUp = false; cage[turn].clearbuff(board); } if (cage[nextturn].Hide) // Xoa dao cu cua dich { for (int i = 0; i < cage[nextturn].nPieces; i++) { MyPieces p = cage[nextturn].Pieces[i]; if (p.Started && !p.Ended) { int t = board.arrSquares[p.curIndex % 56].status; if (t != nextturn + 1) { if (t != 0) { int team = board.arrSquares[p.curIndex % 56].status - 1; int index = board.arrSquares[p.curIndex % 56].curIndex; cage[team].Update(index); SoundPlayer sound = new SoundPlayer(@"Resources\Audio\Kick.wav"); sound.LoadAsync(); sound.Play(); sound.Dispose(); this.Invoke(new AntiCrossThreadNoArgument(Refresh)); //Thread.Sleep(20); } board.arrSquares[p.curIndex % 56].status = nextturn + 1; board.arrSquares[p.curIndex % 56].curIndex = i; } } } cage[nextturn].Hide = false; cage[nextturn].clearbuff(board); } if (cage[nextturn].Shield) //Xóa đạo cụ của địch { cage[nextturn].Shield = false; cage[nextturn].clearbuff(board); } Refresh(); //newthread.Resume(); //StartAI = true; if (!cage[nextturn].isPlayer) { Thread thread_AI = new Thread(Thread_AI); thread_AI.Start(); } else { changeImageTurn(); btnShake.Visible = true; pShake.Visible = false; } } else //Them luot { cage[turn].GetTurn = false; MessageBox.Show("Thêm lượt! Tiến hành lượt quay tiếp theo"); nextturn = turn; btnShake.Visible = true; pShake.Visible = false; } } else { btnShake.Visible = true; pShake.Visible = false; } }
private void Self_MoneyBalanceReply(object sender, MoneyBalanceReplyEventArgs e) { if (floading) { tmoneybalance = e.Balance; floading = false; return; } TransactionInfo ti = e.TransactionInfo; if (ti.DestID != UUID.Zero && ti.SourceID != UUID.Zero) { if (instance.Config.CurrentConfig.PlayPaymentReceived) { SoundPlayer simpleSound = new SoundPlayer(Properties.Resources.MoneyBeep); simpleSound.Play(); simpleSound.Dispose(); } } //tabs["chat"].Highlight(); int bal = e.Balance - tmoneybalance; string ttl = "METAbolt Alert"; string body = string.Empty; if (bal > 0) { if (e.Success) { if (ti.DestID != client.Self.AgentID) { body = e.Description; } else { if (!String.IsNullOrEmpty(e.Description)) { string pfrm = string.Empty; if (ti.TransactionType == 5008) { pfrm = " via " + ti.ItemDescription; } body = e.Description + pfrm; body = body.Replace(".", string.Empty); } else { if (!String.IsNullOrEmpty(ti.ItemDescription)) { body = "You have received a payment of L$" + ti.Amount.ToString(CultureInfo.CurrentCulture) + " from " + ti.ItemDescription; } else { body = "You have received a payment of L$" + ti.Amount.ToString(CultureInfo.CurrentCulture); } } } } TrayNotifiy(ttl, body, false); } else { ////body = e.Description; //if (ti.DestID != client.Self.AgentID) //{ // if (!String.IsNullOrEmpty(ti.ItemDescription)) // { // body = "You paid L$" + ti.Amount.ToString() + " to/for " + ti.ItemDescription; // } // else // { // body = "You paid L$" + ti.Amount.ToString(); // } //} //else //{ // body = e.Description; //} if (!String.IsNullOrEmpty(e.Description)) { body = e.Description; TrayNotifiy(ttl, body, false); } } tmoneybalance = e.Balance; }
private void Process(int t, int index) { for (int i = 0; i < cage[turn].nPieces; i++) if (cage[turn].Pieces[i].IsChoice) cage[turn].Pieces[i].IsChoice = false; SoundPlayer sound = new SoundPlayer(@"Resources\Audio\move.wav"); sound.LoadAsync(); sound.Play(); sound.Dispose(); int count = 0; while (count < go) { count++; vic = cage[t].Pieces[index].MoveSteponStep(board, index); if (vic.nType == -2) { this.Invoke(new AntiCrossThreadNoArgument(Refresh)); break; } if (!this.InvokeRequired) { Refresh(); } else { this.Invoke(new AntiCrossThreadNoArgument(Refresh)); } } }
//Separate thread private void Friends_OnFriendOnline(object sender, FriendInfoEventArgs e) { if (InvokeRequired) { BeginInvoke(new MethodInvoker(() => Friends_OnFriendOnline(sender, e))); return; } if (!string.IsNullOrEmpty(e.Friend.Name) && !string.IsNullOrEmpty(avname)) { if (!instance.Config.CurrentConfig.DisableFriendsNotifications) { if (instance.Config.CurrentConfig.PlayFriendOnline) { SoundPlayer simpleSound = new SoundPlayer(Properties.Resources.Friend_On); simpleSound.Play(); simpleSound.Dispose(); } string ttl = "METAbolt Alert"; string body = e.Friend.Name + " is online"; TrayNotifiy(ttl, body, false); } } }
public void playExplosionSound() { System.Media.SoundPlayer explosion = new System.Media.SoundPlayer("../../sounds/explosion.wav"); explosion.Play(); explosion.Dispose(); }
private void BgwScriptDncDoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { const double scanInterval = 0.3; while (botRunning && !bgw_script_dnc.CancellationPending) { //TargetInfo.SetTarget(0); if ((PlayerInfo.Status == 2 || PlayerInfo.Status == 3) && File.Exists(Application.StartupPath + @"\dead.wav")) { using (SoundPlayer player = new SoundPlayer(Application.StartupPath + @"\dead.wav")) { player.PlaySync(); player.Dispose(); } } if (checkZone.Checked && startzone != api.Player.ZoneId) ToolStopClick(null, null); if (DeathWarp.Checked && (PlayerInfo.Status == 2 || PlayerInfo.Status == 3)) PlayerDead(); if (isCasting) continue; if (followplayer.Checked && PlayerInfo.Status == 0) FollowTarget(); if ((assist.Checked || partyAssist.Checked) && PlayerInfo.Status == 0) Assist(); if (aggro.Checked && PlayerInfo.Status == 0 && !isPulled) DetectAggro(); if (PlayerInfo.Status == 0 && !isPulled && SelectedTargets.Items.Count != 0) FindTarget(); while (PlayerInfo.Status == 1 && botRunning && TargetInfo.ID > 0) { isPulled = true; if (naviMove) naviMove = false; if (ignoreTarget.Count > 0) ignoreTarget.Clear(); #region Check Target Distance if (mobdist.Checked) { if (TargetInfo.Distance >= (float)KeepTargetRange.Value && TargetInfo.HPP > 1) { isMoving = true; while (TargetMoving() && PlayerInfo.Status == 1 && botRunning) { Thread.Sleep(TimeSpan.FromSeconds(0.1)); } while (TargetInfo.Distance >= (float)KeepTargetRange.Value && TargetInfo.HPP > 1 && PlayerInfo.Status == 1 && botRunning) { api.AutoFollow.SetAutoFollowCoords(TargetInfo.X - PlayerInfo.X, TargetInfo.Y - PlayerInfo.Y, TargetInfo.Z - PlayerInfo.Z); api.AutoFollow.IsAutoFollowing = true; Thread.Sleep(TimeSpan.FromSeconds(0.1)); if (TargetInfo.ID == 0 || TargetInfo.ID == PlayerInfo.ServerID) break; if (mobStuckWatch.Checked && isStuck(true)) { int count = 0; float dir = -45; while (isStuck(true)) { if (TargetInfo.ID == 0 || TargetInfo.ID == PlayerInfo.ServerID) break; api.Entity.GetLocalPlayer().H = PlayerInfo.H + (float)((Math.PI / 180) * dir); WindowInfo.KeyDown(API.Keys.NUMPAD8); Thread.Sleep(TimeSpan.FromSeconds(2)); WindowInfo.KeyUp(API.Keys.NUMPAD8); count++; if (count == 4) { dir = (dir == -45 ? 45 : -45); count = 0; } } WindowInfo.KeyUp(API.Keys.NUMPAD8); } } api.AutoFollow.IsAutoFollowing = false; isMoving = false; } if (TargetInfo.Distance < 2 && TargetInfo.HPP > 1 && PlayerInfo.Status == 1 && TargetInfo.ID > 0) { while (TargetInfo.Distance < 2 && TargetInfo.HPP > 1 && PlayerInfo.Status == 1 && TargetInfo.ID > 0) { WindowInfo.KeyDown(API.Keys.NUMPAD2); Thread.Sleep(TimeSpan.FromSeconds(0.1)); } WindowInfo.KeyUp(API.Keys.NUMPAD2); } } #endregion WindowInfo.KeyUp(API.Keys.NUMPAD8); WindowInfo.KeyUp(API.Keys.NUMPAD2); if (!TargetInfo.IsFacingTarget(PlayerInfo.X, PlayerInfo.Z, PlayerInfo.H, TargetInfo.X, TargetInfo.Z) && facetarget.Checked && TargetInfo.HPP > 1) TargetInfo.FaceTarget(TargetInfo.X, TargetInfo.Z); ninjaShadows(); #region Check Hate Control if (tank.Checked && selectedHateControl.Text != "" && PlayerInfo.Status == 1 && TargetInfo.ID > 0) { if (selectedHateControl.Text == @"Animated Flourish" && PlayerInfo.GetFinishingMoves() > 0 && Recast.GetAbilityRecast(221) == 0) { if (TargetInfo.HPP >= numericUpDown7.Value && TargetInfo.HPP <= numericUpDown6.Value && PlayerInfo.Status == 1 && TargetInfo.ID > 0) { api.ThirdParty.SendString("/ja \"Animated Flourish\" <t>"); Thread.Sleep(TimeSpan.FromSeconds(1.0)); } } if (selectedHateControl.Text == @"Provoke" && Recast.GetAbilityRecast(5) == 0) { if (TargetInfo.HPP >= numericUpDown7.Value && TargetInfo.HPP <= numericUpDown6.Value && PlayerInfo.Status == 1 && TargetInfo.ID > 0) { api.ThirdParty.SendString("/ja \"Provoke\" <t>"); Thread.Sleep(TimeSpan.FromSeconds(1.0)); } } if (selectedHateControl.Text == @"Flash" && PlayerInfo.MPP >= 25 && Recast.GetAbilityRecast(112) == 0) { if (TargetInfo.HPP >= numericUpDown7.Value && TargetInfo.HPP <= numericUpDown6.Value && PlayerInfo.Status == 1 && TargetInfo.ID > 0) { api.ThirdParty.SendString("/ma \"Flash\" <t>"); Casting(); } } } #endregion HealingWaltz(); if (usecurev.Checked || usecureiv.Checked || usecureiii.Checked || usecureii.Checked || usecure.Checked) CuringWaltzSelf(); if (ptusecurev.Checked || ptusecureiv.Checked || ptusecureiii.Checked || ptusecureii.Checked || ptusecure.Checked) CuringWaltzParty(); if ((usedrain.Checked || usedrainii.Checked || usedrainiii.Checked || useaspir.Checked || useaspirii.Checked || usehaste.Checked) && !noSamba.Checked) Sambas(); if ((usequickstep.Checked || useboxstep.Checked || usestutterstep.Checked || usefeatherstep.Checked) && !NoSteps.Checked) Steps(); #region Check AutoRange Attack if (autoRangeAttack.Checked && TargetInfo.ID > 0) { api.ThirdParty.SendString(textBox7.Text); var delay = DateTime.Now.AddSeconds((double)autoRangeDelay.Value); while (DateTime.Now < delay) { if (PlayerInfo.Status == 0) break; TargetInfo.FaceTarget(TargetInfo.X, TargetInfo.Z); Thread.Sleep(TimeSpan.FromSeconds(1.0)); } } #endregion #region Check Use Food if (usefood.Checked) { var name = foodName.Text; if (!PlayerInfo.HasBuff(251) && name != "" && Inventory.ItemQuantityByName(name) > 0) { api.ThirdParty.SendString("/item \"" + name + "\" <me>"); Thread.Sleep(TimeSpan.FromSeconds(10.0)); } } #endregion PlayerJA(); PlayerWS(); PlayerMA(); if (PlayerInfo.GetFinishingMoves() > 0) { if (userevfloValue.Value > 0 || usebldfloValue.Value > 0 || usewldfloValue.Value > 0 || useclmfloValue.Value > 0 || usestkfloValue.Value > 0 || useterfloValue.Value > 0) { if (TargetInfo.ID > 0) UseFlourish(); } } Thread.Sleep(TimeSpan.FromSeconds(0.1)); } #region check: scan delay & idle if (usenav.Checked && api.AutoFollow.IsAutoFollowing && !naviMove) api.AutoFollow.IsAutoFollowing = false; if (PlayerInfo.Status == 0 && PlayerInfo.Status != 0 && TargetInfo.HPP == 0) SetTarget(0); if (ScanDelay.Checked && !naviMove) { Thread.Sleep(TimeSpan.FromSeconds((double)numericUpDown38.Value)); } else if (!ScanDelay.Checked) { Thread.Sleep(TimeSpan.FromSeconds(scanInterval)); } if (IdleLocation.Checked && PlayerInfo.Status == 0 && (TargetInfo.ID == 0 || TargetInfo.ID == PlayerInfo.TargetID)) ReturnIdleLocation(); if (PlayerInfo.Status == 0 && isPulled) { isPulled = false; if (aggro.Checked && PlayerInfo.Status == 0) DetectAggro(); if (PlayerInfo.Status == 0 && ((HealHP.Checked && PlayerInfo.HPP <= healHPcount.Value) || (HealMP.Checked && PlayerInfo.MPP <= healMPcount.Value) || (healforAutomatonHP.Checked && PetInfo.HPP <= healforAutomatonHPset.Value) || (healforAutomatonMP.Checked && PetInfo.MPP <= healforAutomatonMPset.Value))) { Thread.Sleep(TimeSpan.FromSeconds(1.0)); if ((PlayerInfo.MainJob == 15 || PlayerInfo.SubJob == 15) && PetInfo.ID > 0) { if (SMNPetNames.Contains(PetInfo.Name)) { api.ThirdParty.SendString("/pet \"Release\" <me>"); Thread.Sleep(TimeSpan.FromSeconds(1.0)); } } api.ThirdParty.SendString("/heal on"); Thread.Sleep(TimeSpan.FromSeconds(1.0)); if (textBox6.Text != "") { PreHealMain = api.Resources.GetItem(api.Player.Main).Name[0]; PreHealSub = api.Resources.GetItem(api.Player.Sub).Name[0]; api.ThirdParty.SendString($"/equip Main \"{textBox6.Text}\""); } SetTarget(0); } if (PlayerInfo.Status == 0 && !isPulled) FindTarget(); } if ((TargetInfo.ID == 0 || TargetInfo.ID == PlayerInfo.TargetID) && PlayerInfo.Status == 0 && !naviMove) { useTrust(); if (Recast.GetAbilityRecast(218) == 0 && UseJigs.Checked) { if (SpectralJig.Checked && !PlayerInfo.HasBuff(69)) api.ThirdParty.SendString("/ja \"Spectral Jig\" <me>"); else if (ChocoboJig.Checked) api.ThirdParty.SendString("/ja \"Chocobo Jig\" <me>"); else if (ChocoboJigII.Checked) api.ThirdParty.SendString("/ja \"Chocobo Jig II\" <me>"); } SetTarget(0); } if (usenav.Checked && !naviMove && PlayerInfo.Status == 0) { if (TargetInfo.ID > 0) SetTarget(0); naviMove = true; } if (PlayerInfo.Status == 33) { var healdone = false; while (PlayerInfo.Status == 33 && (HealHP.Checked || HealMP.Checked || healforAutomatonHP.Checked || healforAutomatonMP.Checked)) { Thread.Sleep(TimeSpan.FromSeconds(0.1)); if (fullheal.Checked) { if ((PlayerInfo.MainJob == 9 || PlayerInfo.SubJob == 9) && PetInfo.Name != null) { if (PlayerInfo.HPP == 100 && PlayerInfo.MPP == 100 && PetInfo.HPP == 100 && PetInfo.MPP == 100) healdone = true; } else if (PlayerInfo.HPP == 100 && PlayerInfo.MPP == 100) healdone = true; } else if ((HealHP.Checked? PlayerInfo.HPP == 100 : true) && (HealMP.Checked? PlayerInfo.MPP == 100 : true) && (healforAutomatonHP.Checked? PetInfo.HPP == 100 : true) && (healforAutomatonMP.Checked? PetInfo.MPP == 100 : true)) healdone = true; if (healdone) { if (textBox6.Text != "" && healdone) { api.ThirdParty.SendString($"/equip Main \"{PreHealMain}\""); Thread.Sleep(TimeSpan.FromSeconds(1.0)); api.ThirdParty.SendString($"/equip Sub \"{PreHealSub}\""); } api.ThirdParty.SendString("/heal off"); Thread.Sleep(TimeSpan.FromSeconds(1.0)); } } } #endregion } WindowInfo.KeyUp(API.Keys.NUMPAD8); WindowInfo.KeyUp(API.Keys.NUMPAD2); api.AutoFollow.IsAutoFollowing = false; isMoving = false; }
public void playNewFerry() { System.Media.SoundPlayer newFerry = new System.Media.SoundPlayer("../../sounds/ferry.wav"); newFerry.Play(); newFerry.Dispose(); }