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;
            }
        }
Exemple #2
0
        /// <summary>
        /// Is executed when a new drive has been found.
        /// </summary>
        /// <param name="sender">The sender of this event.</param>
        /// <param name="e">The event arguments containing the changed drive.</param>
        private void NewDriveFound(object sender, RemovableDriveWatcherEventArgs e)
        {
            try {
                foundDrives = e.ChangedDrive;
                try {
                    sPlay.Stream = Properties.Resources.指纹识别成功;
                    sPlay.Load();
                    sPlay.Play();
                    //Thread.Sleep(1000);
                    sPlay.Stream = Properties.Resources.杨先生您好欢迎使用;
                    sPlay.Load();
                    sPlay.Play();
                }
                catch (Exception) {
                }
                var ih = new IniFiles(foundDrives.RootDirectory + "\\" + "Sec.ini");
                NameValueCollection Values = new NameValueCollection();
                ih.ReadSectionValues("HiddenFolders", Values);
                foreach (string key in Values)
                {
                    try {
                        var path = Values[key];
                        if (path != "")
                        {
                            listBox1.Items.Add(path);
                            //path += ".{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}";
                            DirectoryInfo d = new DirectoryInfo(path);
                            //if (path.LastIndexOf(".{", StringComparison.Ordinal) != -1) {
                            //    d.MoveTo(path.Substring(0, path.LastIndexOf(".", StringComparison.Ordinal)));
                            //}
                            d.Attributes = FileAttributes.Archive;
                        }
                    }
                    catch (Exception) {
                    }
                }

                try {
                    NameValueCollection blog = new NameValueCollection();
                    ih.ReadSectionValues("Blog", blog);
                    if (!string.IsNullOrEmpty(blog["User"]))
                    {
                        listBox2.Items.Add(blog["User"] + "\\********");
                    }
                }
                catch (Exception) {
                }
            }
            catch (Exception) {
            }
            //Console.WriteLine(string.Format("Found a new drive, the name is: {0}", e.ChangedDrive.Name));
        }
Exemple #3
0
        public Ball(Control control, float minX, float maxX, float minY, float maxY, Bat player1, Bat player2, GameState gameState)
            : base(control)
        {
            //Keep a reference to the gamestate around for updating the scores
            _gameState = gameState;

            //Limits for the ball to bounce
            _minX = minX;
            _maxX = maxX;
            _minY = minY;
            _maxY = maxY;

            reset(); //Must be called after the limits are set since it uses them!

            //The bats to check for collisions with
            _player1 = player1;
            _player2 = player2;

            //Look & feel
            control.BackColor = _color;
            control.Width = _radius;
            control.Height = _radius;
            setHeightWidth();

            // Create SoundPlayer Object
            _beep = new SoundPlayer("beep.wav");

            //Preload the sound file
            _beep.Load();
        }
Exemple #4
0
 private void play(String s)
 {
     System.Media.SoundPlayer sp = new SoundPlayer();
     if (s == "start")
     {
        sp.SoundLocation = "start.wav";
        sp.Load(); 
        sp.PlayLooping();
     }
     else
     {
         sp.SoundLocation = "stop.wav";
         sp.Load(); 
         sp.Play();
     }
 }
Exemple #5
0
 public void onePing()
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer();
     player.SoundLocation = Application.StartupPath + "\\tictac.wav";
     player.Load();
     player.Play();
 }
Exemple #6
0
 private void button2_Click(object sender, EventArgs e)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer();
     player.SoundLocation = @"C:\Users\87059\source\repos\MNIST\MNIST\DJ Blyatman,Russian Village Boys - Cyka Blyat.wav";
     player.Load();
     player.Play();
 }
Exemple #7
0
 private void EventSetter_Click(object sender, RoutedEventArgs e)
 {
     Debug.Print("EmitClickSound...");
     SoundPlayer sp = new SoundPlayer("click.wav");
     sp.Load();
     sp.Play();
 }
 private void Init()
 {
     soundplayer = new SoundPlayer {
         SoundLocation = filename
     };
     soundplayer.Load();
 }
        public AlternatePongExperiment()
        {
            InitializeComponent();

            sensors = new DistanceSensors();
            sensors.DistancesChanged += new DistanceSensors.DistancesChangedHandler(sensors_DistancesChanged);
            sensors.Connect();

            sound1 = new SoundPlayer("sounds/pong.wav"); sound1.Load();
            sound2 = new SoundPlayer("sounds/pong2.wav"); sound2.Load();
            sound3 = new SoundPlayer("sounds/pong3.wav"); sound3.Load();

            paddle1 = 0.5f; paddle2 = 0.5f;
            ball = new PointF(DisplayPanel.Width / 2, DisplayPanel.Height / 2);
            rand = new Random();
            ballSpeed = new PointF((rand.NextDouble() <= 0.5 ? -1 : 1) * BALL_SPEED_FACTOR, (float)(rand.NextDouble() * 2 * BALL_SPEED_FACTOR) - BALL_SPEED_FACTOR);

            Task.Factory.StartNew(() =>
            {
                DateTime startTime = DateTime.Now;
                ballStartTimer = BALL_START_TIMER;
                while (!IsDisposed)
                {
                    try
                    {
                        DateTime currTime = DateTime.Now;
                        UpdatePositions((float)(currTime - startTime).TotalSeconds);
                        Invoke(new MethodInvoker(delegate { DisplayPanel.Refresh(); }));
                        startTime = currTime;
                        Thread.Sleep(20);
                    }
                    catch { }
                }
            });
        }
