private void loadPlugins() { try { foreach (string dll in Directory.GetFiles("./plugins", "*.dll")) { Assembly assembly = Assembly.LoadFrom(dll); foreach (Type type in assembly.GetTypes()) { toolBar.Items.Add(new Separator()); if (type.IsClass && type.IsPublic && typeof(IPlugin).IsAssignableFrom(type)) { Object obj = Activator.CreateInstance(type); IPlugin plugin = (IPlugin)obj; Effect effect = plugin.getEffect(); EffectCommand command = new EffectCommand(effect, mainCanvas); Button pluginButton = plugin.getPluginButton(); pluginButton.DataContext = command; pluginButton.Click += pluginButton_Click; toolBar.Items.Add(pluginButton); } } } } catch (DirectoryNotFoundException e) { MessageBox.Show("No plugins"); } }
private void pluginButton_Click(object sender, RoutedEventArgs e) { Button senderButton = sender as Button; EffectCommand command = senderButton.DataContext as EffectCommand; undoRedo.InsertComand(command); command.Execute(); }
private void testEffects_Click(object sender, RoutedEventArgs e) { //this.CreateBitmap(mainCanvas); DropShadowEffect effect = new DropShadowEffect(); effect.Direction = 320; effect.ShadowDepth = 25; effect.Color = Color.FromRgb(122, 122, 122); effect.Opacity = 1; BlurEffect blur = new BlurEffect(); blur.Radius = 15; EffectCommand command = new EffectCommand(blur, mainCanvas); undoRedo.InsertComand(command); command.Execute(); }