Пример #1
49
 public void LaserSound()
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer();
     player.SoundLocation = "peww1.wav";
     player.Load();
     player.Play();
     player.Play();
 }
Пример #2
0
        private SoundManager()
        {
            myPlayerAlarm = new System.Media.SoundPlayer();
            myPlayerAlarm.SoundLocation = @"c:\windows\media\tada.wav";

            myPlayerContract = new System.Media.SoundPlayer();
            myPlayerContract.SoundLocation = @"c:\windows\media\ringin.wav";

            myPlayerException = new System.Media.SoundPlayer();
            myPlayerException.SoundLocation = @"c:\windows\media\Windows XP Critical Stop.wav";

            myAliveAlarm = new System.Media.SoundPlayer();
            myAliveAlarm.SoundLocation = @"c:\windows\media\Windows XP Hardware Fail.wav";

            int useAccount = Convert.ToInt32(Util.RemoveComma(ConfigManager.Ins().Config.GetValue(ConfigKeyConst.USE_ACCOUNT)));

            if (useAccount == 1)
            {
                _aliveTimer = new Timer(10, "");
            }
            else
            {
                _aliveTimer = new Timer(60 * 60 * 24, ""); // 24시간 뒤에 플레이 하도록 한다.
            }

            this.IsContractSoundOn = false;
        }
Пример #3
0
 public void ShowAwooga()
 {
     var player = new System.Media.SoundPlayer { SoundLocation = _config.Wav };
     player.Play();
     var awooga = new AwoogaForm(_config.Image);
     awooga.ShowDialog();
 }
Пример #4
0
        public void PlaySound(string soundLocation, int volume)
        {
            if (string.IsNullOrEmpty(soundLocation)) return;

            try
            {
                Log.DebugFormat("Playing sound '{0}' at volume", soundLocation, volume);

                try
                {
                    if (currentWaveOutVolume == null || currentWaveOutVolume.Value != volume)
                    {
                        int newVolume = ((ushort.MaxValue / 100) * volume);
                        uint newVolumeAllChannels = (((uint)newVolume & 0x0000ffff) | ((uint)newVolume << 16)); //Set the volume on left and right channels
                        PInvoke.waveOutSetVolume(IntPtr.Zero, newVolumeAllChannels);
                        currentWaveOutVolume = volume;
                    }
                }
                catch (Exception exception)
                {
                    var customException = new ApplicationException(
                        string.Format("There was a problem setting the wave out volume to '{0}'", volume), exception);

                    PublishError(this, customException);
                }

                var player = new System.Media.SoundPlayer(soundLocation);
                player.Play();
            }
            catch (Exception exception)
            {
                PublishError(this, exception);
            }
        }
Пример #5
0
 public override void controllerActivated(Dictionary<int, Target> targets)
 {
     System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
     myPlayer.SoundLocation = @"C:\Users\jon\AppData\Local\Temp\Temp2_P3StarterCode.zip\P3StarterCode\coin.wav";
     myPlayer.LoadAsync();
     myPlayer.Play();
 }
Пример #6
0
 public MainForm() {
     InitializeComponent();
     pa.KeyPressEvent += Pa_KeyPressEvent;
     pa.Start();
     player = new System.Media.SoundPlayer(@"Resources\1.wav");
     player.Load();
 }
Пример #7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            System.Media.SoundPlayer player = new System.Media.SoundPlayer();

            player.SoundLocation = "Sound.wav";
            player.Play();
        }
Пример #8
0
        public AVForm(Jid to_Jid)
        {
            try
            {
                callSoundPlayer = new System.Media.SoundPlayer(CSS.IM.UI.Util.Path.CallPath);//视频的呼叫声音;
            }
            catch (Exception)
            {

            }

            InitializeComponent();
            this.Text = "正在与" + to_Jid.User + "视频通话中";
            aVcommunicationEx1.UDPListen();
            if (CSS.IM.UI.Util.Path.CallSwitch)
            {
                try
                {
                      callSoundPlayer.PlayLooping();
                }
                catch (Exception)
                {

                }
            }
        }
Пример #9
0
        static void Main(string[] args)
        {
            string dave = "\u0044\u0061\u0076\u0065";

            Console.WriteLine("Hello, " + dave + ".");
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("\aAre You Trying To Turn ME Off ?");
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("\aAre You Still Trying\a To Leave ME " + dave + " ?!\a");
            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("I'm sorry " + dave + ", I'm afraid I can't do that.");
            System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();

            //Just change the first part of this to wherever the Hello_Wold folder is on your Drive
            myPlayer.SoundLocation = @"J:\Homework\CSC202\Hello_World\Hello_World\SorryDave.wav";
            myPlayer.Play();
            Console.WriteLine("Press any key to");
            Console.WriteLine("\t\tKiLL ");
            Console.Write("\t\t   HAL");
            Console.ReadKey(true);
        }
Пример #10
0
 static void Main(string[] args)
 {
     if (Convert.ToInt32(args[0]) == -1)
     {
         string soundsRoot = @"I:\ORT_Pendrive\Proyecto\TaskExecute\TaskExecute\bin\Debug\music";
         Random rand = new Random();
         var soundFiles = Directory.GetFiles(soundsRoot, "*.wav");
         var playSound = soundFiles[rand.Next(0, soundFiles.Length)];
         System.Media.SoundPlayer player = new System.Media.SoundPlayer(playSound);
         if (args[1] == "T")
         {
             player.Play();
         }
         else
         {
             player.Stop();
         }
         Console.Read();
     }
     else
     {
         int output = Convert.ToInt32(Math.Pow(2, Convert.ToInt32(args[0])));
         int total = PortControl.PortControl.Input(888);
         if (args[1] == "T")
         {
             if (((byte)PortControl.PortControl.Input(888) & (byte)output) == (byte)0)
                 PortControl.PortControl.Output(888, total + output);
         }
         else
             if (((byte)PortControl.PortControl.Input(888) & (byte)output) == output)
                 PortControl.PortControl.Output(888, total - output);
         Environment.Exit(0);
     }
 }
Пример #11
0
        public void refreshControls()
        {
            lblTurno.Invoke((MethodInvoker)(() => lblTurno.Text = String.Format("{0}", turnosModel.TurnoActual.Turno.ToString())));
            lblVentanilla.Invoke((MethodInvoker)(() => lblVentanilla.Text = String.Format("{0}", turnosModel.TurnoActual.Ventanilla.ToString())));

            short iter = 0;
            if (turnosModel.TurnosAtendiendo.Count() != 0)
            {
                foreach (turno item in (turnosModel.TurnosAtendiendo.Count() == 1 ? turnosModel.TurnosAtendiendo : turnosModel.TurnosAtendiendo.GetRange(turnosModel.TurnosAtendiendo.Count() - 2, 2)))
                {
                    if (iter == 0)
                    {
                        lblTurno1Atiende.Invoke((MethodInvoker)(() => lblTurno1Atiende.Text = String.Format("{0}", item.Turno.ToString())));
                        lblVentanilla1Atiende.Invoke((MethodInvoker)(() => lblVentanilla1Atiende.Text = String.Format("{0}", item.Ventanilla.ToString())));
                        lblServicio1Atiende.Invoke((MethodInvoker)(() => lblServicio1Atiende.Text = String.Format("{0}", item.Tramite.ToString())));
                    }
                    else
                    {
                        lblTurno2Atiende.Invoke((MethodInvoker)(() => lblTurno2Atiende.Text = String.Format("{0}", item.Turno.ToString())));
                        lblVentanilla2Atiende.Invoke((MethodInvoker)(() => lblVentanilla2Atiende.Text = String.Format("{0}", item.Ventanilla.ToString())));
                        lblServicio2Atiende.Invoke((MethodInvoker)(() => lblServicio2Atiende.Text = String.Format("{0}", item.Tramite.ToString())));
                    }
                    iter++;
                }
            }

            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.SoundLocation = string.Format("{0}\\{1}{2}", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), @"Assets\Sounds\", "defaultSound.wav");
            player.Play();
        }
Пример #12
0
        public Beeper(Metronome metronome, string filename)
        {
            metronome.MetronomeEvent += new Metronome.MetronomeHandler(metronomeHandler);

              	        mySoundPlayer = new System.Media.SoundPlayer();
            mySoundPlayer.SoundLocation = filename;
        }
Пример #13
0
        static void EndGame()
        {
            player = new System.Media.SoundPlayer("crash.wav");
            player.Play();

            for (int i = 0; i < 3; i++)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.Clear();
                System.Threading.Thread.Sleep(200);
                Console.BackgroundColor = ConsoleColor.Yellow;
                Console.Clear();
                System.Threading.Thread.Sleep(200);
            }

            Console.ForegroundColor = ConsoleColor.Red;
            Console.SetCursorPosition(35, 10);

            Console.WriteLine(@"

             _______  _______  __   __  _______    _______  __   __  _______  ______
            |       ||   _   ||  |_|  ||       |  |       ||  | |  ||       ||    _ |
            |    ___||  |_|  ||       ||    ___|  |   _   ||  |_|  ||    ___||   | ||
            |   | __ |       ||       ||   |___   |  | |  ||       ||   |___ |   |_||_
            |   ||  ||       ||       ||    ___|  |  |_|  ||       ||    ___||    __  |
            |   |_| ||   _   || ||_|| ||   |___   |       | |     | |   |___ |   |  | |
            |_______||__| |__||_|   |_||_______|  |_______|  |___|  |_______||___|  |_|     ");
        }
Пример #14
0
        public FireFly(String comPort)
        {
            this.WindowState = FormWindowState.Maximized;
            this.FormBorderStyle = FormBorderStyle.None;
            this.InitializeComponent();

            //this.insight = new Insight(new Point(5, 132), new Size(740, 630));
            //this.Controls.Add(insight);

            this.webCamera = new WebCamera(this.webcamFeed1.Width,this.webcamFeed1.Height);
            this.webCamera.ImageCaptured += new WebCamera.WebCamEventHandler(WebCameraImage);
            this.webCamera.Start(0);

            this.alarmSettings = new AlarmSettings();
            this.mediaPlayer = new System.Media.SoundPlayer();
            this.mediaPlayer.SoundLocation = "";

            this.voice = new Voice();

            this.voice.addCommand("Lights On");
            this.voice.addCommand("Lights Off");
            this.voice.addCommand("Strobe");
            this.voice.addCommand("I am awake");

            this.voice.finalizeCommands();

            microcontrollerDriver = new Picaxe40X2(comPort);

            this.clockTimer.Start();
            //this.insightTimer.Start();
            this.alarmOn = false;
        }
Пример #15
0
        public Game()
        {
            InitializeComponent();

            SetStyle(
                ControlStyles.UserPaint |
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.DoubleBuffer |
                ControlStyles.OptimizedDoubleBuffer |
                ControlStyles.AllPaintingInWmPaint,
                true
            );

            Image roadImage = Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Racemap.bmp"));
            BackgroundImage = Image.FromFile(Path.Combine(Environment.CurrentDirectory, "Racemapv3.bmp"));
            roadBitmap = new Bitmap(roadImage);
            //BackgroundImage = roadImage; //DEBUG

            player = new System.Media.SoundPlayer();
            player.SoundLocation = Path.Combine(Environment.CurrentDirectory, "music.wav");
            player.LoadAsync();

            nyanPlayer = new System.Media.SoundPlayer();
            nyanPlayer.SoundLocation = Path.Combine(Environment.CurrentDirectory, "nyan.wav");
            nyanPlayer.LoadAsync();

            Paint += new PaintEventHandler(PaintHandler);

            Init();
        }
Пример #16
0
 private void btPlay_Click(object sender, EventArgs e)
 {
     int sel = Convert.ToInt32(listboxWavSlection.SelectedIndex);
     string location = CDCControls.WavLocation[sel];
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(location);
     player.Play();
 }
Пример #17
0
        //Constructor
        public SoundEffects(ref AxWindowsMediaPlayer axMedia, ref Semaphore soundSem, ref Semaphore mediaSem, ref Boolean stop)
        {
            //Assign variables
            soundSemaphore = soundSem;
            mediaSemaphore = mediaSem;
            media = axMedia;
            media.settings.setMode("loop", false);
            stopped = stop;

            //Determine if sound folder already exists
            if (!Directory.Exists(currentDirectory))
            {
                try
                {
                    Directory.CreateDirectory(currentDirectory); //if not, create it
                } catch { }
            }
            //Get the length of every sound file
            MaxTurboLength = GetSoundLength(currentDirectory + "\\MaxTurbo.wav") + 1000;
            Start1Length = GetSoundLength(currentDirectory + "\\Start1.wav") + 1000;
            Start2Length = GetSoundLength(currentDirectory + "\\Start2.wav") + 1000;
            LoopLength = GetSoundLength(currentDirectory + "\\Loop.wav") + 1000;
            StopLength = GetSoundLength(currentDirectory + "\\Stop.wav") + 1000;
            sound = new System.Media.SoundPlayer(currentDirectory + "\\MaxTurbo.wav");
        }
