/// <summary> /// This event handler provides a dialog to open a regex project file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void projectToolStripMenuItem_Click(object sender, EventArgs e) { try { openFileDialog1.InitialDirectory = Environment.CurrentDirectory + "\\" + projDir; DialogResult result = openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { FileInfo fi = new FileInfo(openFileDialog1.FileName); if (fi.Extension == ".rp") { //call open here RegexProject rp = RegexSerializer.LoadRegexProject(fi.FullName); this.Text += " *" + rp.RegexProjName; this.crs = rp.ProjScanner; this.workingScanDir = rp.ProjWorkingDirectory; } else { throw new Exception("error opening RegexProject fiel: wrong file type"); } } } catch (Exception ex) { MessageBox.Show(" error opening file " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); crl.WriteLog(CRLogger.CRLogTitle.Error, "Error while opening file " + ex.Message); } }
/// <summary> /// this event handler opens the project save as dialog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveProjectAsToolStripMenuItem_Click(object sender, EventArgs e) { try { RegexProject rp = new RegexProject(); rp.RegexProjName = Microsoft.VisualBasic.Interaction.InputBox( "Project Name", "Regex Project", "Project_Name"); rp.ProjWorkingDirectory = this.workingScanDir; rp.ProjScanner = this.crs; RegexSerializer.Save(projDir + "\\" + rp.RegexProjName + ".rp", rp); if (this.Text.Contains(" *")) { //first remove string[] sa = this.Text.Split('*'); this.Text = sa[0] + "*" + rp.RegexProjName; } else { this.Text += @" *" + rp.RegexProjName; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// This event handler saves the CRProject /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveProjectToolStripMenuItem_Click(object sender, EventArgs e) { if (this.Text.Contains(" *")) { //just save try { RegexProject rp = new RegexProject(); //rp.RegexProjName = Microsoft.VisualBasic.Interaction.InputBox( // "Project Name", "Regex Project", "Project_Name"); //get and set project name string[] sa = this.Text.Split('*'); rp.RegexProjName = sa[1]; rp.ProjWorkingDirectory = this.workingScanDir; rp.ProjScanner = this.crs; RegexSerializer.Save(projDir + "\\" + rp.RegexProjName + ".rp", rp); MessageBox.Show(rp.RegexProjName + " saved", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //call save new project //saveProjectAsToolStripMenuItem_Click(this, null); regexProjectToolStripMenuItem_Click(this, null); } }
private void regexProjectToolStripMenuItem_Click(object sender, EventArgs e) { if (this.Text.Contains(" *")) { //call save as } else { try { RegexProject rp = new RegexProject(); rp.RegexProjName = Microsoft.VisualBasic.Interaction.InputBox( "Project Name", "Regex Project", "Project_Name"); rp.ProjWorkingDirectory = this.workingScanDir; rp.ProjScanner = this.crs; RegexSerializer.Save(projDir + "\\" + rp.RegexProjName + ".rp", rp); MessageBox.Show(rp.RegexProjName + " saved", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Text += @" *" + rp.RegexProjName; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public virtual void ProjectChanged(Regulator.SDK.RegexProject newProject) { _currentProject = newProject; _currentProject.ActionStarted += new Regulator.SDK.RegexProject.RegexActionStartDelegate(OnProjectActionStarted); _currentProject.MatchEnded += new Regulator.SDK.RegexProject.RegexMatchEndedDelegate(OnProjectMatchEnded); _currentProject.ReplaceEnded += new Regulator.SDK.RegexProject.RegexReplaceEndedDelegate(OnProjectReplaceEnded); _currentProject.SplitEnded += new Regulator.SDK.RegexProject.RegexSplitEndedDelegate(OnProjectSplitEnded); _currentProject.Updated += new EventHandler(OnProjectUpdated); }
public RegexEditorForm(RegexProject rp) { InitializeComponent(); initFrom();//common form setup method //setup new scanner crs = new CRScanner(); foreach (var p in rp.ProjScanner.Patterns)//add patterns { crs.Patterns.Add(p); } foreach (var fex in rp.ProjScanner.FileExtensions)//add file extensions { crs.FileExtensions.Add(fex); } //fileSavePath = FileSavepath;//set up the save path //crl = Crl; //richTextBox1.Text = text; workingScanDir = rp.ProjWorkingDirectory;//setup the working dir this.Text += " *" + rp.RegexProjName; }
public static VSSolution Load(string fileName) { //Log.DebugFormat("Load ('{0}')", fileName); VSSolution solution = new VSSolution(fileName); using (Stream stream = File.Open(fileName, FileMode.Open, FileAccess.Read)) { using (StreamReader reader = new StreamReader(stream)) { VSSolutionFileParser parser = new VSSolutionFileParser(reader); string line = parser.NextLine(); Match solutionMatch = RegexSolutionVersion.Match(line); if (solutionMatch.Success == false) { parser.ThrowParserException("Not a solution file."); } solution.solutionVersion = decimal.Parse( solutionMatch.Groups["version"].Value, CultureInfo.InvariantCulture); while (true) { try { line = parser.NextLine(); if (line == null) { break; } //salimos del loop cuando 'Global' aparece Match globalMatch = RegexGlobal.Match(line); if (globalMatch.Success) { break; } Match projectMatch = RegexProject.Match(line); if (projectMatch.Success == false) { parser.ThrowParserException( String.Format( CultureInfo.InvariantCulture, "Could not parse solution file (line {0}).", parser.LineCount)); } Guid projectGuid = new Guid(projectMatch.Groups["projectGuid"].Value); string projectName = projectMatch.Groups["name"].Value; string projectFileName = projectMatch.Groups["path"].Value; Guid projectTypeGuid = new Guid(projectMatch.Groups["projectTypeGuid"].Value); if (projectFileName.ToLower().Contains("http://")) { string path = System.IO.Path.GetDirectoryName(fileName); Uri r = new Uri(projectFileName); string f = ""; f = r.Segments[r.Segments.Length - 1]; path = System.IO.Directory.GetParent(path).FullName; string[] files = System.IO.Directory.GetFiles(path, f, SearchOption.AllDirectories); if (files != null && files.Length > 0) { projectFileName = files[files.Length - 1]; } } try { VSProjectInfo project; if (projectTypeGuid == VSProjectType.SolutionFolderProjectType.ProjectTypeGuid) { project = new VSSolutionFilesInfo( solution, projectGuid, projectName, projectTypeGuid); } else { project = new VSProjectWithFileInfo( solution, projectGuid, projectName, projectFileName, projectTypeGuid); } project.Parse(parser); solution.projects.Add(project); } catch (Exception ex) { //Asumimos el error. Si falla posiblemente se trate de un proyecto de setup o no regular } } catch (Exception ex) { //Asumimos el error. Si falla posiblemente se trate de un proyecto de setup o no regular } } } } return(solution); }
protected virtual void OnProjectSplitEnded(RegexProject sender, string[] results) { }
protected virtual void OnProjectReplaceEnded(RegexProject sender, string replaceResult) { }
protected virtual void OnProjectMatchEnded(RegexProject sender, System.Text.RegularExpressions.MatchCollection matches) { }
protected virtual void OnProjectActionStarted(RegexProject sender, RegexActionTypes action) { }
public override void ProjectChanged(RegexProject newProject) { base.ProjectChanged(newProject); }
/// <summary> /// Loads the specified VisualStudio solution file and returns a <see cref="VSSolution"/> representing the solution. /// </summary> /// <param name="fileName">The name of the solution file.</param> /// <returns>A <see cref="VSSolution"/> representing the solution.</returns> public static VSSolution Load(string fileName) { Log.DebugFormat("Load ('{0}')", fileName); VSSolution solution = new VSSolution(fileName); using (Stream stream = File.Open(fileName, FileMode.Open, FileAccess.Read)) { using (StreamReader reader = new StreamReader(stream)) { VSSolutionFileParser parser = new VSSolutionFileParser(reader); string line = parser.NextLine(); Match solutionMatch = RegexSolutionVersion.Match(line); if (solutionMatch.Success == false) { parser.ThrowParserException("Not a solution file."); } solution.solutionVersion = decimal.Parse( solutionMatch.Groups["version"].Value, CultureInfo.InvariantCulture); while (true) { line = parser.NextLine(); if (line == null) { break; } // exit the loop when 'Global' section appears Match globalMatch = RegexGlobal.Match(line); if (globalMatch.Success) { break; } Match projectMatch = RegexProject.Match(line); if (projectMatch.Success == false) { parser.ThrowParserException( String.Format( CultureInfo.InvariantCulture, "Could not parse solution file (line {0}).", parser.LineCount)); } Guid projectGuid = new Guid(projectMatch.Groups["projectGuid"].Value); string projectName = projectMatch.Groups["name"].Value; string projectFileName = projectMatch.Groups["path"].Value; Guid projectTypeGuid = new Guid(projectMatch.Groups["projectTypeGuid"].Value); VSProjectInfo project; if (projectTypeGuid == VSProjectType.SolutionFolderProjectType.ProjectTypeGuid) { project = new VSSolutionFilesInfo( solution, projectGuid, projectName, projectTypeGuid); } else { project = new VSProjectWithFileInfo( solution, projectGuid, projectName, projectFileName, projectTypeGuid); } solution.projects.Add(project); project.Parse(parser); } } } return(solution); }
public void ProjectChanged(RegexProject newProject) { // TODO: Add PluginLister.ProjectChanged implementation }