Ejemplo n.º 1
0
        private void saveFile_Click(object sender, EventArgs e)
        {
            Stream         fs;
            SaveFileDialog savedFile = new SaveFileDialog();

            savedFile.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            savedFile.FilterIndex      = 2;
            savedFile.RestoreDirectory = true;

            if (savedFile.ShowDialog() == DialogResult.OK)
            {
                if ((fs = savedFile.OpenFile()) != null || (fs = File.Create(savedFile.FileName)) != null)
                {
                    // Code to write the stream goes here.
                    string data = patientData.to_string(DateTime.Now.Date.AddHours(RegistryEdit.check_daily_start()));
                    byte[] info = new UTF8Encoding(true).GetBytes(data);
                    try
                    {
                        fs.Write(info, 0, info.Length);
                        fs.Close();
                    }
                    catch (Exception _e)
                    {
                        MessageBox.Show("Write error when committing changes to patient info file.");
                    }
                }
                else
                {
                    MessageBox.Show("Could not open the file path for writing, check file path and try again.");
                }
            }
        }
Ejemplo n.º 2
0
        private void saveSettings_Click(object sender, EventArgs e)
        {
            if (dailyStartCombo.SelectedItem.ToString() != "")
            {
                RegistryEdit.set_daily_start(dailyStartCombo.SelectedIndex);
            }
            Properties.Settings.Default.Save();

            settingsPanel.Hide();
            SettingsButton.Text = "Edit Settings";
        }
Ejemplo n.º 3
0
        public patientPopUp()
        {
            InitializeComponent();

            // Disable maximize and window resize
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.MaximizeBox     = false;
            // Grab the daily start time and disable the continue button until we get our data
            dailyStartCombo.SelectedIndex = RegistryEdit.check_daily_start();
            this.loadMainButton.Enabled   = false;
        }
Ejemplo n.º 4
0
        private void comboBox4_SelectedIndexChanged(object sender, EventArgs e)
        {
            MessageBox.Show("Daily start time set to: " + dailyStartCombo.Text);
            dailyStart.Text = dailyStartCombo.Text;
            gapStart.Items.Clear();
            gapStart.Items.AddRange(generate_times(dailyStartCombo.SelectedIndex));
            gapStop.Items.Clear();
            gapStop.Items.AddRange(generate_times(dailyStartCombo.SelectedIndex));

            // Set value in registry
            RegistryEdit.set_daily_start(dailyStartCombo.SelectedIndex);
        }
Ejemplo n.º 5
0
        private void setTimeline()
        {
            int    start       = 0;
            int    stop        = 0;
            int    blockNumber = 0;
            double rate        = 0;
            int    time        = 0;
            string timestring  = "";

            for (int i = 0; i <= 23; i++)
            {
                time = RegistryEdit.check_daily_start() + i;
                if (time > 12)
                {
                    time -= 12;
                    if (time > 12)
                    {
                        time      -= 12;
                        timestring = time + ":00am";
                    }
                    else
                    {
                        timestring = time + ":00pm";
                    }
                }
                else
                {
                    timestring = time + ":00am";
                }
                rate = this.patientData.getTimeBlocks(start, stop, blockNumber, i);

                Timeline[i].BackColor = Color.LightGray;

                if (rate == 0)
                {
                    Timeline[i].Text      = timestring + "\nMissed";
                    Timeline[i].BackColor = Color.Pink;
                }
                else if (rate == -1)
                {
                    Timeline[i].Text = timestring;
                }
                else
                {
                    Timeline[i].Text = timestring + "\nRate: " + rate + "ml/hr";
                }
            }

            blockNumber++;
            stop++;
        }