Пример #18
0
 private void TagVisualization_Initialized(object sender, EventArgs e)
 {
     String appdir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
     var path = System.IO.Path.Combine(appdir, "camera-shutter-click-01.wav");
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(path);
     player.Play();
 }
Пример #19
0
        private void Start_Animals_Click(object sender, EventArgs e)
        {
            var strButton_Text=Start_Animals.Text;
            System.Media.SoundPlayer player = new System.Media.SoundPlayer();
            player.SoundLocation = "C:\\temp\\play.wav";
            if (strButton_Text == "Start_Animals")
            {
                player.LoadAsync();
                player.PlayLooping();
                Start_Animals.Text = "Stop";
                timer_animals.Enabled = true;
                //listfile[j].Remove(0);
                //animals.Image = Image.FromFile("c:\\temp\\dog.png");
                //anim
                //Timer timer = new Timer();
                //timer.Interval = 500;
                //timer.Enabled = true;
                //timer.Start();

            }
            else
            {
                player.Stop();
                Start_Animals.Text = "Start_Animals";
                timer_animals.Enabled = false;
            }
            //

            //animals.SizeMode = "StretchImage";
        }
Пример #20
0
 public Aleret()
 {
     strm = TestScriptCS.Properties.Resources.piri;
     wmp = new System.Media.SoundPlayer(strm);
     Interval = 500;
     this.Tick += new EventHandler(this.Bombat_Tick);
 }
Пример #21
0
        songbookEntities2 testcontext; //

        #endregion Fields

        #region Constructors

        public Controller(Panel[] panels, ListBox _lbSongs, ComboBox _cbShowCategory, ComboBox _cbAddSongCategory, ListBox _lbRemoveSong)
        {
            Panels = panels;
            lbSongs = _lbSongs;
            cbShowCategory = _cbShowCategory;
            cbAddSongCategory = _cbAddSongCategory;
            lbRemoveSong = _lbRemoveSong;
            currentCategory = -1;
            ShowPanel(0); // иницијално ги сокриваме сите панели
            Panels[1].Hide(); //како и панелот со мени
            Graph = Panels[0].CreateGraphics(); //платно за исцртување на интро панелот
            buffBmp = new Bitmap(Panels[0].Width, Panels[0].Height); //
            buffGraph = Graphics.FromImage(buffBmp); //платно кое го користиме како бафер
            numbSteps = 0;
            backgColor = Color.FromArgb(250, 250, 200); // позадинска боја на интрото
            //креирање на четки и фонтови
            brushBlue = new SolidBrush(Color.Blue);
            brushDodgerBlue = new SolidBrush(Color.DodgerBlue);
            brushRed = new SolidBrush(Color.Red);
            font1 = new Font("Arial", 30);
            font2 = new Font("Arial", 20);
            font3 = new Font("Arial", 16);

            testcontext = new songbookEntities2();

            loadIntro();
            // стартување тајмерот
            loadTimer = new Timer();
            loadTimer.Interval = 50;
            loadTimer.Tick += new EventHandler(timer_Tick);
            loadTimer.Start();
            // стартување на интро звукот
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(Resources.intro);
            player.Play();
        }
Пример #22
0
 public void Start()
 {
     this.m_WavPlayer = new System.Media.SoundPlayer();
     this.m_WavPlayer.SoundLocation = YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.AlertWaveFileName;
     this.m_WavPlayer.LoadAsync();
     this.StartTimer();
 }
Пример #23
0
        public LeagueHelper()
        {
            string fileName = "Settings\\properties.txt";

            string[] lines = System.IO.File.ReadAllLines(fileName);

            int interval = Convert.ToInt32(lines[1]);
            this.recX = Convert.ToInt32(lines[4]);
            this.recY = Convert.ToInt32(lines[5]);
            this.recW = Convert.ToInt32(lines[6]);
            this.recH = Convert.ToInt32(lines[7]);

            this.accuracy = Convert.ToInt32(lines[10]);

            this.timer = new Timer();
            this.timer.Interval = interval;
            this.timer.Enabled = true;
            this.timer.Tick += new System.EventHandler(OnTimerEvent);

            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;

            this.player = new System.Media.SoundPlayer("Sounds\\alert.wav");

            this.oldRed = 0;

            InitializeComponent();
        }
        public RaceProcessor()
        {
            // Store a reference to the Common application data folder
            string appData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

            // Append our Application name
            _appDataPath = Path.Combine(appData, "Pinewood Race Command");

            // Create our application folder if it does not exist
            if (Directory.Exists(_appDataPath).Equals(false))
            {
                Directory.CreateDirectory(_appDataPath);
            }

            // Build the path to our backups
            string backupPath = Path.Combine(_appDataPath, "Backups");
            if (Directory.Exists(backupPath).Equals(false))
            {
                Directory.CreateDirectory(backupPath);
            }

            // Initialize our Heat number to 1
            RaceDataStore.PrelimHeatNumber = 1;

            // Create our media player
            _wavePlayer = new System.Media.SoundPlayer();

            _isInitialized = false;
        }
Пример #25
0
        public int SearchandDestroy(bool reset)
        {
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Resources.kachu);
            System.Media.SoundPlayer playerInf = new System.Media.SoundPlayer(Properties.Resources.pikapika);

            TargetManager tm = TargetManager.GetInstance();
            Controller controller = Controller.GetInstance();

            int i = 0;
            foreach (Target target in tm.TMTargets)
            {
                i++;

                controller.MoveTo(target.x, target.y);

                player.Play();
                controller.Fire();
                controller.SetNum(controller.GetNum() - 1);

                playerInf.PlayLooping();

                if (i != tm.TMTargets.Count)
                {
                    if (reset == true)
                    {
                        controller.Launcher.Reset();
                    }
                }

                Thread.Sleep(250);
            }

            return i;
        }
Пример #26
0
 private void playSound(string path)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer();
     player.SoundLocation = path;
     player.Load();
     player.Play();
 }
Пример #27
0
        public static void Init(Player player)
        {
            SoundPlayer = new System.Media.SoundPlayer();
            ClickSoundPlayer = new System.Media.SoundPlayer(Properties.Resources.clickDefault);
            ClickSoundPlayer.Load();

            VolumeSoundPlayer = new System.Media.SoundPlayer(Properties.Resources.clickVolume);
            VolumeSoundPlayer.Load();

            VolumeEndOfScaleSoundPlayer = new System.Media.SoundPlayer(Properties.Resources.cyk);
            VolumeEndOfScaleSoundPlayer.Load();

            EndOfListSoundPlayer = new System.Media.SoundPlayer(Properties.Resources.zium);
            EndOfListSoundPlayer.Load();

            Slides = new List<Slide>();
            SlideManager.playerForm = player;
            playerForm.FormClosed += (s, e) =>
            {
                SlideManager.Dispose();
                SoundPlayer.Dispose();
                ClickSoundPlayer.Dispose();
                VolumeSoundPlayer.Dispose();
            };
            LoadSlidesDefinitions();
        }
Пример #28
0
 /// <summary>
 /// plays a sound
 /// </summary>
 /// <param name="sound_filename"></param>
 private void PlaySound(string sound_filename)
 {
     usage.Update("Play Sound, SurveyorVisionStereoGtk, PlaySound");
     
     System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();
     myPlayer.SoundLocation = sound_filename;
     myPlayer.Play();
 }
 public Winner2()
 {
     InitializeComponent();
     System.Media.SoundPlayer timeclap = new System.Media.SoundPlayer();
     timeclap.Stream = Properties.Resources.Clap;
     timeclap.Load();
     timeclap.Play();
 }
Пример #30
0
        private static void PlayTest(Sound test)
        {
            using (var stream = new MemoryStream(test.SoundContent))
            using (var player = new System.Media.SoundPlayer(stream))
                player.Play();

            Console.WriteLine($"Played: {test}");
        }
Пример #31
0
        public MainWindow()
        {
            SystemEvents.SessionSwitch += SystemEvents_SessionSwitch;

            //BindingErrorListener.Listen(m => MessageBox.Show(m));
            this.m_MainWindowCommandButtonHandler = new MainWindowCommandButtonHandler();

            this.m_WavPlayer = new System.Media.SoundPlayer();

            this.m_SystemIdentity = YellowstonePathology.Business.User.SystemIdentity.Instance;

            this.m_TabItemFlow        = new TabItem();
            this.m_TabItemFlow.Header = SetHeader("Flow", "Flow.ico");
            this.m_TabItemFlow.Tag    = "Flow";

            this.m_TabItemPathologist        = new TabItem();
            this.m_TabItemPathologist.Header = SetHeader("Pathologist", "Microscope.ico");
            this.m_TabItemPathologist.Tag    = "Pathologist";

            this.m_TabItemReportDistribution        = new TabItem();
            this.m_TabItemReportDistribution.Header = SetHeader("Report Distribution", "Distribution.ico");
            this.m_TabItemReportDistribution.Tag    = "Report_Distribution";

            this.m_TabItemSearch        = new TabItem();
            this.m_TabItemSearch.Header = SetHeader("Search", "Search.ico");
            this.m_TabItemSearch.Tag    = "Search";

            this.m_TabItemLab        = new TabItem();
            this.m_TabItemLab.Header = SetHeader("Lab", "Lab.ico");
            this.m_TabItemLab.Tag    = "Lab";
            this.m_TabItemLab.Name   = "TabItemLab";

            this.m_TabItemAdministration        = new TabItem();
            this.m_TabItemAdministration.Header = SetHeader("Administration", "Wand.ico");
            this.m_TabItemAdministration.Tag    = "Administration";

            this.m_TabItemScanning        = new TabItem();
            this.m_TabItemScanning.Header = SetHeader("Scan Processing", "Scan.ico");
            this.m_TabItemScanning.Tag    = "Scan_Processing";

            this.m_TabItemClient        = new TabItem();
            this.m_TabItemClient.Header = SetHeader("Client", "Client.ico");
            this.m_TabItemClient.Tag    = "Client";

            this.m_TabItemBilling        = new TabItem();
            this.m_TabItemBilling.Header = SetHeader("Billing", "Billing.ico");
            this.m_TabItemBilling.Tag    = "Billing";

            this.m_TabItemCytology        = new TabItem();
            this.m_TabItemCytology.Header = SetHeader("Cytology", "Cytology.ico");
            this.m_TabItemCytology.Tag    = "Cytology";

            this.m_TabItemTyping        = new TabItem();
            this.m_TabItemTyping.Header = SetHeader("Typing", "Typing.ico");
            this.m_TabItemTyping.Tag    = "Typing";

            this.m_TabItemLogin        = new TabItem();
            this.m_TabItemLogin.Header = SetHeader("Login", "Login.ico");
            this.m_TabItemLogin.Tag    = "Login";

            this.m_TabItemClientOrder        = new TabItem();
            this.m_TabItemClientOrder.Header = SetHeader("Client Order", "Batch.ico");
            this.m_TabItemClientOrder.Tag    = "Client_Order";

            this.m_TabItemTask        = new TabItem();
            this.m_TabItemTask.Header = SetHeader("Tasks", "AcceptResults.ico");
            this.m_TabItemTask.Tag    = "Tasks";

            InitializeComponent();

            this.AddHandler(UI.CustomControls.CloseableTabItem.CloseTabEvent, new RoutedEventHandler(this.CloseTab));

            this.TabControlLeftWorkspace.SelectionChanged += new SelectionChangedEventHandler(TabControlLeftWorkspace_SelectionChanged);
            if (this.m_SystemIdentity.User.UserId != 5001 && this.m_SystemIdentity.User.UserId != 5051 && this.m_SystemIdentity.User.UserId != 5126)
            {
                this.MenuItemReportDistribution.IsEnabled = false;
            }

            if (YellowstonePathology.Business.User.UserPreferenceInstance.Instance.UserPreference.ActivateNotificationAlert == true)
            {
                TaskNotifier.Instance.Start();
            }

            this.DataContext = this;

            this.Loaded  += new RoutedEventHandler(MainWindow_Loaded);
            this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing);
        }
