コード例 #1
0
        // calculate and display the results in the RichTextBox
        private void CalculateButton_Click(object sender, EventArgs e)
        {
            // check the values in the ViewModel to see if they are correct before we calculate

            if ((vm.LCT50Dosage > vm.ICT50Dosage) && (vm.ICT50Dosage > vm.ThresholdDosage) && (vm.ThresholdDosage > 0) && (vm.UKts > 0) && (vm.Qkg > 0))
            {
                // we don't have to check the other values because we wouldn't have gotten here unless they are > 0
                totalPattern            = new TotalDosagePattern();
                totalPattern.AgentName  = vm.AgentName;
                totalPattern.WeaponName = vm.WeaponName;
                totalPattern.Qkg        = vm.Qkg;
                totalPattern.UKts       = vm.UKts;
                totalPattern.Psc        = vm.Psc;
                totalPattern.Tst        = vm.Tst;

                // calculate the dosage patterns & stats
                totalPattern.Patterns.Add(totalPattern.CalculateDosagePattern(vm.ThresholdDosage));
                totalPattern.Patterns.Add(totalPattern.CalculateDosagePattern(vm.ICT50Dosage));
                totalPattern.Patterns.Add(totalPattern.CalculateDosagePattern(vm.LCT50Dosage));

                vm.CalculatedPattern = totalPattern;

                ResultsRichText.Clear();

                // output the results to the ResultsRichText box
                ResultsRichText.AppendText(string.Format("Total Dosage Patterns for {0}{1}", totalPattern.WeaponName, Environment.NewLine));
                ResultsRichText.AppendText(string.Format("Filled with {0} kilograms of {1}, explosive release{2}", totalPattern.Qkg, totalPattern.AgentName, Environment.NewLine));
                ResultsRichText.AppendText(string.Format("Atmospheric stability of {0}{1}", totalPattern.Psc.ToString(), Environment.NewLine));
                ResultsRichText.AppendText(string.Format("Target Surface Type is {0}{1}", totalPattern.Tst.ToString(), Environment.NewLine));
                ResultsRichText.AppendText(string.Format("Windspeed is {0:0.0} knots", totalPattern.UKts));
                ResultsRichText.AppendText(Environment.NewLine);
                ResultsRichText.AppendText(Environment.NewLine);

                foreach (DosageField df in totalPattern.Patterns)
                {
                    ResultsRichText.AppendText(string.Format("For Dosage {0} mg.min/m^3{1}", df.Threshold, Environment.NewLine));
                    ResultsRichText.AppendText(string.Format("Maximum Downwind Distance is {0:0.00} meters{1}", df.MaxDownwindDistance, Environment.NewLine));
                    ResultsRichText.AppendText(string.Format("Maximum Crosswind Distance is {0:0.00} meters{1}", df.MaxCrosswindDistance, Environment.NewLine));
                    ResultsRichText.AppendText(string.Format("Area Coverage is {0:0.00} square meters{1}", df.AreaCovergeSquareMeters, Environment.NewLine));
                    ResultsRichText.AppendText(Environment.NewLine);
                }
            }
            else
            {
                ResultsRichText.Clear();

                ResultsRichText.AppendText("LCT50 must be greater than ICT50. ICT50 must be greater than Threshold.");
                ResultsRichText.AppendText(Environment.NewLine);
                ResultsRichText.AppendText("Threshold, Windspeed, and Fill Weight must all be greater than zero.");
                ResultsRichText.AppendText(Environment.NewLine);
                ResultsRichText.AppendText("Please adjust your input parameters and try again.");
            }
        }
コード例 #2
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            // check for valid search term
            if (TermTextBox.TextLength == 0)
            {
                MessageBox.Show("Please enter a valid search term.", "", MessageBoxButtons.OK);
                return;
            }

            // Check for valid directory
            bool directoryExists = Directory.Exists(PathTextBox.Text);

            if (!directoryExists)
            {
                MessageBox.Show("Please select a valid directory.", "", MessageBoxButtons.OK);
                return;
            }

            // Perform search
            string searchTerm = TermTextBox.Text;

            ResultsRichText.Clear();
            if (ContainsRadioButton.Checked)
            {
                searchTerm = $"*{searchTerm}*";
            }
            else if (EndsWithRadioButton.Checked)
            {
                searchTerm = $"*{searchTerm}";
            }
            else
            {
                searchTerm = $"{searchTerm}*";
            }
            string        directory = PathTextBox.Text;
            List <string> validDirs = GetSearchableDirs(directory);
            List <string> results   = GetAllFiles(validDirs, searchTerm);

            foreach (string r in results)
            {
                ResultsRichText.AppendText(r + "\n");
            }

            ResultsRichText.AppendText($"\nTOTAL RESULTS: {results.Count}");
            ResultsRichText.ScrollToCaret();
        }