Ejemplo n.º 6
0
        private void loadFile_Click(object sender, EventArgs e)
        {
            // Create a new file opening dialog that automatically searches for files with a .txt extension
            OpenFileDialog fileToSave = new OpenFileDialog();

            fileToSave.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            fileToSave.FilterIndex      = 1;
            fileToSave.RestoreDirectory = true;
            // Load all file content into here if possible
            var fileContent = string.Empty;

            // If they select OK on the dialog
            if (fileToSave.ShowDialog() == DialogResult.OK)
            {
                // Try to open the file
                var fs = fileToSave.OpenFile();
                // Try to read the whole file
                using (StreamReader reader = new StreamReader(fs))
                {
                    fileContent = reader.ReadToEnd();
                }

                // Set our reset time to today + time offset
                DateTime resetTime = DateTime.Now.Date.AddHours(RegistryEdit.check_daily_start
                                                                    ());
                PatientInfo patientDataTmp = new PatientInfo(fileContent, resetTime);
                if (patientDataTmp.validate())
                {
                    // If the file did not contain enough data or had invalid lines
                    MessageBox.Show("ERROR: Could not load patient information check file name and path.");
                    return;
                }
                else
                {
                    // Let a nurse know if old times were dropped (so they don't think the times just disappeared)
                    if (patientDataTmp.is_trimmed())
                    {
                        MessageBox.Show("Warning: Times over 24 hours were present and have been removed.");
                    }
                    // Save the data in our data class & sync
                    patientData = patientDataTmp;
                    sync_ui();
                }
            }
        }
Ejemplo n.º 7
0
        private void SettingsButton_Click(object sender, EventArgs e)
        {
            if (settingsPanel.Visible)
            {
                if (dailyStartCombo.SelectedItem.ToString() != "")
                {
                    RegistryEdit.set_daily_start(dailyStartCombo.SelectedIndex);
                }

                settingsPanel.Hide();
                SettingsButton.Text = "Edit Settings";
            }
            else
            {
                settingsPanel.Show();
                SettingsButton.Text = "Close [X]";
            }
        }
Ejemplo n.º 8
0
        public Form1()
        {
            InitializeComponent();
            rateOutput.Text   = "0";
            missedOutput.Text = "0";
            int new_start = RegistryEdit.check_daily_start();

            if (new_start > -1 && new_start < 24)
            {
                dailyStartCombo.SelectedIndex = new_start;
                this.gapStart.Items.Clear();
                this.gapStop.Items.Clear();
                this.gapStart.Items.AddRange(generate_times(dailyStartCombo.SelectedIndex));
                this.gapStop.Items.AddRange(generate_times(dailyStartCombo.SelectedIndex));
            }
            Timeline[0]  = Timeline1;
            Timeline[1]  = Timeline2;
            Timeline[2]  = Timeline3;
            Timeline[3]  = Timeline4;
            Timeline[4]  = Timeline5;
            Timeline[5]  = Timeline6;
            Timeline[6]  = Timeline7;
            Timeline[7]  = Timeline8;
            Timeline[8]  = Timeline9;
            Timeline[9]  = Timeline10;
            Timeline[10] = Timeline11;
            Timeline[11] = Timeline12;
            Timeline[12] = Timeline13;
            Timeline[13] = Timeline14;
            Timeline[14] = Timeline15;
            Timeline[15] = Timeline16;
            Timeline[16] = Timeline17;
            Timeline[17] = Timeline18;
            Timeline[18] = Timeline19;
            Timeline[19] = Timeline20;
            Timeline[20] = Timeline21;
            Timeline[21] = Timeline22;
            Timeline[22] = Timeline23;
            Timeline[23] = Timeline24;

            // Disable maximize and window resize
            this.FormBorderStyle = FormBorderStyle.FixedSingle;
            this.MaximizeBox     = false;

            int    time       = 0;
            string timestring = "";

            for (int i = 0; i <= 23; i++)
            {
                time = RegistryEdit.check_daily_start() + i;
                if (time > 12)
                {
                    time -= 12;
                    if (time > 12)
                    {
                        time      -= 12;
                        timestring = time + ":00am";
                    }
                    else
                    {
                        timestring = time + ":00pm";
                    }
                }
                else
                {
                    timestring = time + ":00am";
                }
                Timeline[i].Text = timestring;
            }
        }
Ejemplo n.º 9
0
 private void dailyStartCombo_SelectedIndexChanged(object sender, EventArgs e)
 {
     // set the registry value for our start time to the selected start time
     RegistryEdit.set_daily_start(dailyStartCombo.SelectedIndex);
 }