Beispiel #1
0
        /// <summary>
        /// Initializes the NormalSwitcherForm and opens the file given by <paramref name="file"/>
        /// </summary>
        /// <param name="file">Path of the file to be displayed</param>
        internal NormalSwitcherForm(string file)
        {
            InitializeComponent();

            BindEvents();

            StreamReader reader = new StreamReader(file);

            try {
                parser.Parse(reader);
                triangleList = parser.TriangleList;
                backupList   = triangleList.Copy();
                SetOrigin();
                originTrackBar.Visible = true;
                InitVisualization();

                currentFile       = file;
                allButton.Enabled = true;

                InitializePages();
            } catch (Exception exception) {
                MessageBox.Show(exception.Message, "Error");
            } finally {
                reader.Close();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sets all triangles back to the values from the STL-file.
        /// </summary>
        /// <param name="sender">resetToolStripMenuItem or resetButton</param>
        /// <param name="e">Standard EventArgs</param>
        private void Reset(object sender, EventArgs e)
        {
            triangleList = null;
            triangleList = backupList.Copy();
            currentSelection.Clear();
            history.Clear();

            undoButton.Enabled = false;
            changed            = false;
            visualization.SetColorArray();
            visualization.SetPickingColors();
            SetOrigin();
            SetPanelsChanged();
            (tabControl1.SelectedTab as Page).UpdateTab();
        }
Beispiel #3
0
        /// <summary>
        /// Closes a previously opened file and opens a new one.
        /// Parses the file and initializes the arrays and GUI-elements.
        /// </summary>
        /// <param name="sender">openToolStripMenuItem</param>
        /// <param name="e">Standard EventArgs</param>
        private void OpenFile(object sender, EventArgs e)
        {
            try {
                CloseFile(sender, e);

                OpenFileDialog ofd = new OpenFileDialog();
                ofd.CheckFileExists = true;
                ofd.DefaultExt      = "stl";
                ofd.Filter          = "STL Files (*.stl)|*.stl";
                ofd.Multiselect     = false;
                ofd.Title           = "Open STL-file";
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    StreamReader reader = new StreamReader(ofd.FileName);
                    try {
                        parser.Parse(reader);

                        triangleList = parser.TriangleList;
                        backupList   = triangleList.Copy();
                        SetOrigin();
                        originTrackBar.Visible = true;
                        InitVisualization();

                        currentFile       = ofd.FileName;
                        allButton.Enabled = true;

                        InitializePages();
                    } catch (Exception exception) {
                        MessageBox.Show(exception.Message, "Error");
                    } finally {
                        reader.Close();
                    }
                }
                ofd.Dispose();
            } catch { }
        }