Click here to Skip to main content
15,890,512 members
Home / Discussions / C#
   

C#

 
GeneralRe: in what classes do I handle/place these resources? Pin
OriginalGriff13-Sep-10 22:25
mveOriginalGriff13-Sep-10 22:25 
QuestionTimer events driving me insane! Pin
stephen.darling13-Sep-10 14:48
stephen.darling13-Sep-10 14:48 
AnswerRe: Timer events driving me insane! Pin
Luc Pattyn13-Sep-10 15:23
sitebuilderLuc Pattyn13-Sep-10 15:23 
GeneralRe: Timer events driving me insane! Pin
stephen.darling13-Sep-10 15:29
stephen.darling13-Sep-10 15:29 
AnswerRe: Timer events driving me insane! Pin
PIEBALDconsult13-Sep-10 16:45
mvePIEBALDconsult13-Sep-10 16:45 
QuestionHow do I repeat this sound file as required? Pin
stephen.darling13-Sep-10 10:12
stephen.darling13-Sep-10 10:12 
AnswerRe: How do I repeat this sound file as required? Pin
AspDotNetDev13-Sep-10 11:03
protectorAspDotNetDev13-Sep-10 11:03 
GeneralRe: How do I repeat this sound file as required? Pin
stephen.darling13-Sep-10 11:11
stephen.darling13-Sep-10 11:11 
Hello and thank you.

Here is my code, but it is rough as i have not yet created the classes etc, it is all happening within the form function

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;

namespace SimMed
{
    public partial class simmedForm : Form
    {

        // to play sounds, import windows multimedia library
        [DllImport("winmm.dll")]
        private static extern bool PlaySound(string lpszName, int hModule, int dwFlags);


        #region Variables

        private int nTime;		// how long has the sim ran for?
        private int patientHeartRate;
        private int patientBloodPressure;
        private int patientTemp;
        private int patientBreathRate;
        private int patientConciousLevel;

        

        #endregion



        public simmedForm()
        {

           

            InitializeComponent();


            //temp values, need to move these into proper classes etc

            HeartBpmLed.Text = ("72");

            patientHeartRate = 72;

            startNewSimulation(false);

            

        }


        private void startNewSimulation(bool restart)
        {

            if (timer1.Enabled) timer1.Stop();

            if (!timer1.Enabled) InitTimer(); // run timer if it is not running

            // reset all global variales
        }


        private void InitTimer()
        {
            timer1.Interval = 1000; // in milliseconds

            timer1.Enabled = true;	// run timer

        }


        private void PlayWav(int play)
        {

            string myFile = ".\\Sounds\\default.wav";
                switch (play)
                {
                    case 1:
                        myFile = ".\\Sounds\\ecg.wav";
                        break;
                    case 2:
                        myFile = ".\\Sounds\\ecg.wav";
                        break;
                    case 3:
                        myFile = ".\\Sounds\\ecg.wav";
                        break;
                    case 4:
                        myFile = ".\\Sounds\\ECG Alarm.wav";
                        break;
                    case 5:
                        myFile = ".\\Sounds\\Flatline.wav";
                        break;
                    case 6:
                        myFile = ".\\Sounds\\Medicalventilator.wav";
                        break;
                    case 7:
                        myFile = ".\\Sounds\\PulseOximeter.wav";
                        break;
                    case 8:
                        myFile = ".\\Sounds\\Heartbeat.wav";
                        break;
                    case 9:
                        myFile = ".\\Sounds\\Won.wav";
                        break;
                    case 10:
                        myFile = ".\\Sounds\\illegal.wav";
                        break;
                    default:
                        break;
                }

                PlaySound(myFile, 0, 0x0003);	// asynchonious play, start to play a new sound event if previous
                // finished playing
            }



        private void simmedForm_Load(object sender, EventArgs e)
        {

        }


        
        private void timer1_Tick(object sender, EventArgs e)
        {
            Random r1 = new Random(unchecked((int)DateTime.Now.Ticks));
            nTime++;

            patientHeartRate = 72 + r1.Next(0, 5);

            HeartBpmLed.Text = patientHeartRate.ToString();
           PlayWav(1);

           
            

        }

        
    }
}


Thank you
GeneralRe: How do I repeat this sound file as required? Pin
AspDotNetDev13-Sep-10 11:42
protectorAspDotNetDev13-Sep-10 11:42 
GeneralRe: How do I repeat this sound file as required? Pin
stephen.darling13-Sep-10 12:29
stephen.darling13-Sep-10 12:29 
QuestionMessage Removed Pin
13-Sep-10 8:36
hove8213-Sep-10 8:36 
GeneralRe: ObjectPolicy Pin
OriginalGriff13-Sep-10 9:06
mveOriginalGriff13-Sep-10 9:06 
GeneralRe: ObjectPolicy Pin
Pete O'Hanlon13-Sep-10 9:07
mvePete O'Hanlon13-Sep-10 9:07 
AnswerRe: ObjectPolicy Pin
Eddy Vluggen13-Sep-10 10:43
professionalEddy Vluggen13-Sep-10 10:43 
GeneralRe: ObjectPolicy Pin
hove8213-Sep-10 10:56
hove8213-Sep-10 10:56 
GeneralRe: ObjectPolicy Pin
Eddy Vluggen13-Sep-10 11:36
professionalEddy Vluggen13-Sep-10 11:36 
GeneralRe: ObjectPolicy Pin
PIEBALDconsult13-Sep-10 14:43
mvePIEBALDconsult13-Sep-10 14:43 
GeneralRe: ObjectPolicy [modified] Pin
hove8213-Sep-10 19:54
hove8213-Sep-10 19:54 
GeneralRe: ObjectPolicy Pin
Eddy Vluggen14-Sep-10 7:52
professionalEddy Vluggen14-Sep-10 7:52 
GeneralRe: ObjectPolicy Pin
hove8214-Sep-10 8:09
hove8214-Sep-10 8:09 
GeneralRe: ObjectPolicy Pin
Eddy Vluggen14-Sep-10 8:58
professionalEddy Vluggen14-Sep-10 8:58 
GeneralRe: ObjectPolicy Pin
hove8214-Sep-10 9:13
hove8214-Sep-10 9:13 
AnswerRe: ObjectPolicy Pin
Pete O'Hanlon13-Sep-10 10:45
mvePete O'Hanlon13-Sep-10 10:45 
GeneralRe: ObjectPolicy Pin
hove8213-Sep-10 10:59
hove8213-Sep-10 10:59 
QuestionGet only modified data at form exit Pin
manchukuo13-Sep-10 8:30
manchukuo13-Sep-10 8:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.