Пример #32
0
 private void frmPizzaDelivery_Load(object sender, EventArgs e)
 {
     {
         int w = pnlGrid.Width / 24;
         int l = w;
         int t = w;
         // J is row, I is column; build one row at a time
         for (int j = 0; j < 21; j++)
         {
             for (int i = 0; i < 21; i++)
             {
                 deliveryGrid[i, j]        = new Label();
                 deliveryGrid[i, j].Width  = w;
                 deliveryGrid[i, j].Height = w;
                 deliveryGrid[i, j].Top    = t;
                 deliveryGrid[i, j].Left   = l;
                 deliveryGrid[i, j].Font   = new Font
                                                 ("Microsoft Sans Serif", 10, FontStyle.Bold);
                 deliveryGrid[i, j].TextAlign =
                     ContentAlignment.MiddleCenter;
                 if (i == 0)
                 {
                     if (j != 0)
                     {
                         // row numbers
                         deliveryGrid[i, j].Text =
                             j.ToString();
                         deliveryGrid[i, j].Width =
                             Convert.ToInt32(1.5 * w);
                         deliveryGrid[i, j].Left =
                             Convert.ToInt32(0.5 * w);
                         deliveryGrid[i, j].ForeColor =
                             Color.DarkBlue;
                     }
                 }
                 else if (j == 0)
                 {
                     if (i != 0)
                     {
                         // column letters
                         deliveryGrid[i, j].Text = ((char)
                                                    (i + 64)).ToString();
                         deliveryGrid[i, j].ForeColor =
                             Color.DarkBlue;
                     }
                 }
                 else
                 {
                     deliveryGrid[i, j].BorderStyle =
                         BorderStyle.FixedSingle;
                     deliveryGrid[i, j].BackColor =
                         Color.White;
                     deliveryGrid[i, j].ForeColor =
                         Color.Yellow;
                     if (i < 10)
                     {
                         deliveryGrid[i, j].Tag = "0" +
                                                  i.ToString();
                     }
                     else
                     {
                         deliveryGrid[i, j].Tag = i.ToString();
                     }
                     if (j < 10)
                     {
                         deliveryGrid[i, j].Tag += "0" +
                                                   j.ToString();
                     }
                     else
                     {
                         deliveryGrid[i, j].Tag += j.ToString();
                     }
                     deliveryGrid[i, j].Click += new System.EventHandler
                                                     (this.DeliveryGrid_Click);
                 }
                 pnlGrid.Controls.Add(deliveryGrid[i, j]);
                 l += w;
             }
             // new row
             l  = w;
             t += w;
         }
     }
     pizzasInOven[0]   = picPizza1;
     pizzasInOven[1]   = picPizza2;
     pizzasInOven[2]   = picPizza3;
     pizzasInOven[3]   = picPizza4;
     pizzasInOven[4]   = picPizza5;
     pizzasInOven[5]   = picPizza6;
     pizzasInOven[6]   = picPizza7;
     pizzasInOven[7]   = picPizza8;
     grpOven.Enabled   = false;
     grpCar.Enabled    = false;
     tmrClock.Interval = mSecPerMin;
     tmrOven.Interval  = mSecPerMin;
     tmrCar.Interval   = mSecPerMin * minPer20Squares / 20;
     gameOverSound     = new System.Media.SoundPlayer
                             (Application.StartupPath + "\\tada.wav");
     phoneSound = new System.Media.SoundPlayer
                      (Application.StartupPath + "\\phone.wav");
     dingSound = new System.Media.SoundPlayer
                     (Application.StartupPath + "\\ding.wav");
     beepSound = new System.Media.SoundPlayer
                     (Application.StartupPath + "\\carbeep.wav");
 }
Пример #33
0
        private void timer_Tick(object sender, EventArgs e)
        {
            PowerStatus powerStatus = SystemInformation.PowerStatus;

            batteryPercentage   = (powerStatus.BatteryLifePercent * 100).ToString();
            batteryChargeStatus = (powerStatus.BatteryChargeStatus).ToString();
            powerLineStatus     = (powerStatus.PowerLineStatus).ToString();

            Color whiteColor = Color.White;
            Color greenColor = System.Drawing.ColorTranslator.FromHtml("#7CFC00");
            Color redColor   = Color.Red;

            Color color = whiteColor;

            if (powerLineStatus.ToLower() == "online")
            {
                if (Int32.Parse(batteryPercentage) >= 80)
                {
                    TimeSpan duration = DateTime.Now - lastExecutedTime;

                    if (duration.TotalMinutes >= 5)
                    {
                        System.Media.SoundPlayer player = new System.Media.SoundPlayer(ConfigurationManager.AppSettings["HighBatterySound"]);
                        player.Play();
                        lastExecutedTime = DateTime.Now;
                    }
                }
                color = greenColor;
            }
            else if (batteryChargeStatus.ToString().ToLower().Contains("not charging"))
            {
                //Should use relative path or through resources.
                System.Media.SoundPlayer player = new System.Media.SoundPlayer(ConfigurationManager.AppSettings["LowBatterySound"]);
                player.Play();
            }
            else
            {
                if (Int32.Parse(batteryPercentage) <= 30)
                {
                    TimeSpan duration = DateTime.Now - lastExecutedTime;

                    if (duration.TotalMinutes >= 5)
                    {
                        //Should use relative path or through resources.
                        System.Media.SoundPlayer player = new System.Media.SoundPlayer(ConfigurationManager.AppSettings["LowBatterySound"]);
                        player.Play();
                        lastExecutedTime = DateTime.Now;
                    }
                    color = redColor;
                }
                else
                {
                    color = whiteColor;
                }
            }

            using (Bitmap bitmap = new Bitmap(DrawText(batteryPercentage, new Font(iconFont, iconFontSize, FontStyle.Bold), color, Color.Transparent)))
            {
                System.IntPtr intPtr = bitmap.GetHicon();
                try
                {
                    using (Icon icon = Icon.FromHandle(intPtr))
                    {
                        notifyIcon.Icon = icon;
                        notifyIcon.Text = batteryPercentage + "%";
                    }
                }
                finally
                {
                    DestroyIcon(intPtr);
                }
            }
        }
Пример #34
0
 private void btn_sair_Click(object sender, EventArgs e)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer("sys_sounds/sair.wav");
     player.Play();
     this.Close();
 }
Пример #35
0
//---------------------------------------------------------------------

//  playerxSound()

//       Creates a SoundPlayer object, loads the porky sound file and plays

//       the file.

//---------------------------------------------------------------------

        private void playerxSound()
        {
            sndPlayer = new System.Media.SoundPlayer(Properties.Resources.porky2);
            sndPlayer.Play();
        }
Пример #36
0
        static int showResults()
        {
            System.Media.SoundPlayer soundPlayer = play_background_sound();
            Console.Clear();

            List <Player> players = new List <Player>();
            string        wXml    = "";
            StreamReader  pSr     = new StreamReader("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\results.xml");

            using (pSr)
            {
                wXml = pSr.ReadToEnd();
            }
            XmlDocument lXml = new XmlDocument();

            lXml.LoadXml(wXml);
            XmlNodeList pNodes = lXml.SelectNodes("//Player");

            foreach (XmlNode oNode in pNodes)
            {
                string name     = oNode["name"].InnerText;
                string surname  = oNode["surname"].InnerText;
                string date     = oNode["date"].InnerText;
                int    moneyWon = Convert.ToInt32(oNode["moneyWon"].InnerText);
                string jokers   = oNode["jokers"].InnerText;
                players.Add(new Player(name, surname, date, moneyWon, jokers));
            }


            int n = players.Count();

            for (int i = 0; i < n - 1; i++)
            {
                for (int j = 0; j < n - i - 1; j++)
                {
                    if (players[j].moneyWon < players[j + 1].moneyWon)
                    {
                        Player temp = players[j];
                        players[j]     = players[j + 1];
                        players[j + 1] = temp;
                    }
                }
            }

            Console.WriteLine("All players:");


            var table = new ConsoleTable("No. ", "name", "surname", "date", "money won", "jokers used");
            int rbr   = 1;

            foreach (Player player in players)
            {
                table.AddRow(rbr++ + ".", player.name, player.surname, player.date, player.moneyWon, player.jokers);
            }

            table.Write();
            Console.WriteLine();

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            showMenu();
            int choice = your_option();

            stop_background_sound(soundPlayer);
            return(choice);
        }
Пример #37
0
 private void playSoundLooping(string path)
 {
     player = new System.Media.SoundPlayer(@path);
     player.PlayLooping();
     soundPlaying = true;
 }
