// Open file
        private void Open_OnClick(object sender, RoutedEventArgs e)
        {
            // Set the button as an open file dialog when clicked
            OpenFileDialog openDlg = new OpenFileDialog
            {
                // Set the title of the pop-up window
                Title = "Browse STL Data",
                // Set the filter so the user can only open STL files
                Filter = "STL File (*.stl) | *.stl;*.txt",
                // Set the initial directory of open file to My Documents
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
            };

            try
            {
                // Requirements to open the file
                if (openDlg.ShowDialog() == true)
                {
                    // Connect to STL Import
                    importSTL.DataReader read = new importSTL.DataReader(openDlg.FileName);
                    STLFile = read.ReadFile();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured: " + ex, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Пример #2
0
        private void stlSelectBt_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog
            {
                Title           = "Browse STL Data",
                CheckFileExists = true,
                CheckPathExists = true,
                Filter          = "STL Files|*.stl;*.txt;"
            };

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                importSTL.DataReader read = new importSTL.DataReader(openFile.FileName);
                dm = read.ReadFile();
                Console.ReadLine();
            }
        }
Пример #3
0
        private void stlSelectBt_Click(object sender, EventArgs e)
        {
            Stopwatch timePassed = new Stopwatch();

            timePassed.Start();
            OpenFileDialog openFile = new OpenFileDialog
            {
                Title           = "Browse STL Data",
                CheckFileExists = true,
                CheckPathExists = true,
                Filter          = "STL Files|*.stl;*.txt;"
            };

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                importSTL.DataReader read = new importSTL.DataReader(openFile.FileName);
                dm = read.ReadFile();

                timePassed.Stop();
                textBox2.Text = Convert.ToString("import finished - Time Passed: " + timePassed.Elapsed);
            }
        }