|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
using static System.Windows.Forms.Form;
|
|
|
|
|
|
|
|
|
|
namespace Rs.Framework
|
|
|
|
|
{
|
|
|
|
|
public static class ControlManager
|
|
|
|
|
{
|
|
|
|
|
public static List<Control> GetControlList(Control findControl)
|
|
|
|
|
{
|
|
|
|
|
List<Control> list = GetContolsInternal(findControl, new List<Control>());
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<Control> GetContolsInternal(Control findControl,List<Control> foundControls)
|
|
|
|
|
{
|
|
|
|
|
if(findControl!=null && findControl.Controls.Count>0)
|
|
|
|
|
{
|
|
|
|
|
foreach (Control subControl in findControl.Controls)
|
|
|
|
|
{
|
|
|
|
|
foundControls.Add(subControl);
|
|
|
|
|
if(subControl.Controls.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foundControls= GetContolsInternal(subControl, foundControls);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return foundControls;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过控件Tag查找控件数组
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="findControl"></param>
|
|
|
|
|
/// <param name="tagName"></param>
|
|
|
|
|
/// <param name="searchAllChildren"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static Control[] FindByTag(Control findControl,string tagName, bool searchAllChildren)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(tagName))
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
ArrayList arrayList = FindInternal(tagName, searchAllChildren,findControl.Controls, new ArrayList());
|
|
|
|
|
Control[] array = new Control[arrayList.Count];
|
|
|
|
|
arrayList.CopyTo(array, 0);
|
|
|
|
|
return array;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static ArrayList FindInternal(string key, bool searchAllChildren, Control.ControlCollection controlsToLookIn, ArrayList foundControls)
|
|
|
|
|
{
|
|
|
|
|
if (controlsToLookIn == null || foundControls == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < controlsToLookIn.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (controlsToLookIn[i] != null && controlsToLookIn[i].Tag != null && string.Compare(controlsToLookIn[i].Tag.ToString(), key) == 0)
|
|
|
|
|
{
|
|
|
|
|
foundControls.Add(controlsToLookIn[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (searchAllChildren)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < controlsToLookIn.Count; j++)
|
|
|
|
|
{
|
|
|
|
|
if (controlsToLookIn[j] != null && controlsToLookIn[j].Controls != null && controlsToLookIn[j].Controls.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foundControls = FindInternal(key, searchAllChildren, controlsToLookIn[j].Controls, foundControls);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return foundControls;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return foundControls;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
return foundControls;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Control FindControl(Control control,string name)
|
|
|
|
|
{
|
|
|
|
|
Control[] controls = control.Controls.Find(name, true);
|
|
|
|
|
if(controls!=null&&controls.Length>0)
|
|
|
|
|
return controls[0];
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|