以编程方式启动 sketchflow 播放器

发布于 2024-10-04 10:33:13 字数 222 浏览 3 评论 0原文

我正在尝试将 SketchFlow 原型嵌入 PRISM 区域,我成功地渲染了 sketchflow 播放器视觉效果,但似乎 Sketch.Flow 数据未加载。我在 NavigationViewModel 上看到许多绑定异常。

我知道它可能不受官方支持,但我想在单个 Silverlight 应用程序中托管多个 sketchflow,以便我可以轻松部署新的 SketchFlow XAP 并显示我选择的任何一个。

I am trying to embed a SketchFlow prototype in a PRISM region, i am successful in getting the sketchflow player visuals to render but it appears that the Sketch.Flow data is not loaded. I see a number of binding exceptions on the NavigationViewModel.

I know it may not be officially supported but I would like to host multiple sketchflows within a single Silverlight application so I can easily deploy new SketchFlow XAPs and display whichever one I so choose.

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

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

发布评论

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

评论(2

洋洋洒洒 2024-10-11 10:33:13

您的问题中没有提供足够的信息来确定,但我怀疑这与 SketchFlow 播放器如何找到 Sketch.Flow 数据文件有关。

如果您查看常规 SketchFlow 项目的结构,您会发现一个主应用程序和一个包含项目屏幕的第二个程序集。在主应用程序的 app.xaml.cs 文件中,有一行如下所示:

[ assembly: Microsoft.Expression.Prototyping.Services.SketchFlowLibraries("SilverlightPrototype1.Screens")]

该行定义了 SketchFlow Player 的位置寻找它期望的数据。我还没有尝试过您正在做的事情,但可能需要在您的主程序或托管 SketchFlow 播放器的加载程序集中设置该属性。

请注意,这并没有以任何方式得到官方支持,我只是想帮助您找到解决方案。

There isn't quite enough info provided in your question to know for sure, but I suspect it has to do with how the SketchFlow Player finds the Sketch.Flow data file.

If you look at how a regular SketchFlow project is structured, you have a main app, and a second assembly containing the screens for the project. In the app.xaml.cs file of the main app, there is a line that looks like this:

[assembly: Microsoft.Expression.Prototyping.Services.SketchFlowLibraries("SilverlightPrototype1.Screens")]

That line defines where the SketchFlow Player will look for the data it expects. I haven't tried what you are doing, but that attribute will probably need to be set on your main, or the loading assembly that hosts the SketchFlow Player.

Please note that this is not officially supported in any way, I'm just trying to help find a solution for you.

初熏 2024-10-11 10:33:13

第一步是构造 PlayerWindow 的实例。

string targetTypeName = "Microsoft.Expression.Prototyping.Workspace.PlayerWindow, Microsoft.Expression.Prototyping.Runtime, Version=4.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
var targetType = Type.GetType(targetTypeName);
var view = container.Resolve(targetType) as PlayerWindow;

简单地构造一个 PlayerWindow 是不够的。不幸的是,播放器窗口内部有代码使用 CallingAssembly 来定位 Sketch.Flow 内容并将其反序列化。下面我修改了在 Microsoft PlayerWindow 类中找到的代码,以使用指定的程序集而不是从 CallingAssembly 派生的程序集来执行此操作。

string str = string.Format(CultureInfo.InvariantCulture, "/SilverlightPrototype1.Screens;Component/Sketch.Flow", new object[] { PlayerContext.Instance.LibraryName });
StreamResourceInfo resourceStream = Application.GetResourceStream(new Uri(str, UriKind.RelativeOrAbsolute));
if (resourceStream != null)
{
数据 = Serializer.Deserialize(resourceStream.Stream);
}
一旦我得到反序列化的Sketch.Flow

内容,我想我需要使用该数据和其他视图模型、MiniFlowGraphViewModel、AnnotationViewModel、BrandingModel 重新初始化 PlayerWindow 的 NavigationViewModel,以及更新 DesignTimeAnnotations。

PlayerContext.Instance.RuntimeData = data;
view.NavigationViewModel = new NavigationViewModel(data);
view.MiniFlowGraphViewModel = new FlowGraphViewModel();
view.AnnotationViewModel = new AnnotationViewModel(view.NavigationViewModel, data.RuntimeOptions.DisableInking, data.RuntimeOptions.HideDesignTimeAnnotations);
view.BrandingModel = new BrandingModel(data);
PlayerContext.Instance.BrandingModel = new BrandingModel(data);

不幸的是,PLayerWindow 上的 DesignTimeAnnotations 属性似乎是内部的或私有的,因此我不确定如何更新它。

执行上述操作将使我在该区域内获得一个 SketchFlow 播放器,导航显示显示我当前位于“屏幕 1”。但是,主屏幕显示区域为空白,左侧控制面板无法工作。我在 NavigationViewModel、BrandinModel 和 FlowGraphModel 上收到各种 BindingExpression 错误。

  • Zoom
  • DockedControls
  • CollapsedControls
  • SharedInkStrokes
  • InkVisibility
  • InkEditingMode
  • IsInkEditModeNone
  • IsMapOpen
  • IsFlowOverviewOpen

The first step is to construct an instance of the PlayerWindow.

string targetTypeName = "Microsoft.Expression.Prototyping.Workspace.PlayerWindow, Microsoft.Expression.Prototyping.Runtime, Version=4.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
var targetType = Type.GetType(targetTypeName);
var view = container.Resolve(targetType) as PlayerWindow;

Simply constructing a PlayerWindow is not enough. The player window has code inside of it that unfortunately uses the CallingAssembly to locate the Sketch.Flow content and de-serialize it. Below I have modified the code I found in the Microsoft PlayerWindow class to do this to use a specified assembly instead of the one derrived from the CallingAssembly.

string str = string.Format(CultureInfo.InvariantCulture, "/SilverlightPrototype1.Screens;Component/Sketch.Flow", new object[] { PlayerContext.Instance.LibraryName });
StreamResourceInfo resourceStream = Application.GetResourceStream(new Uri(str, UriKind.RelativeOrAbsolute));
if (resourceStream != null)
{
data = Serializer.Deserialize(resourceStream.Stream);
}

Once I get the deserialized Sketch.Flow content back I think I need to re-initialize the PlayerWindow's NavigationViewModel using that data and the other view models, MiniFlowGraphViewModel, AnnotationViewModel, BrandingModel, as well as update DesignTimeAnnotations.

PlayerContext.Instance.RuntimeData = data;
view.NavigationViewModel = new NavigationViewModel(data);
view.MiniFlowGraphViewModel = new FlowGraphViewModel();
view.AnnotationViewModel = new AnnotationViewModel(view.NavigationViewModel, data.RuntimeOptions.DisableInking, data.RuntimeOptions.HideDesignTimeAnnotations);
view.BrandingModel = new BrandingModel(data);
PlayerContext.Instance.BrandingModel = new BrandingModel(data);

Unfortunately it appears that the DesignTimeAnnotations property on PLayerWindow is either internal or private so I am not sure how I can update it.

Doing the above will get me a SketchFlow Player inside of the region with the navigation display showing that I am currently on "Screen 1". However, the main screen display area is blank and the left hand control panels are not working. I get a variety of BindingExpression errors on NavigationViewModel, BrandinModel and FlowGraphModel.

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