C# WPF MAF 插件之间的交互

发布于 2024-09-03 12:45:06 字数 241 浏览 3 评论 0原文

我想在 WPF 上使用 MAF 创建一个非常简单的 Paint 应用程序。

我想创建的插件是:

  1. 主图像处理器 - 显示当前绘画并接收来自用户的
  2. 输入 工具箱 - 用户可以选择某些类型的绘图工具
  3. 图层 - 用户可以选择要显示的图层、删除图层和选择在哪一层上工作的

问题是:如何在不使用主机的情况下在不同的加载项之间进行交互?

谢谢, 罗尼

I would like create a very simple Paint application using MAF on WPF.

The Add Ins I would like to create are:

  1. Main Image Processor - Shown the current paint and receive inputs from the user
  2. Tool Box - The user can select some types of drawings tools
  3. Layers - The user can select the layers to display, delete layers and select on which layer to work on

the question is: How I can interact between the different Add-Ins without using the host?

Thanks,
Ronny

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

渔村楼浪 2024-09-10 12:45:06

我这样做的方法是让主机在发现每个加载项时将其收集到一个集合中,然后在初始化时将该集合传递给每个加载项。您传递给加载项的是其他加载项的接口,因为这实际上是主机所了解的所有内容。

主机应该初始化每个加载项,然后一旦它们全部初始化,就向它们发出激活信号,然后它们发现其他加载项并开始执行它们的操作。每个加载项都应公开 WhoAreYou 方法,以便它们在激活时可以找出还安装了哪些人。从基类派生加载项将简化这一过程。一旦你解决了其中一个问题,那么所有的问题都解决了。

这种方法仅使用主机来收集和分发加载项接口,加载项通过合约管道直接相互通信,而不是通过主机路由消息。

The way I do it is for the host to gather each add-in into a collection as they're being discovered, and then pass that collection to each add-in as it initializes it. What you're passing to the add-ins are the other add-ins' interfaces, as that's really all the host knows about them.

The host should initialize each add-in, and then once they're all initialized, signal them to activate, where they then discover the other add-ins and go do their thing. Each add-in should expose a WhoAreYou method so that they can find out who else is installed when they're activated. Deriving your add-ins from a base class will simplify this. Once you've figured it out for one then it's done for all of them.

This approach only uses the host to collect and distribute the add-in interfaces, with the add-ins communicating directly with each other through the contract pipeline instead of routing messages through the host.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文