Posted 17 years ago
by Matt Adamson
Guys
I use this drop down to show multiple Document instances which are switched back and forth by caching them for C# / other code files. The drop down is initialised to the editor through the designer and then at runtime the syntax editor control changes the Document property as required.
The issue appears to be when the cached Document using the C# add on is loaded and set to the Document property of the syntax editor, the drop downs don't get refreshed with the members for that file.
Other files simply use the LoadLanguageFromXml calls if the file isn't of cs or vb type
I use this drop down to show multiple Document instances which are switched back and forth by caching them for C# / other code files. The drop down is initialised to the editor through the designer and then at runtime the syntax editor control changes the Document property as required.
The issue appears to be when the cached Document using the C# add on is loaded and set to the Document property of the syntax editor, the drop downs don't get refreshed with the members for that file.
Other files simply use the LoadLanguageFromXml calls if the file isn't of cs or vb type
//
// Set the language parser to use from the file extension
//
// Firstly try and find an add on language specified for the file
// otherwise drop back to using a dynamic languaged definition.
//
SyntaxLanguage syntaxLanguage = GetAddOnLanguageForFileExtension(Path.GetExtension(sourceFile.FileName));
if (syntaxLanguage != null)
{
rightDocument.Language = syntaxLanguage;
}
else
{
//
// If language of file doesn't support add on features then try
// retrieve a dynamic language definition
//
// If a dynamic language definition doesn't exist then no colour
// syntax highlighting will be applied.
//
String languageFile = LanguageSupport.GetLanguageFileFromExtension(Path.GetExtension(sourceFile.FileName));
if (languageFile != null)
{
try
{
rightDocument.LoadLanguageFromXml(languageFile, 0);
Trace.WriteLineIf(traceSwitchSourceCodeEditorBuilder.TraceInfo,
String.Format("Loaded dynamic language xml definition from file '{0}'",
languageFile));
}
catch (Exception e)
{
Trace.WriteLineIf(traceSwitchSourceCodeEditorBuilder.TraceError,
String.Format("Failed to load dynamic language xml definition from file '{0}', Exception='{1}'",
languageFile,
e.Message));
throw;
}
}
}
leftEditorTypeMemberDropDownList.Visible = syntaxLanguage != null;
rightEditorTypeMemberDropDownList.Visible = syntaxLanguage != null;