Пример #38
0
        private void btnBuild_Click(object sender, EventArgs e)
        {
            //Check current settings
            if (!File.Exists(txtMobi.Text))
            {
                MessageBox.Show(@"Specified book was not found.", @"Book Not Found");
                return;
            }
            if (rdoShelfari.Checked && txtShelfari.Text == "")
            {
                MessageBox.Show(@"No Shelfari link was specified.", @"Missing Shelfari Link");
                return;
            }
            if (settings.useKindleUnpack && !File.Exists(settings.mobi_unpack))
            {
                MessageBox.Show(@"Kindleunpack was not found.\r\nPlease review the settings page.", @"Kindleunpack Not Found");
                return;
            }
            if (!Directory.Exists(settings.outDir))
            {
                MessageBox.Show(@"Specified output directory does not exist.\r\nPlease review the settings page.", @"Output Directory Not found");
                return;
            }
            if (Properties.Settings.Default.realName.Trim().Length == 0 ||
                Properties.Settings.Default.penName.Trim().Length == 0)
            {
                MessageBox.Show(
                    @"Both Real and Pen names are required for End Action\r\n" +
                    @"file creation. This information allows you to rate this\r\n" +
                    @"book on Amazon. Please review the settings page.",
                    @"Amazon Customer Details Not found");
                return;
            }
            //Create temp dir and ensure it exists
            string randomFile = Functions.GetTempDirectory();

            if (!Directory.Exists(randomFile))
            {
                MessageBox.Show(@"Temporary path not accessible for some reason.", @"Temporary Directory Error");
                return;
            }

            prgBar.Value = 0;

            //0 = asin, 1 = uniqid, 2 = databasename, 3 = rawML, 4 = author, 5 = title
            List <string> results;

            if (settings.useKindleUnpack)
            {
                Log("Running Kindleunpack to get metadata...");
                results = Functions.GetMetaData(txtMobi.Text, settings.outDir, randomFile, settings.mobi_unpack);
            }
            else
            {
                Log("Extracting metadata...");
                try
                {
                    results = Functions.GetMetaDataInternal(txtMobi.Text, settings.outDir, true, randomFile).getResults();
                }
                catch (Exception ex)
                {
                    Log("Error getting metadata: " + ex.Message);
                    return;
                }
            }
            if (results.Count != 6)
            {
                Log(results[0]);
                return;
            }

            if (settings.saverawml)
            {
                Log("Saving rawML to dmp directory...");
                File.Copy(results[3], Path.Combine(Environment.CurrentDirectory + @"\dmp", Path.GetFileName(results[3])), true);
            }

            // Added author name to log output
            Log(String.Format("Got metadata!\r\nDatabase Name: {0}\r\nASIN: {1}\r\nAuthor: {2}\r\nTitle: {3}\r\nUniqueID: {4}",
                              results[2], results[0], results[4], results[5], results[1]));

            Log(String.Format("Attempting to build X-Ray...\r\nSpoilers: {0}", settings.spoilers ? "Enabled" : "Disabled"));
            bool AZW3 = false;

            if (Path.GetExtension(txtMobi.Text) == ".azw3")
            {
                if (settings.offset == -16 && MessageBox.Show("A -16 offset is automatically applied for this AZW3 file.\r\n"
                                                              + "Are you sure you want to keep your existing -16 setting?", "Offset Setting", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    settings.offset = 0;
                    settings.Save();
                }
                AZW3 = true;
            }
            Log("Offset: " + settings.offset.ToString() + (AZW3 ? " (-16 for AZW3)" : ""));

            //Create X-Ray and attempt to create the base file (essentially the same as the site)
            XRay xray;

            try
            {
                if (rdoShelfari.Checked)
                {
                    xray = new XRay(txtShelfari.Text, results[2], results[1], results[0], this, settings.spoilers,
                                    settings.offset - (AZW3 ? 16 : 0), "", false);
                }
                else
                {
                    xray = new XRay(txtXMLFile.Text, results[2], results[1], results[0], this, settings.spoilers,
                                    settings.offset - (AZW3 ? 16 : 0), "");
                }
                if (xray.CreateXray() > 0)
                {
                    Log("Error while processing.");
                    return;
                }
                Log("Initial X-Ray built, adding locations and chapters...");
                //Expand the X-Ray file from the unpacked mobi
                if (xray.ExpandFromRawMl(results[3], settings.ignoresofthyphen, !settings.useNewVersion) > 0)
                {
                    Log("Error while processing locations and chapters.");
                    return;
                }
            }
            catch (Exception ex)
            {
                Log("An error occurred while creating the new X-Ray database.\r\n" + ex.Message);
                return;
            }

            Log("Saving X-Ray to file...");
            string outFolder = "";
            string _newPath  = "";

            try
            {
                if (settings.android)
                {
                    outFolder = settings.outDir + @"\Android\" + results[0];
                    Directory.CreateDirectory(outFolder);
                }
                else
                {
                    outFolder = settings.useSubDirectories
                        ? Functions.GetBookOutputDirectory(results[4], Functions.RemoveInvalidFileChars(results[5]))
                        : settings.outDir;
                }
            }
            catch (Exception ex)
            {
                Log("Failed to create output directory: " + ex.Message + "\r\nFiles will be placed in the default output directory.");
                outFolder = settings.outDir;
            }
            _newPath = outFolder + "\\" + xray.GetXRayName(settings.android);

            if (settings.useNewVersion)
            {
                try
                {
                    SQLiteConnection.CreateFile(_newPath);
                }
                catch (Exception ex)
                {
                    Log("An error occurred while creating the new X-Ray database. Is it opened in another program?\r\n" + ex.Message);
                    return;
                }
                SQLiteConnection m_dbConnection;
                m_dbConnection = new SQLiteConnection(("Data Source=" + _newPath + ";Version=3;"));
                m_dbConnection.Open();
                string sql;
                try
                {
                    using (StreamReader streamReader = new StreamReader("BaseDB.sql", Encoding.UTF8))
                    {
                        sql = streamReader.ReadToEnd();
                    }
                }
                catch (Exception ex)
                {
                    Log("An error occurred while opening the BaseDB.sql file. Ensure you extracted it to the same directory as the program.\n"
                        + ex.Message);
                    m_dbConnection.Dispose();
                    return;
                }
                SQLiteCommand command = new SQLiteCommand("BEGIN; " + sql + " COMMIT;", m_dbConnection);
                Log("Building new X-Ray database. May take a few minutes...");
                command.ExecuteNonQuery();
                command = new SQLiteCommand("PRAGMA user_version = 1; PRAGMA encoding = utf8; BEGIN;", m_dbConnection);
                command.ExecuteNonQuery();
                Log("Done building initial database. Populating with info from source X-Ray...");
                try
                {
                    xray.PopulateDb(m_dbConnection);
                }
                catch (Exception ex)
                {
                    Log("An error occurred while creating the new X-Ray database. Is it opened in another program?\r\n" + ex.Message);
                    m_dbConnection.Close();
                    m_dbConnection.Dispose();
                    return;
                }
                Log("Updating indices...");
                sql = "CREATE INDEX idx_occurrence_start ON occurrence(start ASC);\n"
                      + "CREATE INDEX idx_entity_type ON entity(type ASC);\n"
                      + "CREATE INDEX idx_entity_excerpt ON entity_excerpt(entity ASC); COMMIT;";
                command = new SQLiteCommand(sql, m_dbConnection);
                command.ExecuteNonQuery();
                m_dbConnection.Close();
                m_dbConnection.Dispose();
            }
            else
            {
                using (StreamWriter streamWriter = new StreamWriter(_newPath, false, settings.utf8 ? Encoding.UTF8 : Encoding.Default))
                {
                    streamWriter.Write(xray.ToString());
                }
            }
            if (Properties.Settings.Default.playSound)
            {
                System.Media.SoundPlayer player = new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\done.wav");
                player.Play();
            }

            Log("X-Ray file created successfully!\r\nSaved to " + _newPath);

            try
            {
                PopulateXRayPreviews(results[5], xray);
                btnPreview.Enabled          = true;
                cmsPreview.Items[2].Enabled = true;
            }
            catch (Exception ex)
            {
                Log("Error populating X-Ray preview windows: " + ex.Message);
            }

            try
            {
                Directory.Delete(randomFile, true);
            }
            catch (Exception)
            {
                Log("An error occurred while trying to delete temporary files.\r\nTry deleting these files manually.");
            }
        }
Пример #39
0
        //Collision Detection
        protected void collisionDetection(Object source, ElapsedEventArgs e)
        {
            this.Dispatcher.Invoke((Action)(() =>
            {
                for (int i = 0; i < aisquares.Length; i++)
                {
                    //get player current dimensions and position
                    double playerRight = rectPlayer.Margin.Left + (playerSize);
                    double playerBottom = rectPlayer.Margin.Top + (playerSize);
                    double playerLeft = rectPlayer.Margin.Left - (playerSize);
                    double playerTop = rectPlayer.Margin.Top - (playerSize);

                    //get target square dimensions and position
                    double badTop = aisquares[i].Margin.Top - aisquares[i].ActualHeight;
                    double badBottom = aisquares[i].Margin.Top + aisquares[i].ActualHeight;
                    double badLeft = aisquares[i].Margin.Left - aisquares[i].ActualWidth;
                    double badRight = aisquares[i].Margin.Left + aisquares[i].ActualWidth;



                    //Test for collsion using above dimensions
                    if (badRight >= playerLeft &&
                        badLeft <= playerRight &&
                        badBottom >= playerTop &&
                        badTop <= playerBottom)
                    {               //successful collision
                        if (i < 24) //Green square locations in array
                        {
                            //play good sound
                            System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\Windows\Media\chimes.wav");
                            player.Play();
                            //update score, size and speed
                            playerScore += 1;
                            playerSize += 1;
                            speed += 0.5;
                        }
                        else//A red sqaure has been hit
                        {
                            //Show game over, play bad sound and record new high score if achieved
                            gridGameOver.Visibility = Visibility.Visible;
                            System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"c:\Windows\Media\Windows Critical Stop.wav");
                            player.Play();

                            //save new high score to file depending on what difficultty was used
                            //Easy
                            if (numberOfOpponents == 30 && playerScore > highScoreEasy)
                            {
                                gridGameOver.Visibility = Visibility.Collapsed;
                                gridHighScore.Visibility = Visibility.Visible;
                                highScoreEasy = playerScore;

                                TextWriter tw = new StreamWriter(path);
                                tw.WriteLine(highScoreEasy + "");
                                tw.WriteLine(highScoreMedium + "");
                                tw.WriteLine(highScoreHard + "");
                                tw.Close();
                            }
                            //Medium
                            if (numberOfOpponents == 75 && playerScore > highScoreMedium)
                            {
                                gridGameOver.Visibility = Visibility.Collapsed;
                                gridHighScore.Visibility = Visibility.Visible;
                                highScoreMedium = playerScore;

                                TextWriter tw = new StreamWriter(path);
                                tw.WriteLine(highScoreEasy + "");
                                tw.WriteLine(highScoreMedium + "");
                                tw.WriteLine(highScoreHard + "");
                                tw.Close();
                            }
                            //Hard
                            if (numberOfOpponents == 100 && playerScore > highScoreHard)
                            {
                                gridGameOver.Visibility = Visibility.Collapsed;
                                gridHighScore.Visibility = Visibility.Visible;
                                highScoreHard = playerScore;

                                TextWriter tw = new StreamWriter(path);
                                tw.WriteLine(highScoreEasy + "");
                                tw.WriteLine(highScoreMedium + "");
                                tw.WriteLine(highScoreHard + "");
                                tw.Close();
                            }


                            lblEasy.Content = highScoreEasy + "";
                            lblMedium.Content = highScoreMedium + "";
                            lblHard.Content = highScoreHard + "";

                            lose = true;
                        }


                        //respawn the square that was hit
                        int rndX = 0;
                        int rndY = 0;
                        //While used to make sure respawned sqaures are away from current player position to avoid instant collision
                        while (rndX < rectPlayer.Margin.Left + 50 + playerSize && rndX > rectPlayer.Margin.Left - 50 - playerSize)
                        {
                            rndX = globalSeed.Next(-475, 475);
                        }
                        while (rndY < rectPlayer.Margin.Top + 50 + playerSize && rndY > rectPlayer.Margin.Top - 50 - playerSize)
                        {
                            rndY = globalSeed.Next(-450, 450);
                        }
                        aisquares[i].Margin = new Thickness(rndX, rndY, 0, 0);
                    }
                }
            }));
        }
Пример #40
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            string audio = System.IO.Path.GetDirectoryName(Application.ExecutablePath);

            System.Media.SoundPlayer player = new System.Media.SoundPlayer(audio + @"\sfx-blipmale.wav");
            player.Play();

            if (String.IsNullOrEmpty(txt1.Text))
            {
                label2.Text = "";
                txt         = "LA CAJA ESTA VACÍA";
                len         = txt.Length;

                counter++;

                if (counter > len)
                {
                    counter     = 0;
                    label2.Text = "";
                }
                else
                {
                    label2.Text = txt.Substring(0, counter);
                }

                if (counter == txt.Length)
                {
                    timer1.Stop();
                }
                else
                {
                    //counter++;
                }
            }
            else
            {
                label2.Text = "";
                txt         = "EN LA CAJA HAY " + Convert.ToString(txt1.Text).ToUpper();
                len         = txt.Length;

                counter++;

                if (counter > len)
                {
                    counter     = 0;
                    label2.Text = "";
                }
                else
                {
                    label2.Text = txt.Substring(0, counter);
                }

                if (counter == txt.Length)
                {
                    timer1.Stop();
                }
                else
                {
                    //counter++;
                }
            }
        }
Пример #41
0
        private void btnKindleExtras_Click(object sender, EventArgs e)
        {
            //Check current settings
            if (!File.Exists(txtMobi.Text))
            {
                MessageBox.Show("Specified book was not found.", "Book Not Found");
                return;
            }
            if (rdoShelfari.Checked && txtShelfari.Text == "")
            {
                MessageBox.Show("No Shelfari link was specified.", "Missing Shelfari Link");
                return;
            }
            if (!File.Exists(settings.mobi_unpack))
            {
                MessageBox.Show("Kindleunpack was not found. Please review the settings page.", "Kindleunpack Not Found");
                return;
            }
            if (Properties.Settings.Default.realName.Trim().Length == 0 |
                Properties.Settings.Default.penName.Trim().Length == 0)
            {
                MessageBox.Show(
                    "Both Real and Pen names are required for End Action\r\n" +
                    "file creation. This information allows you to rate this\r\n" +
                    "book on Amazon. Please review the settings page.",
                    "Amazon Customer Details Not found");
                return;
            }

            //Create temp dir and ensure it exists
            string randomFile = Functions.GetTempDirectory();

            if (!Directory.Exists(randomFile))
            {
                MessageBox.Show("Temporary path not accessible for some reason.", "Temporary Directory Error");
                return;
            }

            //0 = asin, 1 = uniqid, 2 = databasename, 3 = rawML, 4 = author, 5 = title
            List <string> results;
            long          rawMLSize = 0;

            if (settings.useKindleUnpack)
            {
                Log("Running Kindleunpack to get metadata...");
                results = Functions.GetMetaData(txtMobi.Text, settings.outDir, randomFile, settings.mobi_unpack);
                if (!File.Exists(results[3]))
                {
                    Log("Error: RawML could not be found, aborting.\r\nPath: " + results[3]);
                    return;
                }
                rawMLSize = new FileInfo(results[3]).Length;
            }
            else
            {
                Log("Extracting metadata...");
                try
                {
                    Unpack.Metadata md = Functions.GetMetaDataInternal(txtMobi.Text, settings.outDir, false);
                    rawMLSize = md.PDH.TextLength;
                    results   = md.getResults();
                }
                catch (Exception ex)
                {
                    Log("Error getting metadata: " + ex.Message);
                    return;
                }
            }
            if (results.Count != 6)
            {
                Log(results[0]);
                return;
            }

            if (settings.saverawml && settings.useKindleUnpack)
            {
                Log("Saving rawML to dmp directory...");
                File.Copy(results[3], Path.Combine(Environment.CurrentDirectory + @"\dmp",
                                                   Path.GetFileName(results[3])), true);
            }

            // Added author name to log output
            Log(String.Format("Got metadata!\r\nDatabase Name: {0}\r\nASIN: {1}\r\nAuthor: {2}\r\nTitle: {3}\r\nUniqueID: {4}",
                              results[2], results[0], results[4], results[5], results[1]));
            try
            {
                BookInfo bookInfo = new BookInfo(results[5], results[4], results[0], results[1], results[2],
                                                 randomFile, Functions.RemoveInvalidFileChars(results[5]), txtShelfari.Text);
                Log("Attempting to build Author Profile...");
                AuthorProfile ap = new AuthorProfile(bookInfo, this);
                if (!ap.complete)
                {
                    return;
                }
                Log("Attempting to build Start Actions and End Actions...");
                EndActions ea = new EndActions(ap, bookInfo, rawMLSize, this);
                if (!ea.complete)
                {
                    return;
                }
                if (settings.useNewVersion)
                {
                    ea.GenerateNew();
                    Log("Attempting to build Start Actions...");
                    ea.GenerateStartActions();
                }
                else
                {
                    ea.GenerateOld();
                }

                if (Properties.Settings.Default.playSound)
                {
                    System.Media.SoundPlayer player =
                        new System.Media.SoundPlayer(Environment.CurrentDirectory + @"\done.wav");
                    player.Play();
                }

                try
                {
                    PopulateAPEAPreviews(ap, ea);
                }
                catch (Exception ex)
                {
                    Log("Error populating extras preview windows: " + ex.Message);
                }
            }
            catch (Exception ex)
            {
                Log("An error occurred while creating the new Author Profile, Start Actions, and/or End Actions files: " + ex.Message);
            }
        }
