示例#1
0
文件: MainView.cs 项目: hol353/ApsimX
 // Is there a better way?
 /// <summary>
 /// Helper function for dealing with clicks on the tab labels, or whatever
 /// widgets the tab label might control. Tests to see which tab the 
 /// indicated objects is on. This lets us identify the tabs associated
 /// with click events, for example.
 /// </summary>
 /// <param name="o">The widget that we are seaching for</param>
 /// <returns>Page number of the tab, or -1 if not found</returns>
 private int GetTabOfWidget(object o, ref Notebook notebook, ref string tabName)
 {
     tabName = null;
     Widget widg = o as Widget;
     if (widg == null)
         return -1;
     notebook = IsControlOnLeft(o) ? notebook1 : notebook2;
     for (int i = 0; i < notebook.NPages; i++)
     {
         // First check the tab labels
         Widget testParent = notebook.GetTabLabel(notebook.GetNthPage(i));
         if (testParent == widg || widg.IsAncestor(testParent))
         {
             tabName = notebook.GetTabLabelText(notebook.GetNthPage(i));
             return i;
         }
         // If not found, check the tab contents
         testParent = notebook.GetNthPage(i);
         if (testParent == widg || widg.IsAncestor(testParent))
         {
             tabName = notebook.GetTabLabelText(notebook.GetNthPage(i));
             return i;
         }
     }
     return -1;
 }