Type thisType = this.GetType ();
if (!string.IsNullOrEmpty (Style)) {
- if (Interface.DefaultValuesLoader.ContainsKey (Style)) {
- Interface.DefaultValuesLoader [Style] (this);
+ if (CurrentInterface.DefaultValuesLoader.ContainsKey (Style)) {
+ CurrentInterface.DefaultValuesLoader [Style] (this);
return;
}
} else {
- if (Interface.DefaultValuesLoader.ContainsKey (thisType.FullName)) {
- Interface.DefaultValuesLoader [thisType.FullName] (this);
+ if (CurrentInterface.DefaultValuesLoader.ContainsKey (thisType.FullName)) {
+ CurrentInterface.DefaultValuesLoader [thisType.FullName] (this);
return;
- } else if (!Interface.Styling.ContainsKey (thisType.FullName)) {
- if (Interface.DefaultValuesLoader.ContainsKey (thisType.Name)) {
- Interface.DefaultValuesLoader [thisType.Name] (this);
+ } else if (!CurrentInterface.Styling.ContainsKey (thisType.FullName)) {
+ if (CurrentInterface.DefaultValuesLoader.ContainsKey (thisType.Name)) {
+ CurrentInterface.DefaultValuesLoader [thisType.Name] (this);
return;
}
}
// those files being placed in a Styles folder
string styleKey = Style;
if (!string.IsNullOrEmpty (Style)) {
- if (Interface.Styling.ContainsKey (Style)) {
- styling.Add (Interface.Styling [Style]);
+ if (CurrentInterface.Styling.ContainsKey (Style)) {
+ styling.Add (CurrentInterface.Styling [Style]);
}
}
- if (Interface.Styling.ContainsKey (thisType.FullName)) {
- styling.Add (Interface.Styling [thisType.FullName]);
+ if (CurrentInterface.Styling.ContainsKey (thisType.FullName)) {
+ styling.Add (CurrentInterface.Styling [thisType.FullName]);
if (string.IsNullOrEmpty (styleKey))
styleKey = thisType.FullName;
}
- if (Interface.Styling.ContainsKey (thisType.Name)) {
- styling.Add (Interface.Styling [thisType.Name]);
+ if (CurrentInterface.Styling.ContainsKey (thisType.Name)) {
+ styling.Add (CurrentInterface.Styling [thisType.Name]);
if (string.IsNullOrEmpty (styleKey))
styleKey = thisType.Name;
}
#endregion
try {
- Interface.DefaultValuesLoader[styleKey] = (Interface.LoaderInvoker)dm.CreateDelegate(typeof(Interface.LoaderInvoker));
- Interface.DefaultValuesLoader[styleKey] (this);
+ CurrentInterface.DefaultValuesLoader[styleKey] = (Interface.LoaderInvoker)dm.CreateDelegate(typeof(Interface.LoaderInvoker));
+ CurrentInterface.DefaultValuesLoader[styleKey] (this);
} catch (Exception ex) {
throw new Exception ("Error applying style <" + styleKey + ">:", ex);
}
/// store indices of template delegate to be handled by root parentChanged event
/// </summary>
List<int> templateCachedDelegateIndices = new List<int>();
+ /// <summary>
+ /// Store template bindings in the instantiator
+ /// </summary>
Delegate templateBinding;
#region IML parsing
/// <summary>
- /// Parses IML and build a dynamic method that will be used to instanciate one or multiple occurence of the IML file or fragment
+ /// Parses IML and build a dynamic method that will be used to instantiate one or multiple occurences of the IML file or fragment
/// </summary>
void parseIML (XmlReader reader) {
IMLContext ctx = new IMLContext (findRootType (reader));
Directory.CreateDirectory (CrowConfigRoot);
loadCursors ();
- loadStyling ();
findAvailableTemplates ();
FontRenderingOptions = new FontOptions ();
public Interface(){
CurrentInterface = this;
CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
-
+ loadStyling ();
initTooltip ();
}
#endregion
/// The compilation is done on the first object instancing, and is also done for custom widgets
public delegate void LoaderInvoker(object instance);
/// <summary>Store one loader per StyleKey</summary>
- public static Dictionary<String, LoaderInvoker> DefaultValuesLoader = new Dictionary<string, LoaderInvoker>();
+ public Dictionary<String, LoaderInvoker> DefaultValuesLoader = new Dictionary<string, LoaderInvoker>();
/// <summary>Store dictionnary of member/value per StyleKey</summary>
- public static Dictionary<string, Style> Styling;
+ public Dictionary<string, Style> Styling;
/// <summary> parse all styling data's during application startup and build global Styling Dictionary </summary>
- static void loadStyling() {
+ protected virtual void loadStyling() {
Styling = new Dictionary<string, Style> ();
//fetch styling info in this order, if member styling is alreadey referenced in previous
loadStylingFromAssembly (Assembly.GetExecutingAssembly ());
}
/// <summary> Search for .style resources in assembly </summary>
- static void loadStylingFromAssembly (Assembly assembly) {
+ void loadStylingFromAssembly (Assembly assembly) {
if (assembly == null)
return;
foreach (string s in assembly
.GetManifestResourceNames ()
.Where (r => r.EndsWith (".style", StringComparison.OrdinalIgnoreCase))) {
- new StyleReader (assembly, s)
- .Dispose ();
+ using (Stream stream = assembly.GetManifestResourceStream (s)) {
+ new StyleReader (this, stream, s);
+ }
+
}
}
static void loadCursors(){
int column = 1;
int line = 1;
- public StyleReader (Assembly assembly, string resId)
- : base(assembly.GetManifestResourceStream (resId))
+ public StyleReader (Interface iface, Stream stream, string resId)
+ : base(stream)
{
resourceId = resId;
string styleKey = resId.Substring (0, resId.Length - 6);
string expression = token.Trim ();
foreach (string tc in targetsClasses) {
- if (!Interface.Styling.ContainsKey (tc))
- Interface.Styling [tc] = new Style ();
- else if (Interface.Styling [tc].ContainsKey (currentProperty))
+ if (!iface.Styling.ContainsKey (tc))
+ iface.Styling [tc] = new Style ();
+ else if (iface.Styling [tc].ContainsKey (currentProperty))
continue;
- Interface.Styling [tc] [currentProperty] = expression;
+ iface.Styling [tc] [currentProperty] = expression;
}
token = "";
}