Skip to content

interface markup language

Jean-Philippe Bruyère edited this page Nov 1, 2021 · 4 revisions

IML is a declarative language based on XML for defining user interfaces.

<HorizontalStack DataSource="{CurrentSolution}">
	<TreeView Name="treeview" Width="20%" Height="100%" IsRoot="true"
		Data="{Projects}" SelectedItemChanged="onSelectedItemChanged"
		ItemTemplate="#CrowIDE.ui.ProjectTree.template"/>
	<Splitter/>
	<EditPane Data="{OpenedItems}" DataTest="Extension"
		SelectedItem="{²SelectedItem}"	SelectedItemElement="{²SelectedItemElement}"
		ItemTemplate="#CrowIDE.ui.EditPaneItems.template"/>
	<Splitter/>
	<MembersView Width="30%" Background="DimGray"
		DataTest="Type"  Instance="{SelectedItemElement}"
		ItemTemplate="#CrowIDE.ui.MembersItem.template"/>
</HorizontalStack>

IML files are compiled into a single dynamic method on their first load, further instantiations are done through Instantiators that holds all the logic for parsing and compilation, this mechanic is transparent for normal uses. This allows interface visuals to be modified by end user without changing the internals.

XML Elements

XML elements may be any class derived from Widget plus several special tags:

Depending on the base class derived, an element may accept or not single or multiple children following those rules:

XML Attributes

Attributes may be any of the public properties or events of the Widget.

Attribute values are converted automatically in the decalring type of the property. Overriding the ToString() method and providing a public static Parse(string str) method will control the conversions. No conversion syntax exists in IML.

exemple:
//implementation of string conversions in the Size class
public override string ToString() =>
	string.Format("{0},{1}", Width, Height);

public static Size Parse(string s) {
	string[] d = s.Split(new char[] { ',' });
	return d.Length == 1 ? new Size(int.Parse(d[0])) : new Size(
		int.Parse(d[0]),
		int.Parse(d[1]));
}

This will allow to read and write Size attributes in IML with an integer pair separated with a comma.

<Widget MinimumSize="50,50"/>

Enum` values may be specified with their single name.

<Widget HorizontalAlignment="Left"/>

Properties accepting a file path, may also accept the hashtag(#) prefix for targeting embedded resources inside loaded assemblies.

<Image Path="#resource.id.png"/>

Events attribute accept handler method name (private or public) having corresponding signature.

<Widget MouseClick="onMouseClick1"/>

All attribute values may accept binding expressions enclosed in curly brackets.

<Label Text="{DSProperty}" DataSource="{CurrentDS}"/>

Further readings:

Clone this wiki locally