Perhaps there's already a way to do this, but I haven't found one yet.
There are several things I'd like to do when a syntax editor loads my language. For instance, I'd like to attach to the ContextMenuRequested event, and the SmartIndent and IntellipromptSmartTagClicked events. I'd also like to set the context menu strip on the control.
I know that some of these things sound like they wouldn't be good to have in my language (like context menu strip), but I am the only one using my language and I'd like to be able to put all my code for supporting the syntax editor within my language. My current approach to solving the problem is that I have most of my code in the language, with some code in a "Component" that I place on all of my forms and hook up to a syntax editor instance. This component does the attach / detach stuff and sets up / houses the code for the context menus.
Anyway, is there any chance I can get an event for when the language is 'attached' to a syntax editor, and when it is 'detached'?
I'd expect it to look something like:
event EventHandler SyntaxEditorAttached;
event EventHandler SyntaxEditorDetached;
and the code should work like:I'm assuming all the other events that the syntax editor fires have a sender that is itself, right? That way I can figure out in my event handlers which syntax editor the event came from...
Thanks,
There are several things I'd like to do when a syntax editor loads my language. For instance, I'd like to attach to the ContextMenuRequested event, and the SmartIndent and IntellipromptSmartTagClicked events. I'd also like to set the context menu strip on the control.
I know that some of these things sound like they wouldn't be good to have in my language (like context menu strip), but I am the only one using my language and I'd like to be able to put all my code for supporting the syntax editor within my language. My current approach to solving the problem is that I have most of my code in the language, with some code in a "Component" that I place on all of my forms and hook up to a syntax editor instance. This component does the attach / detach stuff and sets up / houses the code for the context menus.
Anyway, is there any chance I can get an event for when the language is 'attached' to a syntax editor, and when it is 'detached'?
I'd expect it to look something like:
event EventHandler SyntaxEditorAttached;
event EventHandler SyntaxEditorDetached;
and the code should work like:
private void FireSyntaxEditorAttached(SyntaxLanguage language)
{
if(language != null && language.SyntaxEditorAttached != null)
language.SyntaxEditorAttached(this, EventArgs.Empty);
}
private void FireSyntaxEditorDetached(SyntaxLanguage language)
{
if(language != null && language.SyntaxEditorDetached != null)
language.SyntaxEditorDetached(this, EventArgs.Empty);
}
//...
public SyntaxLanguage Language {
get {
//... same as before
}
set {
if(_Language != value)
{
FireSyntaxEditorDetached(_Language);
_Language = value;
//... other stuff when language changes
FireSyntaxEditorAttached(_Language);
}
}
}
Thanks,
Kelly Leahy Software Architect Milliman, USA