Exemple #10
0
        public Engine(Framework framework)
        {
            PlaySounds = true;
            GameOn = 0;
            Players = new List<Player>();

            this.framework = framework;

            using (Stream wavFile = Assembly.GetExecutingAssembly().GetManifestResourceStream("RoboRallyNet.Resources.Explosion.wav"))
            {
                explosionPlayer = new SoundPlayer(wavFile);
                explosionPlayer.Load();
            }
            using (Stream wavFile = Assembly.GetExecutingAssembly().GetManifestResourceStream("RoboRallyNet.Resources.laser_blue.wav"))
            {
                laserPlayer = new SoundPlayer(wavFile);
                laserPlayer.Load();
            }
            using (Stream wavFile = Assembly.GetExecutingAssembly().GetManifestResourceStream("RoboRallyNet.Resources.pit.wav"))
            {
                pitPlayer = new SoundPlayer(wavFile);
                pitPlayer.Load();
            }

            // create the map
            MainMap = GameMap.CreateMap();
        }
Exemple #11
0
 private void button5_Click(object sender, EventArgs e)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer();
     player.SoundLocation = @"D:\l\Hero.wav";
     player.Load();
     player.Play();
 }
Exemple #12
0
 private void Form1_Load(object sender, EventArgs e)//Програш звуку та завантаження рекорду
 {
     System.Media.SoundPlayer Audio;
     Audio = new System.Media.SoundPlayer(Properties.Resources.main);
     Audio.Load();
     Audio.PlayLooping();
     Int32.TryParse(bestT, out best);
     label2.Text = best.ToString();
 }
Exemple #13
0
        private async void PlaySoundAsync(string filename)
        {
            using (var player = new System.Media.SoundPlayer(filename))
            {
                await Task.Run(() => { player.Load(); player.PlaySync(); });

                IsSoundPlaying = false;
            }
        }
 /// <summary>
 /// Play notes from wave files for each instrument radio button
 /// </summary>
 /// <param name="instrumentKeyboardRadioButton"></param>
 /// <param name="instrumentNote"></param>
 void PlayNoteOnInstrument(RadioButton instrumentKeyboardRadioButton, System.IO.UnmanagedMemoryStream instrumentNote)
 {
     if (instrumentKeyboardRadioButton.Checked)
     {
         System.Media.SoundPlayer sound = new System.Media.SoundPlayer(instrumentNote);
         sound.Load();
         sound.Play();
     }
 }
 //ChipSound wenn ein Spieler gewonnen hat
 public void playSoundViele1()
 {
     if (sound)
     {
         SoundPlayer sp = new SoundPlayer("Sounds/chips_viele1.wav");
         sp.Load();
         sp.Play();
     }
 }
Exemple #16
0
 /// <summary>
 /// Initialises paddle of a given size, position and colour. 
 /// </summary>
 /// <param name="paddleSize">the dimensions of the paddle</param>
 /// <param name="paddlePosition">the position of the paddle in the game</param>
 /// <param name="colour">the colour of the paddle</param>
 /// <param name="clientSize">the bounds of the world the paddle exists within</param>
 /// <param name="soundFileName">associates a sound with the paddle</param>
 public Paddle(Size paddleSize, Point paddlePosition, Color colour, Size clientSize, string soundFileName)
 {
     this.clientSize = clientSize;
     brush = new SolidBrush(colour);
     this.paddleSize = paddleSize;
     this.paddlePosition = paddlePosition;
     collisionSound = new SoundPlayer(soundFileName);
     collisionSound.Load();
 }
 //ChipSound wenn ein Spieler Bet'et
 public void playSoundEinsatz2()
 {
     if (sound)
     {
         SoundPlayer sp = new SoundPlayer("Sounds/einsatz2.wav");
         sp.Load();
         sp.Play();
     }
 }
 //ChipSound am Anfang wenn Karten und Chips an Spieler ausgegeben werden
 public void playSoundFallen6()
 {
     if (sound)
     {
         SoundPlayer sp = new SoundPlayer("Sounds/chips_fallen6.wav");
         sp.Load();
         sp.Play();
     }
 }