Пример #42
0
 /// <summary>
 /// Instantiates the sound player.
 /// Plays the click sound for each button clicked.
 /// </summary>
 private void play_Sound_Click()
 {
     sound_Player = new System.Media.SoundPlayer(Tablut.Properties.Resources.Menu_Click);
     sound_Player.Play();
 }
Пример #43
0
 /// <summary>
 /// Instantiates the sound player.
 /// Plays a sound when the mouse enters a button.
 /// </summary>
 /// <param name="sender">The button that called the function.</param>
 /// <param name="e">Contains informations about the raised "mouse enter" event.</param>
 private void play_Sound_Enter(object sender, EventArgs e)
 {
     sound_Player = new System.Media.SoundPlayer(Tablut.Properties.Resources.Menu_Move);
     sound_Player.Play();
 }
Пример #44
0
        private void BackgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            chatOutput = "[info] Starting IntelBot...\n";
            //string path = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "\\Documents\\EVE\\logs\\Chatlogs\\";
            string channelInput = ChannelName.Text;

            chatOutput += "[info] Path found: " + path + "\n";
            this.Invoke(new MethodInvoker(delegate { ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); }));
            string fileName = GetFileName(channelInput, path);

            if (fileName == "")
            {
                chatOutput               += "[ERROR] Channel not found. Please check your input and try again!\n";
                ChatOutput.Text           = chatOutput;
                ChatOutput.SelectionStart = ChatOutput.Text.Length;
                ChatOutput.ScrollToCaret();
            }
            else
            {
                chatOutput += "[info] Chat found: " + fileName + "\n";
                this.Invoke(new MethodInvoker(delegate { ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); }));
                string filePath = path + fileName;
                string keyword1 = System1.Text;
                if (keyword1 == "")
                {
                    keyword1 = "nofilterusedasdf1234";
                }
                string keyword2 = System2.Text;
                if (keyword2 == "")
                {
                    keyword2 = "nofilterusedasdf1234";
                }
                string keyword3 = System3.Text;
                if (keyword3 == "")
                {
                    keyword3 = "nofilterusedasdf1234";
                }
                string keyword4 = System4.Text;
                if (keyword4 == "")
                {
                    keyword4 = "nofilterusedasdf1234";
                }
                string keyword5 = System5.Text;
                if (keyword5 == "")
                {
                    keyword5 = "nofilterusedasdf1234";
                }
                string keyword6 = System6.Text;
                if (keyword6 == "")
                {
                    keyword6 = "nofilterusedasdf1234";
                }
                string keyword7 = System7.Text;
                if (keyword7 == "")
                {
                    keyword7 = "nofilterusedasdf1234";
                }
                string keyword8 = System8.Text;
                if (keyword8 == "")
                {
                    keyword8 = "nofilterusedasdf1234";
                }
                string keyword9 = System9.Text;
                if (keyword9 == "")
                {
                    keyword9 = "nofilterusedasdf1234";
                }
                string[] keywords = new string[] { keyword1, keyword2, keyword3, keyword4, keyword5, keyword6, keyword7, keyword8, keyword9 };

                chatOutput += "[info] Filters applied\n";
                this.Invoke(new MethodInvoker(delegate { ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); }));
                chatOutput += "[info] IntelBot running...\n";
                this.Invoke(new MethodInvoker(delegate { ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); }));

                int WrittenLines = 0;
                player = new System.Media.SoundPlayer(configPath + "alarm.wav");
                while (true)
                {
                    var allLines = ReadLinesFromFile(filePath);
                    for (int i = WrittenLines; i < allLines.Count; i++)                                                                                                                                                                                                                                                                                                    //Alle Zeilen durchgehen
                    {
                        if (WrittenLines < allLines.Count)                                                                                                                                                                                                                                                                                                                 //Alte Zeilen ausfiltern
                        {
                            if (allLines[i].Contains(keywords[0]) || allLines[i].Contains(keywords[1]) || allLines[i].Contains(keywords[2]) || allLines[i].Contains(keywords[3]) || allLines[i].Contains(keywords[4]) || allLines[i].Contains(keywords[5]) || allLines[i].Contains(keywords[6]) || allLines[i].Contains(keywords[7]) || allLines[i].Contains(keywords[8])) //Nach Keywords filtern
                            {
                                chatOutput += "---WARNING!---  ";
                                player.Play();
                            }
                            chatOutput += allLines[i] + "\n";
                            this.Invoke(new MethodInvoker(delegate { ChatOutput.Text = chatOutput; ChatOutput.SelectionStart = ChatOutput.Text.Length; ChatOutput.ScrollToCaret(); }));
                            WrittenLines = i + 1;
                        }
                    }
                    if (worker.CancellationPending == true)
                    {
                        e.Cancel = true;
                        break;
                    }
                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
Пример #45
0
        //public void Play(bool loop = false)
        //{
        //    var playCount = loop ? Songs.Count : 1;
        //    if (_isLocked)
        //    {
        //        return;
        //    }
        //    _isPlaying = true;
        //    for (int i = 0; i < playCount; i++)
        //    {
        //        Console.WriteLine($"Player is playing: {Songs[i].Name}, duration: {Songs[i].Duration}");
        //        System.Threading.Thread.Sleep(1000);
        //    }
        //}

        public void Play(bool loop = false)
        {
            if (_isLocked)
            {
                return;
            }
            ISkin.NewScreen();
            var playCount = loop ? Songs.Count : 1;

            for (int i = 0; i < playCount; i++)
            {
                if (Songs[i].Like.GetValueOrDefault(false))
                {
                    //Console.ForegroundColor = ConsoleColor.Green;
                    //Console.WriteLine($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");
                    //Console.ResetColor();
                    ISkin.Render($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");

                    foreach (var song in Songs)
                    {
                        PlayingSong = song;
                        SongStartedEvent?.Invoke(Songs, song, _isLocked, _volume);

                        using (System.Media.SoundPlayer player = new System.Media.SoundPlayer())
                        {
                            player.SoundLocation = PlayingSong.Path;
                            player.PlaySync();
                        }
                    }
                }
                //  else if (Songs[i].Like.HasValue ? !Songs[i].Like.Value : false)
                else if (Songs[i].Like.HasValue && !Songs[i].Like.Value)
                {
                    //Console.ForegroundColor = ConsoleColor.Red;
                    //Console.WriteLine($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");
                    //Console.ResetColor();
                    ISkin.Render($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");
                    foreach (var song in Songs)
                    {
                        PlayingSong = song;
                        SongStartedEvent?.Invoke(Songs, song, _isLocked, _volume);

                        using (System.Media.SoundPlayer player = new System.Media.SoundPlayer())
                        {
                            player.SoundLocation = PlayingSong.Path;
                            player.PlaySync();
                        }
                    }
                }
                else
                {
                    //Console.WriteLine($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");
                    ISkin.Render($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");
                    System.Threading.Thread.Sleep(1000);
                    foreach (var song in Songs)
                    {
                        PlayingSong = song;
                        SongStartedEvent?.Invoke(Songs, song, _isLocked, _volume);

                        using (System.Media.SoundPlayer player = new System.Media.SoundPlayer())
                        {
                            player.SoundLocation = PlayingSong.Path;
                            player.PlaySync();
                        }
                    }
                }
                //Console.WriteLine($"Player is playing: {Songs[i].Name}, duration: {Songs[i].Duration}");
                //Skin.Render($"Player is playing liked songs: {Songs[i].Name}, duration: {Songs[i].Duration}");
                //System.Threading.Thread.Sleep(1000);
            }
        }
Пример #46
0
 private void playSound(string path)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(@path);
     player.Play();
 }
Пример #47
0
        private static async Task ProcessTaskAsync(Definitions.List.TaskInfo currentTask)
        {
            try
            {
                TmInfoUpdate();

                ActiveTask         = currentTask;
                currentTask.Active = true;

                switch (currentTask.TaskType)
                {
                default:
                    await currentTask.App.CopyFilesAsync(currentTask, CancellationToken.Token).ConfigureAwait(false);

                    break;

                case TaskType.Delete:
                    await currentTask.App.DeleteFilesAsync(currentTask).ConfigureAwait(false);

                    currentTask.App.Library.Apps.Remove(currentTask.App);
                    break;

                case TaskType.Compact:
                    await currentTask.App.CompactTask(currentTask, CancellationToken.Token).ConfigureAwait(false);

                    break;
                }

                if (!CancellationToken.IsCancellationRequested && !currentTask.ErrorHappened)
                {
                    if (currentTask.RemoveOldFiles && currentTask.TaskType != TaskType.Delete && currentTask.TaskType != TaskType.Compact)
                    {
                        Main.FormAccessor.TmLogs.Report(Framework.StringFormat.Format(SLM.Translate(nameof(Properties.Resources.TaskManager_RemoveOldFiles)), new { CurrentTime = DateTime.Now, currentTask.App.AppName }));
                        await currentTask.App.DeleteFilesAsync(currentTask).ConfigureAwait(false);

                        currentTask.App.Library.Apps.Remove(currentTask.App);
                        Main.FormAccessor.TmLogs.Report(Framework.StringFormat.Format(SLM.Translate(nameof(Properties.Resources.TaskManager_RemoveOldFilesCompleted)), new { CurrentTime = DateTime.Now, currentTask.App.AppName }));
                    }

                    if (currentTask.TargetLibrary?.Type == LibraryType.Steam)
                    {
                        _isRestartRequired = true;
                    }

                    currentTask.TaskStatusInfo = SLM.Translate(nameof(Properties.Resources.TaskStatus_Completed));
                    currentTask.Active         = false;
                    currentTask.Completed      = true;

                    currentTask.TargetLibrary?.UpdateAppList();

                    if (currentTask.AutoInstall && !currentTask.Compress)
                    {
                        while (currentTask.TargetLibrary.IsUpdatingAppList)
                        {
                            await Task.Delay(100);
                        }

                        switch (currentTask.TargetLibrary.Type)
                        {
                        case LibraryType.Steam:
                        case LibraryType.SLM:
                            // Not available
                            break;

                        case LibraryType.Origin:
                        case LibraryType.Uplay:
                            currentTask.TargetLibrary.Apps.First(x => x.AppId == currentTask.App.AppId && x.IsCompressed == currentTask.Compress)?.InstallAsync();
                            break;
                        }
                    }

                    // Update library details
                    if (Definitions.SLM.CurrentSelectedLibrary == currentTask.App.Library)
                    {
                        App.UpdateAppPanel(currentTask.App.Library);
                    }
                }

                if (TaskList.Count(x => !x.Completed) == 0)
                {
                    if (Properties.Settings.Default.PlayASoundOnCompletion)
                    {
                        if (!string.IsNullOrEmpty(Properties.Settings.Default.CustomSoundFile) && File.Exists(Properties.Settings.Default.CustomSoundFile))
                        {
                            using (var soundPlayer = new System.Media.SoundPlayer(Properties.Settings.Default.CustomSoundFile))
                            {
                                soundPlayer.Play();
                            }
                        }
                        else
                        {
                            System.Media.SystemSounds.Exclamation.Play();
                        }
                    }

                    if (_isRestartRequired && !Properties.Settings.Default.TaskManager_SteamRestartSkip)
                    {
                        Steam.RestartSteamAsync();
                        _isRestartRequired = false;
                    }
                }

                if (Properties.Settings.Default.TaskManager_AutoClear && !currentTask.ErrorHappened)
                {
                    RemoveTaskProgress.Report(currentTask);
                }

                SLM.Library.UpdateLibraryVisual();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                Logger.Fatal(ex);
            }
            finally
            {
                TmInfoUpdate();
            }
        }
Пример #48
0
        static int playGame()
        {
            int callCounter        = 1;
            int askAudienceCounter = 1;
            int halfHalfCounter    = 1;

            System.Media.SoundPlayer playerBackground = play_background_sound();
            List <Question>          questions        = loadQuestions();

            Console.Clear();
            Random rnd              = new Random();
            int    amountWon        = 0;
            bool   gameOn           = true;
            int    counterQuestions = 0;
            string dateToday        = DateTime.Today.ToString("dd-MM-yyyy");

            Console.WriteLine("Type in your name:");
            string playerName = Console.ReadLine();

            Console.WriteLine("Type in your surname:");
            string playerSurname  = Console.ReadLine();
            int    questionNumber = 0;

            int[] questionNumberCheck = new int[16];
            bool  questionOK;

            Console.Clear();
            for (int i = 1; i < 16; i++)
            {
                if (gameOn == true)
                {
                    do
                    {
                        questionOK = true;
                        if (i < 5)
                        {
                            questionNumber = rnd.Next(1, 9);
                        }
                        if (i < 7 && i > 4)
                        {
                            questionNumber = rnd.Next(9, 13);
                        }
                        if (i < 9 && i > 6)
                        {
                            questionNumber = rnd.Next(13, 17);
                        }
                        if (i < 11 && i > 8)
                        {
                            questionNumber = rnd.Next(17, 21);
                        }
                        if (i < 13 && i > 10)
                        {
                            questionNumber = rnd.Next(21, 24);
                        }
                        if (i < 15 && i > 12)
                        {
                            questionNumber = rnd.Next(24, 29);
                        }
                        if (i == 15)
                        {
                            questionNumber = rnd.Next(29, 31);
                        }
                        for (int q = 0; q < 15; q++)
                        {
                            if (questionNumberCheck[q] == questionNumber)
                            {
                                questionOK = false;
                            }
                        }
                    } while (questionOK == false);
                    stop_background_sound(playerBackground);
                    System.Media.SoundPlayer player1 = new System.Media.SoundPlayer();
                    player1.SoundLocation = ("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\Sounds\\questions.wav");
                    player1.Play();
                    questionNumberCheck[i] = questionNumber;
                    Console.Write("{0}. question: ", i);
                    Console.WriteLine(questions[questionNumber - 1].name);
                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine("a: {0}", questions[questionNumber - 1].a);
                    Console.WriteLine();
                    Console.WriteLine("b: {0}", questions[questionNumber - 1].b);
                    Console.WriteLine();
                    Console.WriteLine("c: {0}", questions[questionNumber - 1].c);
                    Console.WriteLine();
                    Console.WriteLine("d: {0}", questions[questionNumber - 1].d);
                    Console.WriteLine();
                    Console.WriteLine();
                    Console.WriteLine("Avaliable jokers are:");
                    if (callCounter == 1)
                    {
                        Console.WriteLine("press i for Call joker");
                    }
                    if (askAudienceCounter == 1)
                    {
                        Console.WriteLine("press o for Ask audience joker");
                    }
                    if (halfHalfCounter == 1)
                    {
                        Console.WriteLine("press p for 50/50 joker");
                    }
                    Console.WriteLine();
                    Console.WriteLine("***** to quit the game press q");
                    Console.WriteLine();
                    Console.WriteLine("Your answer: ");
                    string yourAnswer = Console.ReadLine();


                    while (yourAnswer != "a" && yourAnswer != "b" && yourAnswer != "c" && yourAnswer != "d" &&
                           yourAnswer != "i" && yourAnswer != "o" && yourAnswer != "p" && yourAnswer != "q")
                    {
                        Console.Clear();
                        Console.WriteLine("Incorrect answer format. Please try again!");
                        Console.Write("{0}. question: ", i);
                        Console.WriteLine(questions[questionNumber - 1].name);
                        Console.WriteLine();
                        Console.WriteLine();
                        Console.WriteLine("a: {0}", questions[questionNumber - 1].a);
                        Console.WriteLine();
                        Console.WriteLine("b: {0}", questions[questionNumber - 1].b);
                        Console.WriteLine();
                        Console.WriteLine("c: {0}", questions[questionNumber - 1].c);
                        Console.WriteLine();
                        Console.WriteLine("d: {0}", questions[questionNumber - 1].d);
                        Console.WriteLine();
                        Console.WriteLine("Avaliable jokers are:");
                        if (callCounter == 1)
                        {
                            Console.WriteLine("press i for Call joker");
                        }
                        if (askAudienceCounter == 1)
                        {
                            Console.WriteLine("press o for Ask audience joker");
                        }
                        if (halfHalfCounter == 1)
                        {
                            Console.WriteLine("press p for 50/50 joker");
                        }
                        Console.WriteLine();
                        Console.WriteLine("***** to quit the game press q");
                        Console.WriteLine();
                        Console.WriteLine("Your answer: ");
                        yourAnswer = Console.ReadLine();
                    }

                    while (yourAnswer == "i" || yourAnswer == "o" || yourAnswer == "p")
                    {
                        if (yourAnswer == "i" && callCounter == 1)
                        {
                            string friend = getFriend();
                            callCounter++;
                            int chance = rnd.Next(1, 101);
                            if (counterQuestions < 5)
                            {
                                chance = rnd.Next(1, 55);
                            }
                            if (counterQuestions >= 5 && counterQuestions < 7)
                            {
                                chance = rnd.Next(1, 60);
                            }
                            if (counterQuestions >= 7 && counterQuestions < 9)
                            {
                                chance = rnd.Next(1, 65);
                            }
                            if (counterQuestions >= 9 && counterQuestions < 11)
                            {
                                chance = rnd.Next(1, 70);
                            }
                            if (counterQuestions >= 11 && counterQuestions < 13)
                            {
                                chance = rnd.Next(1, 75);
                            }
                            if (counterQuestions >= 13 && counterQuestions < 15)
                            {
                                chance = rnd.Next(1, 80);
                            }
                            if (counterQuestions == 15)
                            {
                                chance = rnd.Next(1, 85);
                            }

                            if (chance < 50)
                            {
                                Console.WriteLine();
                                Console.WriteLine("**CALL** {0} says the answer is: {1}", friend, questions[questionNumber - 1].correct);
                                Console.WriteLine();
                            }
                            else
                            {
                                int luck = rnd.Next(1, 4);
                                if (luck == 1)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("**CALL** {0} says the answer is: a", friend);
                                    Console.WriteLine();
                                }
                                if (luck == 2)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("**CALL** {0} says the answer is: b", friend);
                                    Console.WriteLine();
                                }
                                if (luck == 3)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("**CALL** {0} says the answer is: c", friend);
                                    Console.WriteLine();
                                }
                                if (luck == 4)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("**CALL** {0}  says the answer is: d", friend);
                                    Console.WriteLine();
                                }
                            }

                            Console.WriteLine("Your answer: ");
                            yourAnswer = Console.ReadLine();
                            while (yourAnswer != "a" && yourAnswer != "b" && yourAnswer != "c" && yourAnswer != "d" &&
                                   yourAnswer != "i" && yourAnswer != "o" && yourAnswer != "p" && yourAnswer != "q")
                            {
                                Console.WriteLine("Incorrect answer format. Please try again!");
                                Console.WriteLine("Your answer: ");
                                yourAnswer = Console.ReadLine();
                            }
                        }
                        if (yourAnswer == "o" && askAudienceCounter == 1)
                        {
                            askAudienceCounter++;
                            int chance = rnd.Next(1, 101);

                            if (counterQuestions < 5)
                            {
                                chance = rnd.Next(1, 55);
                            }
                            if (counterQuestions >= 5 && counterQuestions < 7)
                            {
                                chance = rnd.Next(1, 60);
                            }
                            if (counterQuestions >= 7 && counterQuestions < 9)
                            {
                                chance = rnd.Next(1, 65);
                            }
                            if (counterQuestions >= 9 && counterQuestions < 11)
                            {
                                chance = rnd.Next(1, 70);
                            }
                            if (counterQuestions >= 11 && counterQuestions < 13)
                            {
                                chance = rnd.Next(1, 75);
                            }
                            if (counterQuestions >= 13 && counterQuestions < 15)
                            {
                                chance = rnd.Next(1, 80);
                            }
                            if (counterQuestions == 15)
                            {
                                chance = rnd.Next(1, 85);
                            }

                            if (chance < 50)
                            {
                                Console.WriteLine();
                                Console.WriteLine("Audience says the answer is: {0}", questions[questionNumber - 1].correct);
                                Console.WriteLine();
                            }
                            else
                            {
                                int luck = rnd.Next(1, 4);
                                if (luck == 1)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("Audience says the answer is: a");
                                    Console.WriteLine();
                                }
                                if (luck == 2)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("Audience says the answer is: b");
                                    Console.WriteLine();
                                }
                                if (luck == 3)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("Audience says the answer is: c");
                                    Console.WriteLine();
                                }
                                if (luck == 4)
                                {
                                    Console.WriteLine();
                                    Console.WriteLine("Audience says the answer is: d");
                                    Console.WriteLine();
                                }
                            }

                            Console.WriteLine("Your answer: ");
                            yourAnswer = Console.ReadLine();
                            while (yourAnswer != "a" && yourAnswer != "b" && yourAnswer != "c" && yourAnswer != "d" &&
                                   yourAnswer != "i" && yourAnswer != "o" && yourAnswer != "p" && yourAnswer != "q")
                            {
                                Console.WriteLine("Incorrect answer format. Please try again!");
                                Console.WriteLine("Your answer: ");
                                yourAnswer = Console.ReadLine();
                            }
                        }
                        if (yourAnswer == "p" && halfHalfCounter == 1)
                        {
                            string firstCase  = "";
                            string secondCase = questions[questionNumber - 1].correct;
                            halfHalfCounter++;

                            int firstRand = rnd.Next(1, 3);
                            if (firstRand == 1)
                            {
                                firstCase = questions[questionNumber - 1].correct;
                                do
                                {
                                    int secondRand = rnd.Next(1, 4);
                                    if (secondRand == 1)
                                    {
                                        secondCase = ("a");
                                    }
                                    if (secondRand == 2)
                                    {
                                        secondCase = ("b");
                                    }
                                    if (secondRand == 3)
                                    {
                                        secondCase = ("c");
                                    }
                                    if (secondRand == 4)
                                    {
                                        secondCase = ("d");
                                    }
                                } while (secondCase == questions[questionNumber - 1].correct);
                            }
                            if (firstRand == 2)
                            {
                                do
                                {
                                    int secondRand = rnd.Next(1, 4);
                                    if (secondRand == 1)
                                    {
                                        firstCase = ("a");
                                    }
                                    if (secondRand == 2)
                                    {
                                        firstCase = ("b");
                                    }
                                    if (secondRand == 3)
                                    {
                                        firstCase = ("c");
                                    }
                                    if (secondRand == 4)
                                    {
                                        firstCase = ("d");
                                    }
                                } while (firstCase == questions[questionNumber - 1].correct);
                            }

                            Console.WriteLine();
                            Console.WriteLine("Correct answer is: {0} or {1}", firstCase, secondCase);
                            Console.WriteLine();
                            Console.WriteLine("Your answer: ");
                            yourAnswer = Console.ReadLine();
                            while (yourAnswer != firstCase && yourAnswer != secondCase && yourAnswer != "i" && yourAnswer != "o" && yourAnswer != "p" && yourAnswer != "q")
                            {
                                Console.WriteLine("Incorrect answer format. Please try again!");
                                Console.WriteLine("Your answer: ");
                                yourAnswer = Console.ReadLine();
                            }
                        }
                        if (yourAnswer == "p" && halfHalfCounter == 2 || yourAnswer == "o" && askAudienceCounter == 2 || yourAnswer == "i" && callCounter == 2)
                        {
                            Console.WriteLine("Incorrect answer format. Please try again!");
                            Console.WriteLine("Your answer: ");
                            yourAnswer = Console.ReadLine();
                            while (yourAnswer != "a" && yourAnswer != "b" && yourAnswer != "c" && yourAnswer != "d" &&
                                   yourAnswer != "i" && yourAnswer != "o" && yourAnswer != "p" && yourAnswer != "q")
                            {
                                Console.WriteLine("Incorrect answer format. Please try again!");
                                Console.WriteLine("Your answer: ");
                                yourAnswer = Console.ReadLine();
                            }
                        }
                    }
                    if (yourAnswer == questions[questionNumber - 1].correct)
                    {
                        System.Media.SoundPlayer playerCorrect = new System.Media.SoundPlayer();
                        playerCorrect.SoundLocation = ("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\Sounds\\correct1.wav");
                        System.Media.SoundPlayer playerCorrectBig = new System.Media.SoundPlayer();
                        playerCorrectBig.SoundLocation = ("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\Sounds\\correct2.wav");
                        Console.Clear();
                        player1.Stop();
                        counterQuestions += 1;
                        Console.WriteLine("CORRECT");
                        if (counterQuestions == 1)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 100KN!");
                            amountWon = 100;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 2)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 200KN!");
                            amountWon = 200;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 3)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 300KN!");
                            amountWon = 300;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 4)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 500KN!");
                            amountWon = 500;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 5)
                        {
                            playerCorrectBig.Play();
                            Console.WriteLine();
                            Console.WriteLine("YOU HAVE WON 1000KN!!!!!!!!!!!!!!!!!!!!!!!!!");
                            amountWon = 1000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(8000);
                            Console.Clear();
                        }
                        if (counterQuestions == 6)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 2000KN!");
                            amountWon = 2000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 7)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 4000KN!");
                            amountWon = 4000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 8)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 8000KN!");
                            amountWon = 8000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 9)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 1600KN!");
                            amountWon = 16000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 10)
                        {
                            playerCorrectBig.Play();
                            Console.WriteLine();
                            Console.WriteLine("YOU HAVE WON 32000KN!!!!!!!!!!!!!!!!!!!!!!!!!");
                            amountWon = 32000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(8000);
                            Console.Clear();
                        }
                        if (counterQuestions == 11)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 64000KN!");
                            amountWon = 64000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 12)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 125000KN!");
                            amountWon = 125000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 13)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 250000KN!");
                            amountWon = 250000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 14)
                        {
                            playerCorrect.Play();
                            Console.WriteLine();
                            Console.WriteLine("You have won 500000KN!");
                            amountWon = 500000;
                            Console.WriteLine();
                            System.Threading.Thread.Sleep(5000);
                            Console.Clear();
                        }
                        if (counterQuestions == 15)
                        {
                            Console.WriteLine();
                            Console.WriteLine("YOU HAVE WON 1000000KN!!!!!!!!!!!!!!!!!!!!!!!!!");
                            amountWon = 1000000;
                            Console.WriteLine();
                            playerCorrectBig.Play();
                            System.Threading.Thread.Sleep(8000);
                            Console.Clear();
                        }
                    }
                    if (yourAnswer == "q")
                    {
                        gameOn = false;
                        Console.Clear();
                        Console.WriteLine("You have quit!");
                        player1.Stop();
                        System.Media.SoundPlayer playerQuit = new System.Media.SoundPlayer();
                        playerQuit.SoundLocation = ("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\Sounds\\fail.wav");
                        playerQuit.Play();
                        System.Threading.Thread.Sleep(5000);
                    }
                    if (yourAnswer != questions[questionNumber - 1].correct && yourAnswer != "q")
                    {
                        if (counterQuestions < 5)
                        {
                            amountWon = 0;
                        }
                        if (counterQuestions >= 5)
                        {
                            amountWon = 1000;
                        }
                        if (counterQuestions >= 10)
                        {
                            amountWon = 32000;
                        }
                        if (counterQuestions == 15)
                        {
                            amountWon = 1000000;
                        }
                        Console.Clear();
                        player1.Stop();
                        gameOn = false;
                        Console.WriteLine("INCORRECT");
                        System.Media.SoundPlayer playerIncorrect = new System.Media.SoundPlayer();
                        playerIncorrect.SoundLocation = ("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\Sounds\\fail.wav");
                        playerIncorrect.Play();
                        System.Threading.Thread.Sleep(5000);
                    }
                }
            }

            string usedJokers = "";

            if (callCounter != 1)
            {
                usedJokers = usedJokers + " " + "Call";
            }
            if (askAudienceCounter != 1)
            {
                usedJokers = usedJokers + " " + "Ask audience";
            }
            if (halfHalfCounter != 1)
            {
                usedJokers = usedJokers + " " + "50/50";
            }

            Console.WriteLine("You have won {0} kn", amountWon);

            XmlDocument doc = new XmlDocument();

            doc.Load("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\results.xml");
            XmlNode Player = doc.CreateElement("Player");
            XmlNode name   = doc.CreateElement("name");

            name.InnerText = playerName;
            Player.AppendChild(name);
            XmlNode surname = doc.CreateElement("surname");

            surname.InnerText = playerSurname;
            Player.AppendChild(surname);
            XmlNode date = doc.CreateElement("date");

            date.InnerText = dateToday;
            Player.AppendChild(date);
            XmlNode moneyWon = doc.CreateElement("moneyWon");

            moneyWon.InnerText = Convert.ToString(amountWon);
            Player.AppendChild(moneyWon);
            XmlNode jokers = doc.CreateElement("jokers");

            jokers.InnerText = usedJokers;
            Player.AppendChild(jokers);
            doc.DocumentElement.AppendChild(Player);
            doc.Save("C:\\Users\\Mario\\Documents\\Visual Studio 2017\\Projects\\Millionaire\\results.xml");


            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();
            System.Media.SoundPlayer background_sound = play_background_sound();
            showMenu();
            int choice = your_option();

            return(choice);
        }
