This is the final post in this mini series, I'm going to show the finished UI user control and how simple it is to host inside a WPF app. The code is available on gitHub and the published binaries are available via nuGet (supports .Net version 4.0+).
Before I show the finished UI, lets look at the F# Interactive in Visual Studio, this loads, queries & displays the results from an external assembly:
What does this look like in my implementation?
It's looks pretty familiar right? :)
The major difference is I've output the working folder for the F# interactive process when the process starts:
I've made this configurable in code, so I thought it would be a good idea to tell the end user where they could put any assemblies they want to reference.
How can the user access the working folder?
Simply, a right click menu:
All the menu options should be obvious, the working folder for the above example is shown below, you can see it has the assembly referenced above:
For completeness the types used in the above query are shown below:
How is the user control being used in code?
The user control obviously has an XAML representation - ReplEngine. I've tried to keep the using of this as simple as possible, the following screen shot shows the control being used in an MVVM implementation with a specific theme being applied:
The control's DataContext is bound to specific view model supplied as part of the assembly. In fact if your going use the control in an MVVM application there are 3 classes you'll need to know about and use:
ReplEngine - as described above the UI representation of the REPL engine to be included in XAML,
ReplEngineController - coordinates communication between the UI and the actual REPL engine implementation, backed by an interface - IReplEngineController,
ReplEngineViewModel - contains all the UI concerns, bindable properties & commands, backed by an interface IReplEngineViewModel and accessed from the controller.
The view model (FSharpReplViewModel) used is shown below and as you can see it's using both the controller & view model, nothing complicated just simple dependency injection and exposure of the view model as the Content property:
The IoC registrations for the controller & view model are easy, as you can see there are couple of parameters, these are optional, this is where you'd configure the working folder and the script to run automatically when the UI is first rendered:
As you can see, it's really quick & simple to use in an MVVM scenario, but;
What if you're not using MVVM, what if you're using a code-behind approach?
This is catered for as well in the form of a user control called ReplWindow. This wraps the ReplEngine user control, the controller & the view model, meaning you don't have to bind any properties. The StartupScript & WorkingDirectory are exposed as dependency properties:
That's it from a hosting point of view, the only thing left to describe is the theme support, not so much describe but show a hideous green example and the supporting XAML:
The theme styles the buttons, border, text & terminal controls, if a theme is not defined it will default to the current windows theme:
Loading gist ....
The example app used above is from the Simple.Wpf.Composition repo available on gitHub.
Before I show the finished UI, lets look at the F# Interactive in Visual Studio, this loads, queries & displays the results from an external assembly:
What does this look like in my implementation?
It's looks pretty familiar right? :)
The major difference is I've output the working folder for the F# interactive process when the process starts:
I've made this configurable in code, so I thought it would be a good idea to tell the end user where they could put any assemblies they want to reference.
How can the user access the working folder?
Simply, a right click menu:
For completeness the types used in the above query are shown below:
How is the user control being used in code?
The user control obviously has an XAML representation - ReplEngine. I've tried to keep the using of this as simple as possible, the following screen shot shows the control being used in an MVVM implementation with a specific theme being applied:
The control's DataContext is bound to specific view model supplied as part of the assembly. In fact if your going use the control in an MVVM application there are 3 classes you'll need to know about and use:
ReplEngine - as described above the UI representation of the REPL engine to be included in XAML,
ReplEngineController - coordinates communication between the UI and the actual REPL engine implementation, backed by an interface - IReplEngineController,
ReplEngineViewModel - contains all the UI concerns, bindable properties & commands, backed by an interface IReplEngineViewModel and accessed from the controller.
The view model (FSharpReplViewModel) used is shown below and as you can see it's using both the controller & view model, nothing complicated just simple dependency injection and exposure of the view model as the Content property:
The IoC registrations for the controller & view model are easy, as you can see there are couple of parameters, these are optional, this is where you'd configure the working folder and the script to run automatically when the UI is first rendered:
As you can see, it's really quick & simple to use in an MVVM scenario, but;
What if you're not using MVVM, what if you're using a code-behind approach?
This is catered for as well in the form of a user control called ReplWindow. This wraps the ReplEngine user control, the controller & the view model, meaning you don't have to bind any properties. The StartupScript & WorkingDirectory are exposed as dependency properties:
That's it from a hosting point of view, the only thing left to describe is the theme support, not so much describe but show a hideous green example and the supporting XAML:
The theme styles the buttons, border, text & terminal controls, if a theme is not defined it will default to the current windows theme:
Loading gist ....
Comments
Post a Comment