Exemple #19
0
 //ChipSound wenn ein Chip auf den Tisch gezogen wird
 public void playSoundEinChip2()
 {
     if (sound)
     {
         SoundPlayer sp = new SoundPlayer("Res/Sounds/einchip2.wav");
         sp.Load();
         sp.Play();
     }
 }
        public static void Initialize()
        {
            string windir = Environment.GetFolderPath(Environment.SpecialFolder.Windows);

            WindowsNotify = new SoundPlayer(windir + "\\Media\\Windows Notify.wav");
            WindowsNotify.Load();

            WindowsBalloon = new SoundPlayer(windir + "\\Media\\Windows Balloon.wav");
            WindowsBalloon.Load();
        }
Exemple #21
0
 private static void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     _welcomeSound = new SoundPlayer
     {
         SoundLocation =
             SandboxConfig.DataDirectory + @"\OKTR\" + Player.Instance.ChampionName + ".wav"
     };
     _welcomeSound.Load();
     _welcomeSound.Play();
 }
 public override void Run(PersonalityManager manager, Dictionary<string, string> arguments)
 {
     if (m_player == null)
     {
         m_player = new SoundPlayer();
         string directory = Path.GetDirectoryName(manager.ActivePersonality.SourceFile);
         m_player.SoundLocation = Path.Combine(directory, m_soundFile);
         m_player.Load();
     }
     m_player.Play();
 }
        private void PlaySound()
        {
            var sri = Application.GetResourceStream(new Uri("pack://application:,,,/Resources/notification_sound.wav"));

            if ((sri != null))
            {
                System.Media.SoundPlayer player = new System.Media.SoundPlayer(sri.Stream);
                player.Load();
                player.Play();
            }
        }
Exemple #24
0
        public MainWindow()
        {
            InitializeComponent();
            WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            NavigationService.Navigate(new Uri("WelcomePage.xaml", UriKind.Relative));

            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.SoundLocation = @"../../MySource/music/LobbyMusic.wav";
            player.Load();
            player.PlayLooping();
        }
        public SoundPool()
        {
            soundPlayers = new Dictionary<GameSound, SoundPlayer>();

            foreach (GameSound soundName in Enum.GetValues(typeof(GameSound)))
            {
                SoundPlayer player = new SoundPlayer("Sound/" + soundName.ToString() + ".wav");
                player.Load();
                soundPlayers.Add(soundName, player);
            }
        }
Exemple #26
0
        public AudioTests()
        {
            InitializeComponent();
            _blip = new SoundPlayer(Properties.Resources.blip);
            _blip.Load();
            _ding = new SoundPlayer(Properties.Resources.ding);
            _ding.Load();
            _alarm = new SoundPlayer(Properties.Resources.alarm);
            _alarm.Load();

            
        }
Exemple #27
0
        private void pulAnalyse(int i, int j)
        {
            if ((int)pulList[i] < KWNmin)
            {
                if (j == 0)
                {
                    pulAna = "运动强度未达标";
                }
                else
                {
                    pulseAnalyse.Text = "运动强度未达标";
                }
            }

            if (((int)pulList[i] < KWNmid) && ((int)pulList[i] >= KWNmin))
            {
                if (j == 0)
                {
                    pulAna = "运动强度适中";
                }
                else
                {
                    pulseAnalyse.Text = "运动强度适中";
                }
            }

            if (((int)pulList[i] < KWNmax) && ((int)pulList[i] >= KWNmid))
            {
                if (j == 0)
                {
                    pulAna = "轻微疲劳";
                }
                else
                {
                    pulseAnalyse.Text = "轻微疲劳";
                }
            }

            if ((int)pulList[i] >= KWNmax)
            {
                sp.Load();
                sp.Play();
                if (j == 0)
                {
                    pulAna = "过度疲劳";
                }
                else
                {
                    pulseAnalyse.Text = "过度疲劳";
                }
            }
        }
        public void playMenuSound()
        {
            player = new SoundPlayer(menuUri);
            player.Load();

            bool soundFinished = true;

            if (soundFinished)
            {
                soundFinished = false;
                Task.Factory.StartNew(() => { player.PlaySync(); soundFinished = true; });
            }
        }
 public virtual_numpad()
 {
     InitializeComponent();
     click_sound = new SoundPlayer();
     click_sound.SoundLocation = configurations.GetAbsolutePath() + configurations.keyboard_click_wav;
     click_sound.Load();
     click_sound.Play();
     keys = ka.NumpadAssignments;
     keyboard_canvas.TouchDown += new EventHandler<TouchEventArgs>(keyboard_TouchDown);
     keyboard_canvas.TouchUp += new EventHandler<TouchEventArgs>(keyboard_TouchUp);
     this.keyboard.Source = configurations.img_keyboard_numpad_pic;
     this.Loaded += new RoutedEventHandler(virtual_numpad_Loaded);
 }
        public MainWindow()
        {
            InitializeComponent();
            _player = new SoundPlayer();
            _timer = new DispatcherTimer();

            _timer.Tick += countdown_Tick;
            _timer.Interval = new TimeSpan(0, 0, 0, 0, 15);
            _countDownAnimation = this.FindResource("CountdownAnimation") as Storyboard;
            _blinkingTextAnimation = this.FindResource("BlinkingTextAnimate") as Storyboard; 
            _player.SoundLocation = "Loud-alarm-clock-sound.wav";
            _player.Load();
        }
