]> git.llucax.com Git - z.facultad/75.10/miklolife.git/commitdiff
* Mas generizacion
authorRicardo Markiewicz <gazer.arg@gmail.com>
Tue, 21 Jun 2005 04:01:56 +0000 (04:01 +0000)
committerRicardo Markiewicz <gazer.arg@gmail.com>
Tue, 21 Jun 2005 04:01:56 +0000 (04:01 +0000)
demo/src/Vistas/ABMGenerico.cs

index 3471b20e2b9b791cf36bc8926980790da64b9d1c..4e185db27d25285f88065b3c26e8fb064dc7d5f6 100644 (file)
@@ -9,26 +9,65 @@ public class ABMGenerico
 {
        Glade.XML xml;
        [Widget] Table tabla;
+       Type current;
 
        public ABMGenerico (Type objectType)
        {
                PropertyInfo[] properties = objectType.GetProperties ();
+               current = objectType;
                
                xml = new Glade.XML (null, "abm_generico.glade", "abm_one", null);
                xml.Autoconnect (this);
 
                uint i=0;
                foreach( PropertyInfo mf in properties ) {
-                       Label l = new Label (mf.Name + " : ");
-                       Entry e = new Entry ();
-                       tabla.Attach (l, 0, 1, i, i+1);
-                       tabla.Attach (e, 1, 2, i, i+1);
-                       l.Show ();
-                       e.Show ();
+                       Widget l = GetWidget (mf);
+                       if (l != null) {
+                               tabla.Attach (l, 0, 1, i, i+1);
+                               Entry e = new Entry ();
+                               tabla.Attach (e, 1, 2, i, i+1);
+                               l.Show ();
+                               e.Show ();
+                       }
                        i++;
                }
        }
 
+       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; 
+       }
+
        public void Run ()
        {
                Dialog w = (Dialog)xml.GetWidget ("abm_one");