-
Notifications
You must be signed in to change notification settings - Fork 20
The User Interface
The user interface is implemented in XML instead of a Visual Studio generated form. Rather than argue the pros and cons of this, we will simply state that this is the way UI's are implemented in HOPE, and we require that any UI's that you contribute to the core open source components are implemented declaratively as well.
Declarative, XML-based UI's should also be utilized for any receptor UI requirements. Note that you can edit the receptor UI XML and have the changes appear immediately, without recompiling the application.
A UI editing tool that generates XML exists but is not currently available to the public.
Declarative (XML) data is instantiated using the lightweight MycroParser.
XML namespaces are used to associate a class name with its implementing assembly. The namespace for .NET and third party assemblies must be fully qualified, for example:
xmlns:wf="System.Windows.Forms, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
Namespaces referencing HOPE assemblies require only the C# namespace and assembly name, for example:
xmlns:ixc="TypeSystemExplorer.Controllers, TypeSystemExplorer"
HOPE implements a lightweight Model-View-Controller paradigm. The "model" tends to be the application model that is instantiated imperatively at runtime.
The controller is instantiated declaratively, for example:
<ixc:SemanticTypeTreeController def:Name="controller" ApplicationController="{ApplicationFormController}" ApplicationModel="{ApplicationModel}"/>
In the code behind, it is implemented:
- in the namespace 'TypeSystemExplorer.Controllers'
- in the folder Controllers
A minimal implementation references the view type in the base class instantiation, for example:
public class SemanticTypeEditorController : ViewController<SemanticTypeEditorView> { }
The view is instantiated declaratively as well, as a child control of the docking suite's GenericPane
, for example:
<ix:Controls> <ixv:SemanticTypeEditorView def:Name="semanticTypeEditorView" Dock="Fill" Model="{ApplicationModel}" ApplicationController="{ApplicationFormController}">
And can itself have child controls. Once instantiated, it is often useful to handle certain events to synchronize, for example, menu options or other behaviors. This is done declaratively by referencing the fully instantiated view, for example:
<ixv:SemanticTypeEditorView ref:Name="semanticTypeEditorView" DockContent="{Container}" Opening="{controller.Opening}" Closing="{controller.Closing}"/>
The view code-behind recommended minimum provides events for opening and closing the pane which facilitates managing forms in the dock panel suite (why the formatting of the code block here is screwed up is beyond me):
` public class SemanticTypeEditorView : PaneView { public delegate void NotificationDlgt();
public event NotificationDlgt Opening;
public event NotificationDlgt Closing;
public ApplicationModel Model { get; protected set; }
public override string MenuName { get { return "mnuSemanticTypeEditor"; } }
public override void EndInit()
{
Opening.IfNotNull().Then(() => Opening());
base.EndInit();
}
protected override void WhenHandleDestroyed(object sender, EventArgs e)
{
Closing.IfNotNull().Then(() => Closing());
base.WhenHandleDestroyed(sender, e);
}
} '
This provides some basic functionality for interacting with the rest of the application.
The main form IDE is declared in the file mainform.xml.
The IDE leverages the open source docking manager DockPanelSuite.
Menus are implemented with the .NET MenuStrip
class and its supporting classes, such as the ToolStripMenuItem
.