Table of Contents

Class Project

Namespace
Myra.Graphics2D.UI
Assembly
Myra.dll

Represents a UI project that can be saved, loaded, and exported to code.

public class Project
Inheritance
Project
Inherited Members

Constructors

Project()

Initializes a new instance of the Project class using the current stylesheet.

public Project()

Project(Stylesheet)

Initializes a new instance of the Project class with the specified stylesheet.

public Project(Stylesheet stylesheet)

Parameters

stylesheet Stylesheet

The stylesheet to use for this project.

Fields

DefaultColumnProportionName

Constant name for default column proportion values.

public const string DefaultColumnProportionName = "DefaultColumnProportion"

Field Value

string

DefaultProportionName

Constant name for default proportion values.

public const string DefaultProportionName = "DefaultProportion"

Field Value

string

DefaultRowProportionName

Constant name for default row proportion values.

public const string DefaultRowProportionName = "DefaultRowProportion"

Field Value

string

ExtraWidgetAssembliesAndNamespaces

Gets or sets the extra widget assemblies and namespaces to include during project loading and saving.

public static Dictionary<Assembly, string[]> ExtraWidgetAssembliesAndNamespaces

Field Value

Dictionary<Assembly, string[]>

ProportionName

Constant name for proportion values.

public const string ProportionName = "Proportion"

Field Value

string

Properties

DesignerRtfAssetsPath

Gets or sets the designer runtime assets folder path.

[FilePath(FileDialogMode.ChooseFolder, "", false)]
public string DesignerRtfAssetsPath { get; set; }

Property Value

string

ExportOptions

Gets the export options for this project.

[Browsable(false)]
public ExportOptions ExportOptions { get; }

Property Value

ExportOptions

ObjectsNodes

Gets the mapping of loaded objects to their respective XML nodes.

[Browsable(false)]
public List<Tuple<object, XElement>> ObjectsNodes { get; }

Property Value

List<Tuple<object, XElement>>

Root

Gets or sets the root widget of the project.

[Browsable(false)]
public Widget Root { get; set; }

Property Value

Widget

Stylesheet

Gets or sets the stylesheet for this project.

[Browsable(false)]
public Stylesheet Stylesheet { get; set; }

Property Value

Stylesheet

StylesheetPath

Gets or sets the path to the stylesheet file.

[Browsable(false)]
public string StylesheetPath { get; set; }

Property Value

string

Methods

GetWidgetTypeByName(string)

Gets the widget type by its name. Resolves by looking up the type in the Myra.Graphics2D.UI namespace.

public static Type GetWidgetTypeByName(string name)

Parameters

name string

The name of the widget type.

Returns

Type

The widget type, or null if not found.

IsProportionName(string)

Determines whether the specified name is a proportion property name.

public static bool IsProportionName(string s)

Parameters

s string

The name to check.

Returns

bool

true if the name is a proportion name; otherwise, false.

LoadFromXml(string, AssetManager, Stylesheet)

Loads a project from an XML string representation.

public static Project LoadFromXml(string data, AssetManager assetManager = null, Stylesheet customStylesheet = null)

Parameters

data string

The XML string containing the project definition.

assetManager AssetManager

The asset manager used to load resources referenced by the project. If null, resources will not be loaded.

customStylesheet Stylesheet

An optional custom stylesheet to apply to the project. If not provided, the stylesheet path from the project's XML will be used.

Returns

Project

A new Project instance loaded from the provided XML data, or null if loading fails.

Save()

Saves the project to an XML string. This method is obsolete; use ToXml() instead.

[Obsolete("Use ToXml")]
public string Save()

Returns

string

An XML string representation of the project.

ShouldSerializeProperty(object, PropertyInfo)

Determines whether a property should be serialized for the specified object using this project's stylesheet.

public bool ShouldSerializeProperty(object o, PropertyInfo p)

Parameters

o object

The object containing the property.

p PropertyInfo

The property information.

Returns

bool

true if the property should be serialized; otherwise, false.

ToXml()

Saves the project to an XML string.

public string ToXml()

Returns

string

An XML string representation of the project.