Hello world,
I want to bring something that is currently bugging me to light and hope that some of you might find this an interesting/entertaining one ;)
Ok, in our company we use a application that imports its sub-application via MEF and docks them as MDI's into its form.
Plugin-names are listed in a list on the left (serving as menu) and are shown in the right area upon click.
Nothing special...
If someone clicks a plugin-name, the related plugin is figured out by the PluginManager object and loaded. The plugin then returns a form (System.Windows.Form) to the PluginManager which is then docked/shown in the righ area as mentioned.
Before docking the PluginManager adds the following to the form:
Form frm = GetForm(key);
frm.AutoScroll = true;
frm.AutoScrollMargin = new Size(5, 5);
frm.AutoScrollMinSize = frm.Size;
That adds scrollbars if necessary because some of our users still use small monitors.
I have to mention that the above code was added to the PluginManager lately and didn't exist from the beginning.
So far so good, scrollable forms... lovely.
Then I realized that clicking Controls within these forms made the form autoscroll to the control getting focused (honestly I have to admit that I wasn't aware of this behavior in first place - now I am).
I then figured out that overriding the following in the form fixed the problem
protected override System.Drawing.Point ScrollToControl(Control activeControl)
{
return DisplayRectangle.Location;
}
So now the only problem is implementing it into about 30 existing plugins.
Here is where the actual trouble starts.
I thought about changing the plugins returned form to something that inherits from System.Windows.Form and overrides the ScrollToControl method, but that requires recompiling every plugin...
What about overriding the method in an existing instance of the form that the plugin returns by the PluginManager... would that work somehow?
Update:
My main goal is not to implement something into every plugin (there are quite a few of that and to some I don't even have access) but to let the PluginManager handle this somehow if possible...
Any idea is happily appreciated,
cheers and best regards
Andy
PS...maybe it is not that entertaining ;)