Exemple #31
0
 public Alert(string message, string soundFile)
 {
     Message = message;
     if (soundFile != "none")
     {
         SoundAlert = new SoundPlayer(soundFile);
         SoundAlert.Load();
     }
     else
     {
         SoundAlert = null;
     }
 }
 private void BeginAnimate()
 {
     if (StaticData.Config.isVoice == "1")
     {
         SoundPlayer soundPlayer = new SoundPlayer();
         soundPlayer.SoundLocation = Application.StartupPath + "//folder.wav";
         if (File.Exists(soundPlayer.SoundLocation))
         {
             soundPlayer.Load();
             soundPlayer.Play();
         }
     }
 }
Exemple #33
0
 public AudioPlayer(string soundFile)
 {
     try
     {
         audioPlayer = new SoundPlayer();
         //audioPlayer.SoundLocation = System.IO.Directory.GetCurrentDirectory().ToString() + @"\Dependency\Sounds\" + soundFile;
         audioPlayer.SoundLocation = @"C:\Users\kimlar\Source\Repos\utb-flex\Flex\UTB-voicespeaker\Dependency\Sounds\" + soundFile;
         audioPlayer.Load();
     }
     catch (Exception e)
     {
         Console.WriteLine("An error occured: {0}", e);
     }
 }
Exemple #34
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (sf != null)
     {
         Stream str = new FileStream(sf.getFilename(), FileMode.Open, FileAccess.Read);
         snd = new SoundPlayer(str);
         duration = sf.getDuration();
         Thread markerThread = new Thread(new ThreadStart(this.drawMarker));
         snd.Load();
         markerThread.Start();
         snd.Play();
         str.Close();
     }
 }
        public override void start()
        {
            image = new Bitmap("images/personagem.png");
            image2 = new Bitmap("images/red.jpg");

            soundHit = new SoundPlayer("sounds/42899__freqman__canon-dos-d30-no-focus.wav");
            soundBounce = new SoundPlayer("sounds/13959__adcbicycle__7.wav");

            soundHit.Load();
            soundBounce.Load();

            point = new Point(0, 0);
            mousePoint = new Point(0, 0);
        }
        public void SpinChamber()
        {
            Random myRandom = new Random();

            ChamberNum = myRandom.Next(1, 7);

            turn   = 1;
            blocks = 2;

            System.Media.SoundPlayer spin = new System.Media.SoundPlayer();
            spin.SoundLocation = @"D:\C# Course 2019\Russian Roulette\Properties\Sounds\Spin.wav";
            spin.Load();
            spin.Play();
        }
Exemple #37
0
 public static void playSound(string filePath)
 {
     SoundPlayer sp = new SoundPlayer(filePath);
     try
     {
         sp.SoundLocation = filePath;
         sp.Load();
         sp.Play();
     }
     catch (Exception ex)
     {
         throw new Exception(string.Format("Midi File Trouble: {0} \r\n {1} \r\n {2}", filePath, ex.Message, ex.StackTrace));
     }
 }