Пример #49
0
 public static void reproducirsonido()
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer();
     player.SoundLocation = "Sonido/Alarma.wav";
 }
Пример #50
0
        static void Main(string[] args)
        {
            System.Media.SoundPlayer move     = new System.Media.SoundPlayer(@"C:\Users\User\Desktop\Snake\Snake\sound\move.wav");
            System.Media.SoundPlayer eat      = new System.Media.SoundPlayer(@"C:\Users\User\Desktop\Snake\Snake\sound\eat.wav");
            System.Media.SoundPlayer gameover = new System.Media.SoundPlayer(@"C:\Users\User\Desktop\Snake\Snake\sound\gameover.wav");
            System.Media.SoundPlayer crash    = new System.Media.SoundPlayer(@"C:\Users\User\Desktop\Snake\Snake\sound\crash.wav");
            byte   right             = 0;
            byte   left              = 1;
            byte   down              = 2;
            byte   up                = 3;
            int    lastFoodTime      = 0;
            int    foodDissapearTime = 12000;
            int    negativePoints    = 0;
            double sleepTime         = 100;
            int    direction         = right; // To make the snake go to the right when the program starts

            Random randomNumbersGenerator = new Random();

            Console.BufferHeight = Console.WindowHeight;
            lastFoodTime         = Environment.TickCount;

            // Make sure the snake spawn with just 3 "*"s and spawn it on the top left of the screen

            Queue <Position> snakeElements = new Queue <Position>();

            for (int i = 0; i <= 3; i++) //spawn snake body
            {
                snakeElements.Enqueue(new Position(0, i));
            }

            // Spawn the first 5 obstacles in the game

            List <Position> obstacles = new List <Position>() //spawn the first obstacles
            {
                new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                             randomNumbersGenerator.Next(0, Console.WindowWidth)),
                new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                             randomNumbersGenerator.Next(0, Console.WindowWidth)),
                new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                             randomNumbersGenerator.Next(0, Console.WindowWidth)),
                new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                             randomNumbersGenerator.Next(0, Console.WindowWidth)),
                new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                             randomNumbersGenerator.Next(0, Console.WindowWidth)),
            };

            foreach (Position obstacle in obstacles) //write obstacle as "=" on declared position
            {
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.SetCursorPosition(obstacle.y, obstacle.x);
                Console.Write("=");
            }

            //Food Creation

            Position food;

            do //randomize where the food spawns
            {
                food = new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                                    randomNumbersGenerator.Next(0, Console.WindowWidth));
            }while (snakeElements.Contains(food) || obstacles.Contains(food)); //to make sure that food doesnt spawn on both snake and obstacles


            //Movement implementation

            Position[] directions = new Position[]
            {
                new Position(0, 1),  // right
                new Position(0, -1), // left
                new Position(1, 0),  // down
                new Position(-1, 0), // up
            };

            while (true) //read the direction of arrow key which user inputted
            {
                negativePoints++;

                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo userInput = Console.ReadKey();
                    if (userInput.Key == ConsoleKey.LeftArrow)
                    {
                        if (direction != right)
                        {
                            direction = left;
                        }
                        move.Play();
                    }
                    if (userInput.Key == ConsoleKey.RightArrow)
                    {
                        if (direction != left)
                        {
                            direction = right;
                        }
                        move.Play();
                    }
                    if (userInput.Key == ConsoleKey.UpArrow)
                    {
                        if (direction != down)
                        {
                            direction = up;
                        }
                        move.Play();
                    }
                    if (userInput.Key == ConsoleKey.DownArrow)
                    {
                        if (direction != up)
                        {
                            direction = down;
                        }
                        move.Play();
                    }
                }


                //Creating the snake:

                Position snakeHead     = snakeElements.Last();  //make sure the head of the snake is spawned at the end of the "*" position
                Position nextDirection = directions[direction]; //initialize which direction is inputted

                Position snakeNewHead = new Position(snakeHead.x + nextDirection.x,
                                                     snakeHead.y + nextDirection.y); //snakehead will move to the same direction to which the user inputted

                // make sure the snake wont be able to go outside the screen
                if (snakeNewHead.y < 0)
                {
                    snakeNewHead.y = Console.WindowWidth - 1;
                }
                if (snakeNewHead.x < 0)
                {
                    snakeNewHead.x = Console.WindowHeight - 1;
                }
                if (snakeNewHead.x >= Console.WindowHeight)
                {
                    snakeNewHead.x = 0;
                }
                if (snakeNewHead.y >= Console.WindowWidth)
                {
                    snakeNewHead.y = 0;
                }

                foreach (Position position in snakeElements) //writes the body of the snake as "*" on declared position
                {
                    Console.SetCursorPosition(position.y, position.x);
                    Console.ForegroundColor = ConsoleColor.DarkGray;
                    Console.Write("*");
                }

                int userPoints = (snakeElements.Count - 4) * 100;

                // Show and update the score of the player

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.SetCursorPosition(110, 0);
                Console.Write("Score: {0}", userPoints);

                // the game will be over when the snake hits it body or the obstacles

                if (snakeElements.Contains(snakeNewHead) || obstacles.Contains(snakeNewHead))
                {
                    gameover.Play();

                    Console.SetCursorPosition(50, 6);

                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Game over!");
                    //if (userPoints < 0) userPoints = 0;

                    Console.SetCursorPosition(45, 7);
                    Console.WriteLine("Your points are: {0}", userPoints);

                    Console.SetCursorPosition(35, 8);
                    Console.WriteLine("Please press the ENTER key to exit the game.");

                    string nametext = Console.ReadLine();

                    using (System.IO.StreamWriter file =
                               new System.IO.StreamWriter(@"C:\Users\joe_y\Desktop\Snaketest\score.txt", true))
                    {
                        file.WriteLine(nametext + " - " + userPoints.ToString());
                    }
                    Console.WriteLine("Please press the ENTER key to exit the game."); //true here mean we won't output the key to the console, just cleaner in my opinion.

                    ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                    if (keyInfo.Key == ConsoleKey.Enter)
                    {
                        return;
                    }
                }


                // The game will be over and user will win if they reached 1000 points

                if (userPoints == 1000)
                {
                    Console.SetCursorPosition(0, 0);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Congrats! You've won the game!");
                    Console.WriteLine("Your points are: {0}", userPoints);
                    int loopcount = 0;
                    while (Console.ReadKey().Key != ConsoleKey.Enter)
                    {
                        if (Console.ReadKey().Key == ConsoleKey.Enter)
                        {
                            return;
                        }
                        loopcount = +1;
                    }
                }

                // writes the head of the snake as ">","<","^","v" to the position it is declared
                snakeElements.Enqueue(snakeNewHead);
                Console.SetCursorPosition(snakeNewHead.y, snakeNewHead.x);
                Console.ForegroundColor = ConsoleColor.Gray;
                if (direction == right)
                {
                    Console.Write(">");
                }
                if (direction == left)
                {
                    Console.Write("<");
                }
                if (direction == up)
                {
                    Console.Write("^");
                }
                if (direction == down)
                {
                    Console.Write("v");
                }


                //What will happened if the snake got fed:
                if (snakeNewHead.y == food.y && snakeNewHead.x == food.x)
                {
                    // Things that will be happening with the FOOD once it got ate by the snake
                    do
                    {
                        food = new Position(randomNumbersGenerator.Next(0, Console.WindowHeight), //randomize the new position of the food
                                            randomNumbersGenerator.Next(0, Console.WindowWidth));
                    }while (snakeElements.Contains(food) || obstacles.Contains(food));            //writes "@" to indicate food to the designated position it randomized
                    eat.Play();
                    lastFoodTime = Environment.TickCount;
                    sleepTime--;

                    // Things that will be happening with the OBSTACLE once the FOOD got ate by the snake

                    Position obstacle = new Position(); // randomize the position of the obstacles
                    do
                    {
                        obstacle = new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                                                randomNumbersGenerator.Next(0, Console.WindowWidth));
                    }while (snakeElements.Contains(obstacle) ||
                            obstacles.Contains(obstacle) ||
                            (food.x != obstacle.x && food.y != obstacle.y));
                    obstacles.Add(obstacle);
                    Console.SetCursorPosition(obstacle.y, obstacle.x);
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.Write("=");
                }
                else
                {
                    // moving...
                    Position last = snakeElements.Dequeue(); // basically moving the snake and delete the last "body part" of the snake to maintain the length of the snake
                    Console.SetCursorPosition(last.y, last.x);
                    Console.Write(" ");
                }


                // Initialize the time taken for the food to spawn if the snake doesn't eat it

                if (Environment.TickCount - lastFoodTime >= foodDissapearTime)
                {
                    negativePoints = negativePoints + 50;
                    Console.SetCursorPosition(food.y, food.x);
                    Console.Write(" ");
                    do
                    {
                        food = new Position(randomNumbersGenerator.Next(0, Console.WindowHeight),
                                            randomNumbersGenerator.Next(0, Console.WindowWidth));
                    }while (snakeElements.Contains(food) || obstacles.Contains(food));
                    lastFoodTime = Environment.TickCount;
                }

                Console.SetCursorPosition(food.y, food.x);
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.Write("@");

                sleepTime -= 0.01;

                Thread.Sleep((int)sleepTime);
            }
        }
