Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();
            var dataInput = new DataInputSet();

            lengthTextBox.Focus();
        }
Beispiel #2
0
        private void SubmitBtn_Click(object sender, RoutedEventArgs e)
        {
            BenthicGroup benthicGroup = new BenthicGroup();
            string       itemGroup    = benthicGroup.getItemGroup(categoryTextBox.Text);

            if (itemGroup == null)
            {
                MessageBox.Show("Wrong category name. Try again.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            else
            {
                var    dataInput      = new DataInputSet();
                double currentLength  = 0;
                double previousLength = 0;

                try
                {
                    currentLength = Convert.ToDouble(lengthTextBox.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Wrong intersect length. Try again.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    goto skip;
                }

                foreach (var data in InputData)
                {
                    previousLength += Convert.ToDouble(data.Length);
                }

                double deltaLength = currentLength - previousLength;
                if (deltaLength < 0)
                {
                    MessageBox.Show("Intersect length less than previous input. Try again.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    goto skip;
                }

                dataInput.Length       = deltaLength.ToString();
                dataInput.Depth        = depthTextBox.Text;
                dataInput.Category     = categoryTextBox.Text;
                dataInput.BenthicGroup = itemGroup;
                InputData.Add(dataInput);
                dataGrid.ItemsSource = InputData;
                dataGrid.Items.Refresh();

                lengthTextBox.Text   = "";
                depthTextBox.Text    = "";
                categoryTextBox.Text = "";
                lengthTextBox.Focus();
            }
            skip :;

            if (InputData.Count != 0)
            {
                createChartBtn.IsEnabled = true;
            }
        }
Beispiel #3
0
        private void OpenItem_Click(object sender, RoutedEventArgs e)
        {
            InputData.Clear();
            string         CSVFileName;
            OpenFileDialog openCSVFileDialog = new OpenFileDialog();

            openCSVFileDialog.Multiselect      = false;
            openCSVFileDialog.Filter           = "Text files (*.csv)|*.csv";
            openCSVFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            if (openCSVFileDialog.ShowDialog() == true)
            {
                CSVFileName = openCSVFileDialog.FileNames[0];
                using (var readCSVFile = new StreamReader(CSVFileName))
                {
                    while (!readCSVFile.EndOfStream)
                    {
                        var dataInput = new DataInputSet();

                        var columns = readCSVFile.ReadLine().Split(',');
                        dataInput.Length       = columns[0];
                        dataInput.Category     = columns[1];
                        dataInput.BenthicGroup = columns[2];
                        dataInput.Depth        = columns[3];
                        InputData.Add(dataInput);
                        dataGrid.ItemsSource = InputData;
                        dataGrid.Items.Refresh();
                    }
                }
            }

            if (InputData.Count != 0)
            {
                createChartBtn.IsEnabled = true;
            }

            if (InputData.Count == 0)
            {
                createChartBtn.IsEnabled = false;
            }
        }