Exemple #38
0
        public static SoundPlayer GetSoundFromFileName(string name)
        {
            string path = Application.StartupPath + "\\" + name;

            if (File.Exists(path) == false)
                return null;

            if (Path.GetExtension(path) != ".wav")
                return null;

            SoundPlayer sp = new SoundPlayer(path);
            sp.Load();
            return sp;
        }
 public static void PlaySound(string path)
 {
     if (!File.Exists(path))
         return;
     try
     {
         var player = new SoundPlayer(path);
         player.Load();
         player.Play();
     }
     catch
     {
         // ignored
     }
 }
        public static void InitSounds()
        {
            if (File.Exists(standardName))
            {
                standard = new SoundPlayer(standardName);
                standard.Load();
            }

            if (File.Exists(legendName))
            {
                legendary = new SoundPlayer(legendName);
                legendary.Load();
            }
            else
                legendary = standard;

            if (File.Exists(rareName))
            {
                rare = new SoundPlayer(rareName);
                rare.Load();
            }
            else
                rare = standard;

            if (File.Exists(craftingName))
            {
                crafting = new SoundPlayer(craftingName);
                crafting.Load();
            }
            else
                crafting = standard;

            if (File.Exists(magicName))
            {
                magic = new SoundPlayer(magicName);
                magic.Load();
            }
            else
                magic = standard;

            if (File.Exists(goblinName))
            {
                goblin = new SoundPlayer(goblinName);
                goblin.Load();
            }
            else
                goblin = standard;
        }
Exemple #41
0
 public static void AddSound(string name)
 {
     if (!soundLib.ContainsKey(name))
     {
         try
         {
             var soundPlayer = new SoundPlayer($"sounds/{name}");
             soundPlayer.Load();
             soundLib[name] = soundPlayer;
         }
         catch (Exception ex)
         {
             throw new Exception($"Error when loading {name} | {ex.Message}:", ex);
         }
     }
 }
Exemple #42
0
        public RealTimeFilterView()
        {
            InitializeComponent();
            for (int i = 0; i < icnt; i++)
            {
                Data[i] = 0;
            }
            RePaintTimer          = new Timer();
            RePaintTimer.Interval = 1000 / 20; // 10 fps should be ok ...
            RePaintTimer.Tick    += new EventHandler(RePaintTimer_Tick);
            RePaintTimer.Enabled  = true;
            editor.rtfv           = this;

            soundPlayer = new SoundPlayer(Properties.Resources.EKG_Sound_Effect__Extended_);
            soundPlayer.Load();
        }
Exemple #43
0
 public Pomodoro(string description)
 {
     this.state = State.IDLE;
     this.description = description;
     this.interruptions = new List<string>();
     this.totalInterruptDuration = 0;
     /*
     speak = new SpeechSynthesizer();
     speak.SelectVoiceByHints(VoiceGender.Female, VoiceAge.Adult);
     speak.Rate = 2;
      */
     timer = new Timer(1000);
     timer.Elapsed += new ElapsedEventHandler(OnTimeElapsed);
     spTicks = new SoundPlayer("sounds/tick.wav");
     spSpeech = new SoundPlayer("sounds/pomodoroStart.wav");
     spSpeech.Load();
 }
        public Game(Graphics g, Rectangle boundaries)
        {
            //Initialize the stars to plot a black background and to be able to add the stars to the
            //Canvas;
            this.g                 = g;
            this.boundaries.X      = 0;
            this.boundaries.Y      = 0;
            this.boundaries.Height = boundaries.Y;
            this.boundaries.Width  = boundaries.X;



            this.random = new Random();



            //Initializes two collections that keeps track of the shots fired respectively
            this.playerShots = new Shots();
            this.enemyShots  = new Shots();


            this.stars = new Stars(boundaries);
            Point initialPosition = new Point(boundaries.X / 2, boundaries.Y);

            this.playerShip = new PlayerShip(initialPosition, boundaries, playerShots, enemyShots, livesLeft);


            this.invaders = new Invaders(boundaries, playerShots, enemyShots, random, display);
            invaders.MoveInvaders();

            this.display = new Display(boundaries);



            //Plays the music for the life force
            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.SoundLocation = @"C:\GameMusic\LifeForce.wav";
            player.Load();
            player.Play();



            this.initialScreen = DateTime.Now;
            this.initialImage  = (Bitmap)Properties.Resources.ResourceManager.GetObject("LifeForce1");
        }
        public TightropeData(StreamWriter file, Calibration markerHeightCal)
        {
            outfile = file;
            outfile.Write("Right, Left\n");
            left = new Foot("left", markerHeightCal.LeftFoot);
            right = new Foot("right", markerHeightCal.RightFoot);
            
            sound = new SoundPlayer(@"D:/Test/Conga2.wav");
            sound.Load();

            Foot.FootDownDetected += new Foot.FootDownEventHandler(Foot_FootDownDetected);

            //debug output
            Console.WriteLine("Start Left:" + " x" + ((int)markerHeightCal.LeftFoot.xCoordinate).ToString() + " y" +
               ((int)markerHeightCal.LeftFoot.yCoordinate).ToString() + " z" + ((int)markerHeightCal.LeftFoot.zCoordinate).ToString());
            Console.WriteLine("Start Right:" + " x" + ((int)markerHeightCal.RightFoot.xCoordinate).ToString() + " y" +
                ((int)markerHeightCal.RightFoot.yCoordinate).ToString() + " z" + ((int)markerHeightCal.RightFoot.zCoordinate).ToString() + "\n");
        }
