예제 #1
0
        private void UiAction_OpenProjectDirect(string projectFile)
        {
            if (!File.Exists(projectFile))
            {
                if (MessageBox.Show("Project file does not exists:\n" + projectFile + "\n\nWould you like to remove it from recent list?", "Open project", MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Stop) == DialogResult.Yes)
                {
                    _recentProjects.RemoveFile(projectFile);
                    _recentProjects.Rebuild();
                }
                return;
            }

            try
            {
                ProjectDefinition openProject = ProjectDefinition.LoadFromFile(projectFile);

                // Load patterns first
                try
                {
                    Reload_ProjectDefinition(
                        Common.AppVarPathMakeAbsolute(openProject.CodeGenSettings.CodeGenPatternFile));
                }
                catch
                {
                    if (MessageBox.Show("Failed to open the pattern project from selected project!\nWould you like ignore this error and continue?", "Open project", MessageBoxButtons.YesNo, MessageBoxIcon.Stop)
                        == DialogResult.No)
                    {
                        return;
                    }
                    // continue to read others!
                }

                // assign new project
                _projectDefinition = openProject;

                // refresh form
                Refresh_Form();

                // save the file name
                _currentProject_Filename = projectFile;
                _currentProject_Opened   = true;

                // menu list!
                _recentProjects.NewFileOperation(projectFile);
                _recentProjects.Rebuild();

                // The project is fresh
                SetModified(false);
            }
            catch (Exception)
            {
                MessageBox.Show("Failed to open the selected project!", "Open project", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }