コード例 #1
0
ファイル: ProjectExplorer.cs プロジェクト: BroneKot/PawnPlus
        private void projectFiles_DoubleClick(object sender, EventArgs e)
        {
            if (File.Exists(this.projectFiles.SelectedNode.Name) == true)
            {
                CEManager.Open(this.projectFiles.SelectedNode.Name, true);
            }

            CEManager.SetActiveDocument(this.projectFiles.SelectedNode.Name, true);
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: BroneKot/PawnPlus
        private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.openFileDialog.Filter = "PAWN File|*.pwn|Include file|*.inc";

            DialogResult dialogResult = this.openFileDialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                CEManager.Open(this.openFileDialog.FileName);
            }
        }
コード例 #3
0
        /// <summary>
        /// Open a project.
        /// </summary>
        /// <param name="projectPath">Path to the project file.</param>
        /// <returns>Returns true if the project was opened with success, false otherwise.</returns>
        public static bool Open(string projectPath)
        {
            if (projectPath == null || System.IO.Path.GetExtension(projectPath) != Extension)
            {
                return(false);
            }

            xmlPath = projectPath;

            bool   isActive = false;
            string filePath = string.Empty, activeFile = string.Empty;

            using (XmlTextReader projectReader = new XmlTextReader(projectPath))
            {
                while (projectReader.Read())
                {
                    switch (projectReader.Name.ToString())
                    {
                    case "Name":
                    {
                        Name = projectReader.ReadString();
                        break;
                    }

                    case "File":
                    {
                        try
                        {
                            isActive = Convert.ToBoolean(Convert.ToInt32(projectReader.GetAttribute("Active")));         // Get the attribute first.
                            filePath = projectReader.ReadString();

                            if (isActive == true)
                            {
                                activeFile = filePath;
                            }

                            CEManager.Open(filePath, true);
                        }
                        catch (Exception)
                        {
                            // File dosen't exist.
                            // TODO: Write the exception to log file.
                        }

                        break;
                    }
                    }
                }
            }

            if (activeFile != string.Empty)
            {
                CEManager.SetActiveDocument(activeFile, true);
            }

            Path = System.IO.Path.GetDirectoryName(projectPath); // Set the project path.

            LoadDirectory(Path);

            IsOpen = true;

            return(true);
        }