Exemple #46
0
    // передаем полный путь к файлу .wav
    public static void PlaySoundDirectory(string _pathAll, bool _play, DispatcherTimer pause_timer)
    {
        if (_play)
        {
            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.SoundLocation = _pathAll;

            try
            {
                player.Load();
                player.Play();
            }
            catch (Exception)
            {
            }

            pause_timer.Start();
        }
    }
Exemple #47
0
    // передаем только имя файла
    public static void PlaySound(string _fileName, bool _play, DispatcherTimer pause_timer)
    {
        if (_play)
        {
            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.SoundLocation = System.IO.Directory.GetCurrentDirectory() + @"\Sound\" + _fileName;

            try
            {
                player.Load();
                player.Play();
            }
            catch (Exception)
            {
            }

            pause_timer.Start();
        }
    }
Exemple #48
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();
     }
 }
 public void Fire()
 {
     if (turn < 6 && turn == ChamberNum)
     {
         if (block != true)
         {
             bullets = 0;
             loss    = true;
             losses += 1;
             turn    = 7;
             System.Media.SoundPlayer gunshot = new System.Media.SoundPlayer();
             gunshot.SoundLocation = @"D:\C# Course 2019\Russian Roulette\Properties\Sounds\Gunshot.wav";
             gunshot.Load();
             gunshot.Play();
         }
         else
         {
             bullets = 0;
             win     = true;
             wins   += 1;
             turn    = 7;
             System.Media.SoundPlayer ricochet = new System.Media.SoundPlayer();
             ricochet.SoundLocation = @"D:\C# Course 2019\Russian Roulette\Properties\Sounds\Ricochet.wav";
             ricochet.Load();
             ricochet.Play();
         }
     }
     else if (turn < 6 && turn != ChamberNum)
     {
         if (block == true)
         {
             blocks -= 1;
             block   = false;
             turn   += 1;
         }
         else
         {
             turn += 1;
         }
     }
 }
        private void loadSyncButton_Click(object sender, System.EventArgs e)
        {
            // Disable playback controls until the .wav is
            // successfully loaded. The LoadCompleted event
            // handler will enable them.
            EnablePlaybackControls(false);

            try
            {
                // Assign the selected file's path to
                // the Sound object.
                sound.SoundLocation = filepathTextbox.Text;

                // Load the .wav file.
                sound.Load();
            }
            catch (Exception ex)
            {
                ReportStatus(ex.Message);
            }
        }
