Ejemplo n.º 1
0
        private void LoadSecondMatrix(object sender, EventArgs e)
        {
            Stream         stream         = null;
            OpenFileDialog openFileDialog = new OpenFileDialog()
            {
                InitialDirectory = "c:\\",
                Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*",
                FilterIndex      = 2,
                RestoreDirectory = true
            };

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try{
                    if ((stream = openFileDialog.OpenFile()) != null)
                    {
                        using ( stream ){
                            var matrix = MatrixTxT.FromTxtToMatrix(stream);
                            matrixSecond = matrix;
                            FillViewMatrix(matrixViewSecond, matrix);
                        }
                    }
                } catch (IOException ex) {
                    MessageBox.Show("Error: File Exeption:" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                } catch (Exception ex) {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
        }