/** * @brief New Project button event, loads the Recent project path from the settings * and shown folder browser. * @param sender * @param e */ private void buttonNewProject_Click(object sender, EventArgs e) { // Load Recent opened folder and set it to the folder browser initial path. browserNewProject.SelectedPath = settings.LoadSetting("General.RecentProject"); // Show browser. if (browserNewProject.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // Get supported file extensions. string supportedFileExtensionsString = (settings.LoadSetting("User.FileExtensions") != "") ? settings.LoadSetting("User.FileExtensions") : Properties.Resources.supportedFileExtensions; string[] supportedFileExtensions = supportedFileExtensionsString.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); // Use ProjectScanner to scan all files. if (!ProjectScanner.Scan(browserNewProject.SelectedPath, supportedFileExtensions, ref bbCodeBase)) { MessageBox.Show("No BBCode Descriptor has been found under the selected path."); } // Remember the project name including the number of recognized BBCode entries. projectName = Path.GetFileName(browserNewProject.SelectedPath) + " #" + bbCodeBase.GetCodeCount(); // Set visuals for ProjectOpen state. SetVisuals(GetVisuals() | VisualStates.ProjectOpen); // Save teh successfuly opened project path. settings.SaveSetting("General.RecentProject", browserNewProject.SelectedPath); } }
/** * @brief Opens a single-file project from the selected location and scans all BBCode descriptors to fill the BBCodeBase. * @param sender * @param e */ private void buttonNewSingleFileProject_Click(object sender, EventArgs e) { // Load Recent opened folder and set it to the folder browser initial path. browserOpenSingleFile.FileName = settings.LoadSetting("General.RecentSingleFile"); // Show browser. if (browserOpenSingleFile.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // Use ProjectScanner to scan the selected file. if (!ProjectScanner.Scan(browserOpenSingleFile.FileName, new string[] { }, ref bbCodeBase)) { MessageBox.Show("No BBCode Descriptor has been found under the selected path."); } // Remember the project name including the number of recognized BBCode entries. projectName = Path.GetFileName(browserOpenSingleFile.FileName) + " #" + bbCodeBase.GetCodeCount(); // Set visuals for ProjectOpen state. SetVisuals(GetVisuals() | VisualStates.ProjectOpen); // Save teh successfuly opened project path. settings.SaveSetting("General.RecentSingleFile", browserOpenSingleFile.FileName); } }