示例#1
0
        ///
        /// <summary>
        /// Opens project from file.
        /// </summary>
        private void openProject()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Title  = "Open Project";
            openFileDialog.Filter = ".ulp|*.ulp"; //Only displays .ulp files
            openFileDialog.ShowDialog();

            if (openFileDialog.FileName != "")
            {
                try
                {
                    _proInter.openProject(openFileDialog.FileName); //Deserializes object
                    enableProButtons();
                }
                catch (System.ApplicationException ex)  //Project name already in use
                {
                    MessageBox.Show("Project '" + ex.Message + "' already in use. Cannot load project.",
                                    "Project Name Already In Use", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                catch (System.NullReferenceException)    //File cannot be opened
                {
                    MessageBox.Show("The file is corrupt and cannot be opened", "Corrupt File", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            enableTargetButtons();
        }