Remember there was a WinForm. Using reflection to do the extensible notebook, idle to Nothing, then with WPF also made an extensible Notepad, the interface can be dynamically extended functionality, simpler, for reference:
The directory structure is as follows:
MainWindow.xaml main function interface, Functionexpand provides expansion interface;
The main function code is as follows:
private void Makefun ()
{
String location = this. GetType (). Assembly.location;
String dllpath = System.IO.Path.GetDirectoryName (location) + "\\plugs";
string[] Strdllpath = System.IO.Directory.GetFiles (DllPath, "*.dll");
foreach (var item in Strdllpath)
{
Assembly-Assembly.loadfile (item);
type[] types =. Getexportedtypes ();
Type Plugtype = typeof (IPlug);
foreach (Var t in types)
{
Determine if the Iplug interface is implemented
if (Plugtype.isassignablefrom (t))
{
Creating plug-in objects based on plug-in types
IPlug iplugobj = activator.createinstance (t) as IPlug;
Create a plug-in button
MenuItem menu = new MenuItem ();
Menu. Header = T.name;
THIS.EXPANDTOOL.ITEMS.ADD (menu);
Menu. Click + = Menu_click;
Menu. Tag = Iplugobj;
}
}
}
}
void Menu_click (object sender, RoutedEventArgs e)
{
MenuItem MenuItem = sender as MenuItem;
IPlug IPlug = Menuitem.tag as IPlug;
Tb_text.text = Iplug. Processtext (Tb_text.text);
}
The effect is as follows:
Now the code to share out, there are interested friends can study: source download
Reprint please specify from: Sparkling Lucky Star
Original address: Http://www.cnblogs.com/dongyang
If reproduced, please keep the original address. Thank you for your cooperation.
Extensible Notepad made by WPF