Skip to content
cliftonm edited this page Sep 6, 2014 · 7 revisions

Home

Guidance

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 UI Basics

Declarative (XML) data is instantiated using the lightweight MycroParser.

XML Namespaces

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"

MVC Model

HOPE implements a lightweight Model-View-Controller paradigm. The "model" tends to be the application model that is instantiated imperatively at runtime.

Instantiating a Controller

The controller is instantiated declaratively, for example:

<ixc:SemanticTypeTreeController def:Name="controller" ApplicationController="{ApplicationFormController}" ApplicationModel="{ApplicationModel}"/>

Code Behind

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> { }

Instantiating a View

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}"/>

Code Behind

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 IDE

The main form IDE is declared in the file mainform.xml.

Docking Manager

The IDE leverages the open source docking manager DockPanelSuite.

Menus

Menus are implemented with the .NET MenuStrip class and its supporting classes, such as the ToolStripMenuItem.