Пример #51
0
        private void playMixed(int numDice)
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(DiceRollForm));
            if (numDice > 2)
            {
                numDice = 3;
            }
            var a       = global::dnd.Properties.Resources.Mixed_4_1;
            int choices = getRandom(8);

            switch (numDice)
            {
            case 3:
                if (choices == 8)
                {
                    a = global::dnd.Properties.Resources.Mixed_4_1;
                }
                else if (choices == 7)
                {
                    a = global::dnd.Properties.Resources.Mixed_4_2;
                }
                else if (choices == 6)
                {
                    a = global::dnd.Properties.Resources.Mixed_4_3;
                }
                else if (choices == 5)
                {
                    a = global::dnd.Properties.Resources.Mixed_4_4;
                }
                else if (choices == 4)
                {
                    a = global::dnd.Properties.Resources.Mixed_3_1;
                }
                else if (choices == 3)
                {
                    a = global::dnd.Properties.Resources.Mixed_3_2;
                }
                else if (choices == 2)
                {
                    a = global::dnd.Properties.Resources.Mixed_3_3;
                }
                else
                {
                    a = global::dnd.Properties.Resources.Mixed_3_4;
                }
                break;

            case 2:
                choices = getRandom(4);
                if (choices == 4)
                {
                    a = global::dnd.Properties.Resources.Mixed_2_1;
                }
                else if (choices == 3)
                {
                    a = global::dnd.Properties.Resources.Mixed_2_2;
                }
                else if (choices == 2)
                {
                    a = global::dnd.Properties.Resources.Mixed_2_3;
                }
                else
                {
                    a = global::dnd.Properties.Resources.Mixed_2_4;
                }
                break;

            default:
                choices = getRandom(4);
                if (choices == 4)
                {
                    a = global::dnd.Properties.Resources._1_Metal_1;
                }
                else if (choices == 3)
                {
                    a = global::dnd.Properties.Resources._1_metal_2;
                }
                else if (choices == 2)
                {
                    a = global::dnd.Properties.Resources._1_Plastic_3;
                }
                else
                {
                    a = global::dnd.Properties.Resources._1_Plastic_4;
                }
                break;
            }
            System.Media.SoundPlayer player = new System.Media.SoundPlayer(a);
            player.Play();
        }
