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
stylesheetStylesheetThe stylesheet to use for this project.
Fields
DefaultColumnProportionName
Constant name for default column proportion values.
public const string DefaultColumnProportionName = "DefaultColumnProportion"
Field Value
DefaultProportionName
Constant name for default proportion values.
public const string DefaultProportionName = "DefaultProportion"
Field Value
DefaultRowProportionName
Constant name for default row proportion values.
public const string DefaultRowProportionName = "DefaultRowProportion"
Field Value
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
Properties
DesignerRtfAssetsPath
Gets or sets the designer runtime assets folder path.
[FilePath(FileDialogMode.ChooseFolder, "", false)]
public string DesignerRtfAssetsPath { get; set; }
Property Value
ExportOptions
Gets the export options for this project.
[Browsable(false)]
public ExportOptions ExportOptions { get; }
Property Value
ObjectsNodes
Gets the mapping of loaded objects to their respective XML nodes.
[Browsable(false)]
public List<Tuple<object, XElement>> ObjectsNodes { get; }
Property Value
Root
Gets or sets the root widget of the project.
[Browsable(false)]
public Widget Root { get; set; }
Property Value
Stylesheet
Gets or sets the stylesheet for this project.
[Browsable(false)]
public Stylesheet Stylesheet { get; set; }
Property Value
StylesheetPath
Gets or sets the path to the stylesheet file.
[Browsable(false)]
public string StylesheetPath { get; set; }
Property Value
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
namestringThe 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
sstringThe 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
datastringThe XML string containing the project definition.
assetManagerAssetManagerThe asset manager used to load resources referenced by the project. If null, resources will not be loaded.
customStylesheetStylesheetAn 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
oobjectThe object containing the property.
pPropertyInfoThe 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.