private void edtSourceDocument_KeyUp( object sender, KeyEventArgs e )
{
try
{
if (e.Alt && e.Control && e.KeyCode == Keys.P && _sourceFileInfo != null)
{
if (edtSourceDocument.Selection != null)
{
Line startLine = edtSourceDocument.Selection.Range.StartingLine;
Line endLine = edtSourceDocument.Selection.Range.EndingLine;
LogManager.Trace( "Extracting Procedure Starting on:{0}, Ending on:{1}", startLine.Number + 1,
endLine.Number );
string projectName = ProjectManager.ProjectName;
if (string.IsNullOrEmpty( projectName ))
throw new Exception( "You must open a project in order to map signals." );
string xmlPath = Path.Combine( ATMLContext.ProjectTranslatorAixmlPath,
projectName + ".aixml.xml" );
if (!File.Exists( xmlPath ))
throw new TranslationException( "Mapping Failed: Missing AIXML File." );
if (_aixmlDocument == null)
_aixmlDocument = XDocument.Load( new MemoryStream( FileManager.ReadFile( xmlPath ) ) );
for (int i = startLine.Number + 1; i <= endLine.Number; i++)
{
XElement node = _aixmlDocument.XPathSelectElement(string.Format("//*[@line_number='{0}' and @file='{1}']", i, _sourceFileInfo.Name));
ProcessAtlasSource( node );
}
}
}
}
catch (Exception err)
{
LogManager.Error( err );
}
}