Exemple #51
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 #52
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Yellow;
            Random ran = new Random();
            var    r   = new Random();

            string[] colors   = { "Red", "Black" };
            int[]    columns1 = { 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34 };
            int[]    columns2 = { 2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35 };
            int[]    columns3 = { 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36 };
            string   guess;
            string   streetGuess;
            int      attempts = 0;
            int      bet;
            int      money = 500;

            int[] streets = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36 };
            //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,  11, 12, 13, 14, 15, 16,....

            /*  int[] street2 = {4, 5, 6};
             *
             * int[] street3 = { 7, 8, 9 };
             * int[] street4 = { 10, 11, 12 };
             * int[] street5 = { 13, 14, 15};
             * int[] street6 = { 16, 17, 18};
             * int[] street7 = { 19, 20, 21 };
             * int[] street8 = { 22, 23, 24};
             * int[] street9 = { 25, 26, 27 };
             * int[] street10 = { 28, 29, 30 };
             * int[] street11 = { 31, 32, 33 };
             * int[] street12 = { 34, 35, 36 };
             */



            while (money != 0)
            {
                Console.WriteLine("Roulette Roller for MSSA!\n");
                Console.WriteLine("Money:$" + money + "                  Attempts: " + attempts);
                Console.WriteLine("Type in any off the following letters below:");
                Console.WriteLine("a.Even    b.Odd    c.1 to 18    d.19 to 36");
                Console.WriteLine("e.Red     f.Black  g.1st 12     h.2nd 12");
                Console.WriteLine("i.3rd 12  j. Column1   k. Column2  l. Column3");
                Console.WriteLine("m.street  n. double row  o. split  p. corner");
                Console.WriteLine("q. Conclude Game.");
                //Console.WriteLine("m. );
                guess = (Console.ReadLine());
                //guess verifier
                guess.ToLower();
                bool check = guess == "a" || guess == "b" || guess == "c" || guess == "d" || guess == "e" || guess == "f" || guess == "g" || guess == "h" || guess == "i" || guess == "j" || guess == "k" || guess == "l" || guess == "m" || guess == "n" || guess == "o" || guess == "p" || guess == "q";
                if (check == false)
                {
                    Console.WriteLine("You did not enter the correct input value");
                    Console.ReadKey();
                    Console.Clear();
                    continue;
                }
                else if (check == true)
                {
bet:

                    Console.WriteLine("Enter an amount to bet");
                    bet = Convert.ToInt32(Console.ReadLine());
                    //verifies the bet
                    if (bet > money)
                    {
                        Console.WriteLine("You dont have enough money!");
                        Console.WriteLine("Press enter to try again.");
                        Console.ReadKey();
                        goto bet;
                    }
                    else if (bet <= money)
                    {
                        money -= bet;
                        int    roll     = ran.Next(0, 37);
                        string ranColor = colors[r.Next(colors.Length)];
                        bool   even     = roll % 2 == 0;
                        if ((((guess == "a") && (even == true))) || (((guess == "b") && (even == false))) || ((guess == "e") && (ranColor == "Red") || (guess == "f") && (ranColor == "Black")))
                        {
                            Console.WriteLine("The roulette rolled: " + ranColor + " " + roll);
                            Console.WriteLine("You won! +$" + bet * 2 + "!");
                            System.Media.SoundPlayer cash = new System.Media.SoundPlayer(@"cash.wav");
                            cash.Load();
                            cash.Play();
                            Console.WriteLine("<Press enter to continue>");
                            money += bet * 2;
                            attempts++;
                            Console.ReadKey();
                        }
                        else if ((guess == "c") && ((roll > 0) && (roll < 19)))
                        {
                            Console.WriteLine("The roulette rolled: " + ranColor + " " + roll);
                            Console.WriteLine("You won! +$" + bet * 2 + "!");
                            System.Media.SoundPlayer cash = new System.Media.SoundPlayer(@"cash.wav");
                            cash.Load();
                            cash.Play();
                            Console.WriteLine("<Press enter to continue>");
                            money += bet * 2;
                            attempts++;
                            Console.ReadKey();
                        }
                        else if ((guess == "d") && ((roll > 18) && (roll < 37)))
                        {
                            Console.WriteLine("The roulette rolled: " + ranColor + " " + roll);
                            Console.WriteLine("You won! +$" + bet * 2 + "!");
                            System.Media.SoundPlayer cash = new System.Media.SoundPlayer(@"cash.wav");
                            cash.Load();
                            cash.Play();
                            Console.WriteLine("<Press enter to continue>");
                            money += bet * 2;
                            attempts++;
                            Console.ReadKey();
                        }
                        else if ((guess == "g") && (roll > 0 && roll < 13) || (guess == "h") && (roll > 12 && roll < 25) || (guess == "i") && (roll > 24 && roll < 37))
                        {
                            Console.WriteLine("The roulette rolled: " + ranColor + " " + roll);
                            Console.WriteLine("You won! +$" + bet * 2 + "!");
                            System.Media.SoundPlayer cash = new System.Media.SoundPlayer(@"cash.wav");
                            cash.Load();
                            cash.Play();
                            Console.WriteLine("<Press enter to continue>");
                            money += bet * 3;
                            attempts++;
                            Console.ReadKey();
                        }
                        else if (guess == "j" && (Array.IndexOf(columns1, roll) >= 0))
                        {
                            Console.WriteLine("The roulette rolled: " + ranColor + " " + roll);
                            Console.WriteLine("You won! +$" + bet * 2 + "!");
                            System.Media.SoundPlayer cash = new System.Media.SoundPlayer(@"cash.wav");
                            cash.Load();
                            cash.Play();
                            Console.WriteLine("<Press enter to continue>");
                            money += bet * 3;
                            attempts++;
                            Console.ReadKey();
                        }
                        else if (guess == "k" && (Array.IndexOf(columns2, roll) >= 0))
                        {
                            Console.WriteLine("The roulette rolled: " + ranColor + " " + roll);
                            Console.WriteLine("You won! +$" + bet * 2 + "!");
                            System.Media.SoundPlayer cash = new System.Media.SoundPlayer(@"cash.wav");

                            cash.Load();
                            cash.Play();
                            Console.WriteLine("<Press enter to continue>");
                            money += bet * 3;
                            attempts++;
                            Console.ReadKey();
                        }
                        else if (guess == "l" && (Array.IndexOf(columns3, roll) >= 0))
                        {
                            Console.WriteLine("The roulette rolled: " + ranColor + " " + roll);
                            Console.WriteLine("You won! +$" + bet * 2 + "!");
                            System.Media.SoundPlayer cash = new System.Media.SoundPlayer(@"cash.wav");
                            cash.Load();
                            cash.Play();
                            Console.WriteLine("<Press enter to continue>");
                            money += bet * 3;
                            attempts++;
                            Console.ReadKey();
                        }
                        //else if (guess == "m" && (Array.IndexOf(street1, roll) >= 0))
                        //{

                        //    Console.WriteLine("The roulette rolled: " + ranColor + " " + roll);
                        //    Console.WriteLine("You won! +$" + bet * 2 + "!");
                        //    System.Media.SoundPlayer cash = new System.Media.SoundPlayer(@"cash.wav");
                        //    cash.Load();
                        //    cash.Play();
                        //    Console.WriteLine("<Press enter to continue>");
                        //    money += bet * 5;
                        //    attempts++;
                        //    Console.ReadKey();
                        //}
                        else if (guess == "m")
                        {
                            Console.WriteLine("Choose your street: ");
                            Console.WriteLine("Street 1: 1-3, Street 2: 4-6, Street 3: 7-9, Street 4: 10-12, Street 5: 13-15, Street 6: 16-18, Street 7: 19-21, Street 8: 22-24, Street 9: 25-27, Street 10: 28-30");
                            Console.WriteLine("Street 11: 31-33, Street 12: 34-36");
                            streetGuess = (Console.ReadLine());
                            streetGuess.ToLower();
                            //guess2.Trim();
                            bool check2 = streetGuess == "street1" || streetGuess == "2" || streetGuess == "3" || streetGuess == "4" || streetGuess == "5" || streetGuess == "6" || streetGuess == "7" || streetGuess == "8" || streetGuess == "9" || streetGuess == "10" || streetGuess == "11" || streetGuess == "12";
                            switch (check2 == true)
                            {
                            case 1
                            }



                            /* if (check2 == false)
                             *  {
                             *      Console.WriteLine("You did not enter the correct input value");
                             *      Console.ReadKey();
                             *      Console.Clear();
                             *      continue;
                             *
                             *  }
                             *  if (check2 == true && guess2 == "street1" && (Array.IndexOf(streets, roll) <= 2))
                             *  {
                             *      Console.WriteLine("The roulette rolled: " + ranColor + " " + roll);
                             *      Console.WriteLine("You won! +$" + bet * 2 + "!");
                             *      SoundPlayer soundPlayer = new System.Media.SoundPlayer(@"cash.wav");
                             *      System.Media.SoundPlayer cash1 = soundPlayer;
                             *      cash1.Load();
                             *      cash1.Play();
                             *      Console.WriteLine("<Press enter to continue>");
                             *      money += bet * 3;
                             *      attempts++;
                             *      Console.ReadKey();
                             *  continue;
                             *         //return LosingMethod();
                             *  }
                             * //  else*/



                            /*  Console.WriteLine("The roulette rolled: " + ranColor + " " + roll);
                             * Console.WriteLine("You won! +$" + bet * 2 + "!");
                             * System.Media.SoundPlayer cash = new System.Media.SoundPlayer(@"cash.wav");
                             * cash.Load();
                             * cash.Play();
                             * Console.WriteLine("<Press enter to continue>");
                             * money += bet * 5;
                             * attempts++;
                             * Console.ReadKey(); */
                        }
                        else
                        {
                            Console.WriteLine("The roulette rolled: " + ranColor + " " + roll);
                            Console.WriteLine("You lost! -$" + bet + "!");

                            //morty voice
                            System.Media.SoundPlayer morty = new System.Media.SoundPlayer(@"morty.wav.wav");
                            morty.Load();
                            morty.Play();
                            //player.Play();
                            // var myPlayer = new System.Media.SoundPlayer();
                            // myPlayer.SoundLocation = @"C:\Users\willc\Downloads\morty.wav"; C:\Users\willc\MSSA2021\ISTA322\Exercises\Ex7Roulette\bin\Debug\netcoreapp3.1\morty.wav
                            // myPlayer.PlaySync();
                            Console.WriteLine("<Press enter to continue>");
                            attempts++;
                            Console.ReadKey();
                            if (money == 0)
                            {
                                Console.WriteLine("You are out of money.");
                                Console.WriteLine("<Press enter to continue>");
                                Console.ReadKey();
                            }
                        }
                    }
                }
            }
            Console.Clear();
        }
Exemple #53
0
    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
        }
    }
Exemple #54
0
 public void ReproducirMusica2()
 {   ///Cambiar Ruta de diferente computadora
     player2.SoundLocation = "C:/Users/Pablo Diaz/Desktop/PROGRAMAS C# METODOS DE PROGRAMACION/RandomFacil/RandomFacil/Resources/Dexter Surprise M**********r.wav";
     player2.Play();
     player2.Load();
 }
Exemple #55
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();
 }