/// <summary> /// Creates a widget by parsing the xml node, extracting /// widget information and then using it to create the widget /// object. /// </summary> /// <param name="node">Node that contains widget info</param> /// <returns>widget, null if error</returns> private Widget createWidget(XmlNode node) { String widgetClass = XmlUtils.GetXMLAttrString(node, "class"); String widgetName = XmlUtils.GetXMLAttrString(node, "name"); if (String.IsNullOrEmpty(widgetName) || String.IsNullOrEmpty(widgetClass)) { return(null); } // look in the form for the .NET control for this widget Control control = findControl(_rootControl, widgetName); Widget widget = null; try { Type widgetType = WidgetManager.GetWidgetType(widgetClass); if (widgetType != null) { widget = (control != null) ? CreateWidget(widgetType, control) : CreateWidget(widgetType, widgetName); if (widget != null) { widget.LayoutXmlNode = node; widget.Load(node); } } } catch (Exception e) { Log.Debug("Error creating widget " + widgetName, e); widget = null; } return(widget); }
/// <summary> /// Create the widget manager. Load all the widgets /// from the config file /// </summary> /// <param name="configFileName">name of the animation file</param> /// <returns></returns> private bool initWidgetManager(String configFileName) { _widgetManager = new WidgetManager(ScannerForm); _widgetManager.Layout.SetColorScheme(ColorSchemes.ScannerSchemeName); _widgetManager.Layout.SetDisabledButtonColorScheme(ColorSchemes.DisabledScannerButtonSchemeName); bool retVal = _widgetManager.Initialize(configFileName); if (!retVal) { Log.Error("Unable to initialize widget manager"); } else { _rootWidget = _widgetManager.RootWidget; if (String.IsNullOrEmpty(_rootWidget.SubClass)) { _rootWidget.SubClass = (ScannerForm is ContextualMenuBase) ? PanelClasses.PanelCategory.ContextualMenu.ToString() : PanelClasses.PanelCategory.Scanner.ToString(); } } return retVal; }
/// <summary> /// Initializes the widget manager. Load the widget layout, /// set the color scheme and get the root widget object /// </summary> private bool initWidgetManager() { _widgetManager = new WidgetManager(_form); _widgetManager.Layout.SetColorScheme(ColorSchemes.DialogSchemeName); bool retVal = _widgetManager.Initialize(getConfigFile()); if (!retVal) { Log.Error("Unable to initialize widget manager"); } else { _rootWidget = _widgetManager.RootWidget; if (String.IsNullOrEmpty(_rootWidget.SubClass)) { _rootWidget.SubClass = PanelClasses.PanelCategory.Dialog.ToString(); } } return retVal; }
/// <summary> /// Initialize the widget manager /// </summary> private bool initWidgetManager() { _widgetManager = new WidgetManager(this); var configFile = PanelConfigMap.GetConfigFileForScreen(this.GetType()); var retVal = _widgetManager.Initialize(configFile); if (!retVal) { Log.Error("Unable to initialize widget manager"); } else { _rootWidget = _widgetManager.RootWidget; } return retVal; }