Example #1
0
        public bool Prepare()
        {
            if (_imgDirectory == string.Empty || _chosenTest == string.Empty || _imgExtension == string.Empty)
            {
                MessageBox.Show(Resources.EmptyFieldError, Resources.ErrorTitle, MessageBoxButtons.OK);
                return(false);
            }

            var directoryName = "DemoSatFiles";
            var attempt       = 0;
            var pathEnding    = @"\";
            var prePath       = directoryName + attempt;

            while (Directory.Exists(prePath))
            {
                attempt++;
                prePath = directoryName + attempt;
            }

            Directory.CreateDirectory(prePath);
            _scriptDir = prePath + pathEnding;

            if (ScriptDaemon.FixScript(Resources.DemoSatStep1, "DemosatStep1.py", FixDemosatAnalysisScript))
            {
                return(true);
            }

            MessageBox.Show(Resources.DemoSatStep1FixError, Resources.ErrorTitle, MessageBoxButtons.OK);
            return(false);
        }
Example #2
0
        private bool Ready(bool verbose)
        {
            if (xAxisLabelTXT.Text == string.Empty ||
                yAxisLabelTXT.Text == string.Empty || graphTitleTXT.Text == string.Empty ||
                graphLengthTXT.Text == string.Empty ||
                graphHeightTXT.Text == string.Empty || labelSizeTXT.Text == string.Empty)
            {
                if (verbose)
                {
                    MessageBox.Show(Resources.EmptyFieldsError, Resources.AlertTitle, MessageBoxButtons.OK);
                }
                return(false);
            }

            double result;

            if (!double.TryParse(graphHeightTXT.Text, out result) ||
                !double.TryParse(labelSizeTXT.Text, out result))
            {
                if (verbose)
                {
                    MessageBox.Show(Resources.InvalidNumber, Resources.AlertTitle, MessageBoxButtons.OK);
                }
                return(false);
            }
            if (AllPlots.Count == 0)
            {
                MessageBox.Show("You must include at least one plot... Click on the '+' to add a plot.",
                                Resources.AlertTitle, MessageBoxButtons.OK);
                return(false);
            }
            if (!ScriptDaemon.FixScript(Resources.RScriptTemplate, _settingsDirectory + @"\RScript.r", FixRScript))
            {
                MessageBox.Show(Resources.ScriptGenerationError, Resources.AlertTitle, MessageBoxButtons.OK);
                return(false);
            }

            //SaveSettings();

            return(true);
        }
Example #3
0
        private bool ReadyToCreateGraph(bool verbose)
        {
            if (fileNameTXT.Text == string.Empty || timeStartTXT.Text == string.Empty ||
                timeStopTXT.Text == string.Empty ||
                xAxisTicksTXT.Text == string.Empty || yMinTXT.Text == string.Empty || yMaxTXT.Text == string.Empty ||
                fileTypeCMB.Text == string.Empty || xAxisLabelTXT.Text == string.Empty ||
                yAxisLabelTXT.Text == string.Empty ||
                graphTitleTXT.Text == string.Empty || graphTypeCMB.Text == string.Empty ||
                graphWidthTXT.Text == string.Empty ||
                graphHeightTXT.Text == string.Empty || plotColorTXT.Text == string.Empty ||
                plotColorTXT.Text == string.Empty ||
                labelSizeTXT.Text == string.Empty || outputDirectoryTXT.Text == string.Empty)
            {
                if (verbose)
                {
                    MessageBox.Show(Resources.EmptyFieldsError, Resources.AlertTitle, MessageBoxButtons.OK);
                }
                return(false);
            }

            if (!Directory.Exists(outputDirectoryTXT.Text))
            {
                if (verbose)
                {
                    var response = MessageBox.Show(Resources.DirectoryDoesntExist, Resources.AlertTitle,
                                                   MessageBoxButtons.YesNo);
                    switch (response)
                    {
                    case DialogResult.No:
                        return(false);

                    case DialogResult.Yes:
                        Directory.CreateDirectory(outputDirectoryTXT.Text);
                        if (outputDirectoryTXT.Text.GetLast(1) != @"\")
                        {
                            outputDirectoryTXT.Text = outputDirectoryTXT.Text + @"\";
                        }
                        break;
                    }
                }
                else
                {
                    Directory.CreateDirectory(outputDirectoryTXT.Text);
                }
            }

            if (outputDirectoryTXT.Text.GetLast(1) != @"\")
            {
                outputDirectoryTXT.Text += @"\";
            }

            double result;

            if (!double.TryParse(yMinTXT.Text, out result) ||
                !double.TryParse(yMaxTXT.Text, out result) ||
                !double.TryParse(graphWidthTXT.Text, out result) ||
                !double.TryParse(graphHeightTXT.Text, out result) ||
                !double.TryParse(labelSizeTXT.Text, out result) ||
                !double.TryParse(xAxisTicksTXT.Text, out result))
            {
                if (verbose)
                {
                    MessageBox.Show(Resources.InvalidNumber, Resources.AlertTitle, MessageBoxButtons.OK);
                }
                return(false);
            }
            if (double.Parse(timeStartTXT.Text) > double.Parse(timeStopTXT.Text))
            {
                if (verbose)
                {
                    MessageBox.Show(Resources.NumericalBoundsError, Resources.AlertTitle, MessageBoxButtons.OK);
                }
                return(false);
            }
            if (double.Parse(yMinTXT.Text) > double.Parse(yMaxTXT.Text))
            {
                if (verbose)
                {
                    MessageBox.Show(Resources.NumericalBoundsError, Resources.AlertTitle, MessageBoxButtons.OK);
                }
                return(false);
            }
            if (double.Parse(timeStartTXT.Text) < 0)
            {
                if (verbose)
                {
                    MessageBox.Show(Resources.InvalidStartTime, Resources.AlertTitle, MessageBoxButtons.OK);
                }
                timeStartTXT.Text = @"0";
                return(false);
            }
            if (Path.GetFileName(fileNameTXT.Text).GetLast(4) != ".csv")
            {
                if (verbose)
                {
                    MessageBox.Show(Resources.InvalidFileExtension, Resources.AlertTitle, MessageBoxButtons.OK);
                }
                return(false);
            }
            if (!fileTypeCMB.Items.Contains(fileTypeCMB.Text))
            {
                if (verbose)
                {
                    MessageBox.Show(Resources.InvalidOutputType, Resources.AlertTitle, MessageBoxButtons.OK);
                }
                return(false);
            }
            if (!graphTypeCMB.Items.Contains(graphTypeCMB.Text))
            {
                if (verbose)
                {
                    MessageBox.Show(Resources.InvalidGraphType, Resources.AlertTitle, MessageBoxButtons.OK);
                }
                return(false);
            }

            if (!ScriptDaemon.FixScript(Resources.RScriptTemplate, "RScript.r", FixRScript))
            {
                MessageBox.Show(Resources.ScriptGenerationError, Resources.AlertTitle, MessageBoxButtons.OK);
                return(false);
            }

            SaveSettings();

            return(true);
        }