12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using CollaborativePlatformMain.DFEntity;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Media;
- namespace CollaborativePlatformMain.Util
- {
- /// <summary>
- ///
- /// <para>文件名(File Name): CollaborationUtil.cs</para>
- ///
- /// <para>描述(Description): 协同窗体后台工具类</para>
- ///
- /// <para>数据表(Tables): nothing</para>
- ///
- /// <para>作者(Author): Ou Rui Song</para>
- ///
- /// <para>日期(Create Date): 2024年4月20日15:24:29</para>
- ///
- /// 修改记录(Revision History):
- /// R1:
- /// 修改作者:
- /// 修改日期:
- /// 修改理由:
- ///
- /// </summary>
- public class CollaborationUtil
- {
- /// <summary>
- /// 获得指定元素的所有子元素
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="obj"></param>
- /// <returns></returns>
- public static List<T> GetChildObjects<T>(DependencyObject obj) where T : FrameworkElement
- {
- DependencyObject child = null;
- List<T> childList = new List<T>();
- for (int i = 0; i <= VisualTreeHelper.GetChildrenCount(obj) - 1; i++)
- {
- child = VisualTreeHelper.GetChild(obj, i);
- if (child is T)
- {
- childList.Add((T)child);
- }
- childList.AddRange(GetChildObjects<T>(child));
- }
- return childList;
- }
- /// <summary>
- /// 获取名字在集合中的下标
- /// </summary>
- /// <param name="name"></param>
- /// <param name="treeViews"></param>
- /// <returns></returns>
- public static int GetIndexByTreeView(string name, List<TreeViewBind> treeViews)
- {
- for (int i = 0; i < treeViews.Count; i++)
- {
- if (treeViews[i].Name.Equals(name))
- {
- return i;
- }
- }
- return -1;
- }
- }
- }
|