/// <summary> /// Creates a set of windows (a GUI layout) from the information in the specified XML. /// </summary> /// <param name="source"> /// String holding the XML source /// </param> /// <param name="callback"> /// PropertyCallback function to be called for each Property element loaded from the layout. This is /// called prior to the property value being applied to the window enabling client code manipulation of /// properties. /// </param> /// <param name="userdata"> /// Client code data pointer passed to the PropertyCallback function. /// </param> /// <returns> /// Pointer to the root Window object defined in the layout. /// </returns> public Window LoadLayoutFromString(string source, PropertyCallback callback = null, object userdata = null) { // log the fact we are about to load a layout System.GetSingleton() .Logger.LogEvent("---- Beginning loading of GUI layout from string ----", LoggingLevel.Informative); // create handler object var handler = new GuiLayoutXmlHandler(callback, userdata); // do parse (which uses handler to create actual data) try { System.GetSingleton() .GetXMLParser() .ParseXmlString(handler, source, GuiLayoutSchemaName); } catch { System.GetSingleton() .Logger.LogEvent("WindowManager::loadLayoutFromString - loading of layout from string failed.", LoggingLevel.Errors); throw; } // log the completion of loading System.GetSingleton() .Logger.LogEvent("---- Successfully completed loading of GUI layout from string ----"); return(handler.GetLayoutRootWindow()); }
/// <summary> /// Creates a set of windows (a GUI layout) from the information in the specified XML file. /// </summary> /// <param name="filename"> /// String object holding the filename of the XML file to be processed. /// </param> /// <param name="resourceGroup"> /// Resource group identifier to be passed to the resource provider when loading the layout file. /// </param> /// <param name="callback"> /// PropertyCallback function to be called for each Property element loaded from the layout. This is /// called prior to the property value being applied to the window enabling client code manipulation of /// properties. /// </param> /// <param name="userdata"> /// Client code data pointer passed to the PropertyCallback function. /// </param> /// <returns> /// Pointer to the root Window object defined in the layout. /// </returns> /// <exception cref="InvalidRequestException"> /// thrown if a filename appears to be invalid. /// </exception> public Window LoadLayoutFromFile(string filename, string resourceGroup = "", PropertyCallback callback = null, object userdata = null) { if (String.IsNullOrEmpty(filename)) { throw new InvalidRequestException("Filename supplied for gui-layout loading must be valid."); } // log the fact we are about to load a layout System.GetSingleton() .Logger.LogEvent("---- Beginning loading of GUI layout from '" + filename + "' ----", LoggingLevel.Informative); // create handler object var handler = new GuiLayoutXmlHandler(callback, userdata); // do parse (which uses handler to create actual data) try { System.GetSingleton() .GetXMLParser() .ParseXmlFile(handler, filename, GuiLayoutSchemaName, String.IsNullOrEmpty(resourceGroup) ? d_defaultResourceGroup : resourceGroup); } catch { System.GetSingleton() .Logger.LogEvent( "WindowManager::loadLayoutFromFile - loading of layout from file '" + filename + "' failed.", LoggingLevel.Errors); throw; } // log the completion of loading System.GetSingleton() .Logger.LogEvent("---- Successfully completed loading of GUI layout from '" + filename + "' ----"); return(handler.GetLayoutRootWindow()); }