Пример #52
0
 private void c_ding_SelectedIndexChanged(object sender, EventArgs e)
 {
     System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"Counter/" + c_ding.Text + ".wav");
     player.Play();
 }
Пример #53
0
 private void btn_sair_MouseEnter(object sender, EventArgs e)
 {
     btn_sair.BackgroundImage = sair_high;
     System.Media.SoundPlayer player = new System.Media.SoundPlayer("sys_sounds/hover.wav");
     player.Play();
 }
        // Game timer that determines player and enemy movement and collisions
        private void Timer_Tick(object sender, System.EventArgs e)
        {
            // If player is not on a platform, apply jumpspeed
            if (!onPlatform)
            {
                player.Top += jumpSpeed;
            }

            // Prevents infinite jump
            if (jumping && force < 0)
            {
                jumping = false;
            }

            // Left and right movements
            if (goLeft)
            {
                player.Left -= 6;
            }
            else if (goRight)
            {
                player.Left += 6;
            }

            // When jumping, apply negative jumpspeed and force
            if (jumping)
            {
                jumpSpeed = -1 * JS;
                force    -= 1;
            }
            // Else, apply positive jumpspeed
            else
            {
                jumpSpeed = JS;
            }

            // Collision Checks
            foreach (Control x in this.Controls)
            {
                // Intersection Checks
                if (player.Bounds.IntersectsWith(x.Bounds))
                {
                    // Player cannot go through floor
                    if (x.Tag.Equals("floor") && !jumping)
                    {
                        force           = 8;
                        player.Top      = x.Top - player.Height;
                        onPlatform      = true;
                        currentPlatform = (Platform)x;

                        // When player lands on floor, switch sprite from jumping to
                        // appropriate image
                        if (goLeft)
                        {
                            player.Image = Image.FromFile("run_left.gif");
                        }
                        else if (goRight)
                        {
                            player.Image = Image.FromFile("run_right.gif");
                        }
                        else
                        {
                            if (lookLeft)
                            {
                                player.Image = Image.FromFile("stand_left.png");
                            }
                            else
                            {
                                player.Image = Image.FromFile("stand_right.png");
                            }
                        }
                    }
                    // Player cannot go through edges
                    if (x.Tag.Equals("edge"))
                    {
                        if (goLeft)
                        {
                            player.Left = x.Left + player.Width;
                        }
                        if (goRight)
                        {
                            player.Left = x.Left - player.Width;
                        }
                    }

                    // Player collects a coin
                    if (x.Tag.Equals("coin"))
                    {
                        UpdateScore(10);
                        x.Dispose();
                        sfxPlayer = new System.Media.SoundPlayer("Coin.wav");
                        sfxPlayer.Play();
                    }
                    // Player collects a heart
                    if (x.Tag.Equals("heart"))
                    {
                        UpdateLives(1);
                        x.Dispose();
                        sfxPlayer = new System.Media.SoundPlayer("getItem.wav");
                        sfxPlayer.Play();
                    }
                    // Player reaches the exit
                    if (x.Tag.Equals("exit"))
                    {
                        UpdateScore(50);
                        timer.Stop();
                        Next();
                    }
                } // End of Intersection Checks

                // Player landing on platform check
                if (x.Tag.Equals("platform") && player.Right > x.Left && player.Left < x.Right &&
                    (player.Bottom <= x.Top && player.Bottom >= x.Top - 20) && !jumping)
                {
                    force           = 8;
                    player.Top      = x.Top - player.Height;
                    onPlatform      = true;
                    currentPlatform = (Platform)x;

                    // When player lands on platform, switch sprite from jumping to
                    // appropriate image
                    if (goLeft)
                    {
                        player.Image = Image.FromFile("run_left.gif");
                    }
                    else if (goRight)
                    {
                        player.Image = Image.FromFile("run_right.gif");
                    }
                    else
                    {
                        if (lookLeft)
                        {
                            player.Image = Image.FromFile("stand_left.png");
                        }
                        else
                        {
                            player.Image = Image.FromFile("stand_right.png");
                        }
                    }
                }

                // Player landing on a turtle of barrel, or getting hit by them
                if ((x.Tag.Equals("turtle") || x.Tag.Equals("barrel")))
                {
                    // If player land on a turtle or barrel, kill it and add to score
                    if (player.Right > x.Left && player.Left < x.Right &&
                        (player.Bottom < x.Top && player.Bottom >= x.Top - 20) && !jumping)
                    {
                        if (x.Tag.Equals("turtle"))
                        {
                            UpdateScore(15);
                            sfxPlayer = new System.Media.SoundPlayer("turtledie.wav");
                            sfxPlayer.Play();
                        }
                        else
                        {
                            UpdateScore(20);
                        }
                        x.Dispose();
                    }

                    // Else player is attacked by turtle or barrel, reset to start and lose a life
                    else if (player.Bounds.IntersectsWith(x.Bounds))
                    {
                        player.Left  = 60;
                        player.Top   = 600;
                        player.Image = Image.FromFile("death.png");
                        onPlatform   = false;
                        UpdateScore(-10);
                        UpdateLives(-1);
                        if (GetLives() == 0)
                        {
                            End();
                        }
                    }
                }

                // Player is attacked by a ghost
                if (x.Tag.Equals("ghost") && player.Bounds.IntersectsWith(x.Bounds))
                {
                    player.Left  = 60;
                    player.Top   = 600;
                    player.Image = Image.FromFile("death.png");
                    onPlatform   = false;
                    UpdateScore(-10);
                    UpdateLives(-1);
                    if (GetLives() == 0)
                    {
                        End();
                    }
                }

                // Update Enemy movements
                if (x is Enemy)
                {
                    Enemy temp = (Enemy)x;
                    temp.Movement();
                }

                // Barrel Gravity
                if (x.Tag.Equals("barrel"))
                {
                    Barrel temp = (Barrel)x;
                    foreach (Control y in this.Controls)
                    {
                        // If barrel is not on a platform or another barrel
                        if (!temp.OnPlatform && !(y is Barrel))
                        {
                            // If barrel intersects with a platform or floo,
                            // set it as the platform that it is on.
                            if ((y.Tag.Equals("platform") || y.Tag.Equals("floor")) &&
                                temp.Bounds.IntersectsWith(y.Bounds))
                            {
                                Platform temp2 = (Platform)y;
                                temp.Platform = temp2;
                            }
                        }

                        // Reverse the barrel direction if it hits an edge
                        if (y.Tag.Equals("edge") && temp.Bounds.IntersectsWith(y.Bounds))
                        {
                            if (temp.GoingLeft)
                            {
                                temp.GoingLeft = false;
                            }
                            else
                            {
                                temp.GoingLeft = true;
                            }
                        }
                    }
                } // End of Barrel Gravity
            }     // End of Collision Checks

            // If a player is on a platform and moves off of the platform, they begin to fall
            if (currentPlatform != null)
            {
                // Leave from the left
                if (goLeft && player.Right < currentPlatform.Left)
                {
                    onPlatform      = false;
                    currentPlatform = null;
                }

                // Leave from the right
                if (goRight && player.Left > currentPlatform.Right)
                {
                    onPlatform      = false;
                    currentPlatform = null;
                }
            }
        }
Пример #55
0
 static void stop_background_sound(System.Media.SoundPlayer player)
 {
     player.Stop();
 }
Пример #56
0
//---------------------------------------------------------------------

//  playeroSound()

//       Creates a SoundPlayer object, loads the rawhide sound file and plays

//       the file.

//---------------------------------------------------------------------

        private void playeroSound()
        {
            sndPlayer = new System.Media.SoundPlayer(Properties.Resources.rawhide);
            sndPlayer.Play();
        }
Пример #57
0
        public ConfigEdit()
        {
            InitializeComponent();

            this.Loaded += ConfigEdit_Loaded;

            _cfgValKeeper   = new CfgValueKeeper();
            _appNewSettings = new Dictionary <string, string>();

            // размеры окна
            double screenWidth  = (double)WpfHelper.GetAppGlobalValue("screenWidth");
            double screenHeight = (double)WpfHelper.GetAppGlobalValue("screenHeight");

            this.Width  = 0.67d * screenWidth;
            this.Height = 0.75d * screenHeight;


            // дополнтельные действия в зависимости от подтверджения готовности
            cbxState3.IsEnabled = KDSModeHelper.IsReadTakenDishes;
            // (bool)WpfHelper.GetAppGlobalValue("UseReadyConfirmedState", false)
            _useReadyConfirmedState = KDSModeHelper.UseReadyConfirmedState;
            if (_useReadyConfirmedState)
            {
                cbxState8.Visibility = Visibility.Visible;

                cbx18.Visibility = Visibility.Visible;
                cbx28.Visibility = Visibility.Visible;
                cbx83.Visibility = Visibility.Visible;
                cbx82.Visibility = Visibility.Visible;
                cbx81.Visibility = Visibility.Visible;
            }
            else
            {
                cbxState8.Visibility = Visibility.Collapsed;

                cbx18.Visibility = Visibility.Collapsed;
                cbx28.Visibility = Visibility.Collapsed;
                cbx83.Visibility = Visibility.Collapsed;
                cbx82.Visibility = Visibility.Collapsed;
                cbx81.Visibility = Visibility.Collapsed;
            }

            // заполнить комбобокс звуковых файлов
            _audioPath = AppEnvironment.GetAppDirectory("Audio");
            _wavPlayer = new System.Media.SoundPlayer();
            if (Directory.Exists(_audioPath))
            {
                DirectoryInfo dirInfo = new DirectoryInfo(_audioPath);
                List <string> files   = new List <string>();

                foreach (FileInfo fileInfo in dirInfo.GetFiles("*.wav", SearchOption.TopDirectoryOnly))
                {
                    files.Add(fileInfo.Name);
                }
                cbxSelectAudio.ItemsSource = files;

                var defFile = WpfHelper.GetAppGlobalValue("NewOrderAudioAttention");
                if ((defFile != null) && (files.Contains(defFile)))
                {
                    cbxSelectAudio.SelectedValue = defFile;
                    _wavPlayer.SoundLocation     = _audioPath + defFile;
                    _wavPlayer.LoadAsync();
                }
            }
            cbxSelectAudio.SelectionChanged += CbxSelectAudio_SelectionChanged;
        }
Пример #58
0
 //this method is used to generate the sound of the fire
 public void playSound()
 {
     //when the counter match with the trigger after that generate  the sound of fire
     System.Media.SoundPlayer Sound = new System.Media.SoundPlayer(gursimran_FireGame_Project.Properties.Resources.Winchester12_RA_The_Sun_God_1722751268);
     Sound.Play();
 }
Пример #59
0
 private void startingForm_Load(object sender, EventArgs e)
 {
     coin = new System.Media.SoundPlayer(Properties.Resources.insert_coin); //assigning to the coin object the real audio resource
 }
Пример #60
0
 private void button10_Click(object sender, EventArgs e)
 {
     System.IO.Stream         str = Properties.Resources.tones;
     System.Media.SoundPlayer snd = new System.Media.SoundPlayer(str);
     snd.Play();
 }