/[OhmsLawCalc]/trunk/OhmsLawCalc/Form1.cs
ViewVC logotype

Diff of /trunk/OhmsLawCalc/Form1.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/OhmsLawCalc/Form1.cs	2014/01/29 07:31:28	21
+++ trunk/OhmsLawCalc/Form1.cs	2014/01/29 07:57:25	22
@@ -118,7 +118,8 @@
                 var p = (c as ICalc);
                 if (p != null)
                 {
-                    var v = p.GetValue();
+                    OhmsLawValueType _type; //not used
+                    var v = p.GetValue(out _type);
                     if (v.Value != 0)
                     {
                         values.Add(v);
@@ -127,6 +128,42 @@
             }
             if (values.Count == 0) { return; }
             var result = OhmsLaw.CreateInstance(type, values);
+
+           ISetValue sv = GetResultControlForTabPage(tp);
+           if (sv != null)
+           {
+               sv.SetValue(result);
+           }
+        }
+
+        private ISetValue GetResultControlForTabPage(TabPage tp)
+        {
+            OhmsLawValueType type = OhmsLawValueType.None;
+            Control ctl = new Control();
+            if (tp.Tag != null)
+            {
+                type = (OhmsLawValueType)tp.Tag;
+            }
+            foreach (var c in tp.Controls)
+            {
+                var p = (c as ICalc);
+                if (p != null)
+                {
+                    OhmsLawValueType _type;
+                    var v = p.GetValue(out _type);
+                    if (_type == type)
+                    {
+                        ctl = (c as Control);
+                        break;
+                    }
+                }
+            }
+
+            if (ctl != null)
+            {
+                return (ctl as ISetValue);
+            }
+            return null;
         }
 
         private void Form1_Load(object sender, EventArgs e)

 

  ViewVC Help
Powered by ViewVC 1.1.22