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