I'm designing a WPF program that will use a DLL-plugin architecture. The host application is more "chrome" than content. It's in charge of providing a consistent look and feel, as well as providing some features common to all the plugins (Such as a "Check for updates" button).
However, my plan is that 3rd party developers will code the plugins. As such, they will need to add plugin specific functionality. I've designed the host application so that it allocates a tab page (or two, if the plugin requests it), and will allow the plugin to fill that tab page with its own buttons, listboxes, ect, which will then trigger the appropriate code in the plugin.
Kind of like MDI, except that the buttons will be hosted in the host application's tab page, but will trigger events in the plugin.
I need some help figuring out how to implement this design. What do I, as the host-programmer, need to do to support this (Such as loading the plugin and filling the tab page)? What will the plugin developers need to do to
"Embed" their WPF in my tab page
Catch events generated by their embedded controls
Get this into a DLL
Check WPF Add-Ins architecture. Here is a sample.
Much of the boilerplate stuff needed to implement a plugin architecture can be found in the Managed Extensibility Framework:
http://mef.codeplex.com/
As for hosting buttons on the Host that will trigger events in the client page, you can achieve this by executing a specific command with the client page set as the Target. Here is an example of executing the 'Paste' command on a Page called "hostedWpfPageControl":
ApplicationCommands.Paste.Execute(null, this.hostedWpfPageControl);
Related
I need to add one button with events on third party windows application, whose click event will open web browser with provided link.
Is there any way to achieve this using c#, .net framework?
I do have API(DLL) to access some of the events and can deploy with third party application. But it doesn't provide method to acces the winform controls. The DLL is a SDK to subscribe events and perform background operations on the third party app.
Is there any way to dynamically draw a button control on current active windows form?
As far as I know, this is not possible since third party app, best approach would be to encapsulate the windows app with your own native app either by consuming the third party component as a control then adding your own buttons around the view that consumes it.
Here's the situation:
We have an existing .NET executable that contains an application using WPF components (dialogs and forms). This executable was created using Gupta Team Developer 6.1, but I'm not sure that is relevant to my question. We'd like to re-use some of these forms in a C#-application, but this is proving difficult.
When we include the external components, either in XAML or by instantiating them in code, they look OK (i.e. fields, buttons, layout etc.), but the event wiring seems to be missing. Nothing happens when pressing buttons and tables/grids are empty.
I've read previous articles on this site on using external WPF components, but they all mention external assemblies compiled as control libraries. Are we trying to do something that's not really possible?
P.S As an experiment we've tried to instantiate the App-object from the executable directly and this brings up a fully functional version of the entire application (well, duh), but we'd really like to be able to pick and choose from the individual forms/dialogs.
I have a WPF executable and I wish to make provisions to it, so that later,
someone from outside might modify or add another window or page
using dll totally separate from my solution.
For short, I wish to make my wpf windows or pages pluggable. How do I do this?
Prism's support modular, on-demand-loading of modules and other parts of your application, in it's core.
you can use MEF framework to make pluggable modules (windows and pages), as it's fully integrated with Prism.
You can find examples and more information in the following resources:
http://www.codeproject.com/Articles/188054/An-Introduction-to-Managed-Extensibility-Framework
http://www.codeproject.com/Articles/37579/Managed-Extensibility-Framework-Part-2
http://www.codeproject.com/Articles/432069/Simple-MEF-Application-for-Beginners
http://www.codeproject.com/Articles/232868/MEF-Features-with-Examples
All,
If you install the Webex productivity tools and have skype installed it adds a window decoration from where you can click a button and it will automatically paste into the conversation box a new webex conference link.
I would like to do something similar for my application, but where to start with adding the window decoration? Is there a standard API for this sort of thing?
Any guidance is appreciated.
What you basically want to do is to 'Draw custom controls' in the Windows Non-Client area. This is also sometimes called the 'Chrome' of the Window.
If you want to do this in your own application, this SO question answers many of the options available: Custom titlebars/chrome in a WinForms app
The code for the main article cited from http://geekswithblogs.net/kobush/articles/CustomBorderForms.aspx is availble at http://customerborderform.codeplex.com/
If you want to add your custom controls to other applications, then you will need to hook into those applications their WndProc. In order to achieve that, you will need to inject your dll into that application (see http://www.codingthewheel.com/archives/how-to-inject-a-managed-assembly-dll and http://www.codeproject.com/Articles/4610/Three-Ways-to-Inject-Your-Code-into-Another-Proces#section_1) and then hook into the WndProc again.
I have an external windows application (no source code) that has a grid within it. This runs as a separate process. When the user selects a cell within the grid via mouse click, I need to be able to read the value within that cell. Can anyone provide some direction on what API's I would need to use to be able to trap and listen to the events?
You best option is UI Automation Overview or accessibility as older technology.
Also you could take a look at this Pinvoke SetFocus to a particular control on how to invoke things on another process (pretty much unrelated to automation, automation works w/o that)
UI Automation is the best tool for the job, however, the downside is that not every app supports that - so this very much depends on the app you're targeting. Some support only the legacy acessibility (IAccessible, IAccessible2 etc.), usually there is a 'combined' approach. Older techniques don't work very good any more but you could try traversing windows, child windows in the target window (for that direction you'll probably need the above technique sooner or later) and hoping you could get it from standard controls, windows text, via messages etc.