+ private Widget GetWidget (PropertyInfo mf)
+ {
+ Widget w = null;
+ if (mf.PropertyType.Equals (typeof(string))
+ || mf.PropertyType.Equals (typeof(int))
+ || mf.PropertyType.Equals (typeof(float))) {
+ Label l = new Label (GetLabel (mf.Name) + " : ");
+ l.Justify = Justification.Left;
+ l.Xpad = 0;
+ l.Xalign = 0;
+ w = l;
+ }
+ return w;
+ }
+
+ private string GetLabel (string name)
+ {
+ int i = 0;
+ string s = (string)name.Clone ();
+ while (i < s.Length) {
+ if (Char.IsUpper(s[i]) && (i>0)) {
+ s = s.Insert (i, " ");
+ i++;
+ }
+ i++;
+ }
+ return s;
+ }
+
+ public void OnDialogResponse (object o, ResponseArgs args)
+ {
+ if (args.ResponseId == ResponseType.Cancel)
+ return;
+
+ PropertyInfo[] properties = current.GetProperties ();
+
+ System.Object output = Activator.CreateInstance (current);
+
+ foreach (string key in widgets.Keys) {
+ PropertyInfo p = current.GetProperty (key);
+ Entry e = (Entry)widgets[key];
+ Console.WriteLine ("{0} = {1}", key, e.Text);
+ if (p.PropertyType.Equals (typeof(string)))
+ p.SetValue (output, e.Text, null);
+ if (p.PropertyType.Equals (typeof(int)))
+ p.SetValue (output, Int32.Parse (e.Text), null);
+ if (p.PropertyType.Equals (typeof(float))) {
+ p.SetValue (output, (float)Double.Parse (e.Text), null);
+ }
+ }
+
+ Controller c = new Controller ();
+
+ c.GenericSave (output);
+
+ c.Dispose ();
+ }
+
+ public void Run (string title)