示例#1
0
        private void OpenSelectedProject()
        {
            if (_selectedProject == null)             // If no project is selected
            {
                return;
            }

            string errorMessage;

            if (!ProjectChecker.IsValidProject(_selectedProject, out errorMessage))
            {
                DarkMessageBox.Show(this, "Failed to load project. " + errorMessage, "Error",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            if (!IsValidGameLauncher())
            {
                return;
            }

            // Set RememberedProject if checkBox_Remember is checked
            if (checkBox_Remember.Checked)
            {
                _ide.IDEConfiguration.RememberedProject = _selectedProject.Name;
            }

            // Save settings and hide the current window
            SaveSettings();
            Hide();

            // Show the main form of TombIDE
            using (FormMain form = new FormMain(_ide, _selectedProject))
            {
                DialogResult result = form.ShowDialog(this);

                if (result == DialogResult.OK)                 // OK means the user wants to switch projects
                {
                    // Reset the RememberedProject setting
                    _ide.IDEConfiguration.RememberedProject = string.Empty;
                    _ide.IDEConfiguration.Save();

                    // Restart the application (without any arguments)
                    Application.Exit();
                    Process.Start(Assembly.GetExecutingAssembly().Location);
                }
                else if (result == DialogResult.Cancel)                 // Cancel means the user closed the program
                {
                    Application.Exit();
                }
            }
        }
示例#2
0
        private void OpenTrproj()
        {
            using (OpenFileDialog dialog = new OpenFileDialog())
            {
                dialog.Title  = "Select the .trproj file you want to open";
                dialog.Filter = "TombIDE Project Files|*.trproj";

                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    try
                    {
                        Project openedProject = Project.FromFile(dialog.FileName);

                        string errorMessage;

                        if (!ProjectChecker.IsValidProject(openedProject, out errorMessage))
                        {
                            throw new ArgumentException(errorMessage);
                        }

                        // Check if a project with the same name but different paths already exists on the list
                        foreach (DarkTreeNode node in treeView.Nodes)
                        {
                            Project nodeProject = (Project)node.Tag;

                            if (nodeProject.Name.ToLower() == openedProject.Name.ToLower() &&
                                nodeProject.ProjectPath.ToLower() != openedProject.ProjectPath.ToLower())
                            {
                                if (AskForProjectNodeReplacement(openedProject, node))
                                {
                                    break;                                     // The user confirmed replacing the node
                                }
                                else
                                {
                                    return;                                     // The user declined replacing the node
                                }
                            }
                        }

                        if (!IsProjectOnList(openedProject))
                        {
                            AddProjectToList(openedProject, true);
                        }

                        SelectProjectOnList(openedProject.Name);
                    }
                    catch (Exception ex)
                    {
                        DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }
示例#3
0
        private void FillProjectList()
        {
            treeView.Nodes.Clear();

            // Add nodes into the treeView for each project
            foreach (Project project in _ide.AvailableProjects)
            {
                if (ProjectChecker.IsValidProject(project))
                {
                    AddProjectToList(project, false);
                }
            }

            // Update TombIDEProjects.xml with only valid projects
            RefreshAndReserializeProjects();
        }
示例#4
0
        public void OpenTrprojWithTombIDE(string trprojFilePath)
        {
            try
            {
                Project openedProject = Project.FromFile(trprojFilePath);

                string errorMessage;

                if (!ProjectChecker.IsValidProject(openedProject, out errorMessage))
                {
                    throw new ArgumentException(errorMessage);
                }

                // Check if a project with the same name but different paths already exists on the list
                foreach (DarkTreeNode node in treeView.Nodes)
                {
                    Project nodeProject = (Project)node.Tag;

                    if (nodeProject.Name.ToLower() == openedProject.Name.ToLower() &&
                        nodeProject.ProjectPath.ToLower() != openedProject.ProjectPath.ToLower())
                    {
                        if (AskForProjectNodeReplacement(openedProject, node))
                        {
                            break;                             // The user confirmed replacing the node
                        }
                        else
                        {
                            return;                             // The user declined replacing the node
                        }
                    }
                }

                if (!IsProjectOnList(openedProject))
                {
                    AddProjectToList(openedProject, true);
                }

                _ide.IDEConfiguration.RememberedProject = openedProject.Name;

                // Continue code in Program.cs
            }
            catch (Exception ex)
            {
                DarkMessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }