private CodeMemberMethod CreateSignalHandler(Widget widget, Signal signal) { CodeMemberMethod handler = new CodeMemberMethod(); handler.Name = signal.Handler; // TODO: Fix Util.ConvertSignal so we can switch this back!! //MethodInfo invokeInfo = Type.GetType("System.EventHandler").GetMethod("Invoke"); MethodInfo invokeInfo = signal.GetEventHandlerType().GetMethod("Invoke"); foreach (ParameterInfo parm in invokeInfo.GetParameters()) { handler.Parameters.Add(new CodeParameterDeclarationExpression(parm.ParameterType.FullName, parm.Name)); } handler.Statements.Add(new CodeCommentStatement("TODO: Write code to handle the " + signal.Name + " event here.")); return handler; }
private void ParseNode(Widget parentWindow, XmlNode node) { foreach (XmlNode child in node.ChildNodes) { if (child.Name == "widget") { string widgetClass = child.Attributes["class"].Value; string widgetName = child.Attributes["id"].Value; Widget widget = new Widget(widgetClass, widgetName); // if (widgetClass == "GtkWindow" | widgetClass == "GtkMenu" | widgetClass == "GnomeApp" | widgetClass.EndsWith("Dialog") ) { if (child.ParentNode.Name == "glade-interface") { widgets.Add(widget); parentWindow = widget; } else { parentWindow.Widgets.Add(widget); } lastWidget = widget; } else if (child.Name == "signal") { string signalName = child.Attributes["name"].Value; string signalHandler = child.Attributes["handler"].Value; lastWidget.Signals.Add(new Signal(lastWidget, signalName, signalHandler)); } ParseNode(parentWindow, child); } }
public Signal(Widget parentWidget, string name, string handler) { this.name = name; this.handler = handler; this.widget = parentWidget; }