private void InitUserSnippets()
        {
            XmlDocument doc  = new XmlDocument();
            var         path = App.LocalRPAStudioDir + @"\Config\CodeSnippets.xml";

            doc.Load(path);
            var rootNode = doc.DocumentElement;

            var directoryNodes = rootNode.SelectNodes("Directory");

            foreach (XmlNode dir in directoryNodes)
            {
                var dirPath = (dir as XmlElement).GetAttribute("Path");
                var id      = (dir as XmlElement).GetAttribute("Id");

                var userItem = new SnippetTreeItem();
                userItem.IsUserAdd  = true;//标识为用户添加
                userItem.Id         = id;
                userItem.Path       = dirPath;
                userItem.Name       = Path.GetFileName(dirPath);
                userItem.IsExpanded = true;

                SnippetsItems.Add(userItem);

                DirectoryInfo di = new DirectoryInfo(dirPath);
                InitGroup(di, userItem);
            }
        }
 private void SnippetTreeItemSetAllIsMatch(SnippetTreeItem item, bool IsMatch)
 {
     item.IsMatch = IsMatch;
     foreach (var child in item.Children)
     {
         SnippetTreeItemSetAllIsMatch(child, IsMatch);
     }
 }
 private void SnippetTreeItemSetAllSearchText(SnippetTreeItem item, string SearchText)
 {
     item.SearchText = SearchText;
     foreach (var child in item.Children)
     {
         SnippetTreeItemSetAllSearchText(child, SearchText);
     }
 }
 private void SnippetTreeItemSetAllIsSearching(SnippetTreeItem item, bool IsSearching)
 {
     item.IsSearching = IsSearching;
     foreach (var child in item.Children)
     {
         SnippetTreeItemSetAllIsSearching(child, IsSearching);
     }
 }
 private void SnippetTreeItemSetAllIsExpanded(SnippetTreeItem item, bool IsExpanded)
 {
     item.IsExpanded = IsExpanded;
     foreach (var child in item.Children)
     {
         SnippetTreeItemSetAllIsExpanded(child, IsExpanded);
     }
 }
        private void InitGroup(DirectoryInfo di, SnippetTreeItem parent = null)
        {
            //当前目录文件夹遍历
            DirectoryInfo[] dis = di.GetDirectories();
            for (int j = 0; j < dis.Length; j++)
            {
                var item = new SnippetTreeItem();
                item.Path = dis[j].FullName;
                item.Name = dis[j].Name;

                if (parent != null)
                {
                    parent.Children.Add(item);
                }
                else
                {
                    item.IsExpanded = true;//默认展开第一层
                    SnippetsItems.Add(item);
                }

                InitGroup(dis[j], item);
            }

            //当前目录文件遍历
            FileInfo[] fis = di.GetFiles();
            for (int i = 0; i < fis.Length; i++)
            {
                var item = new SnippetTreeItem();
                item.IsSnippet = true;
                item.Path      = fis[i].FullName;
                item.Name      = fis[i].Name;

                if (fis[i].Extension.ToLower() == ".xaml")
                {
                    if (parent != null)
                    {
                        parent.Children.Add(item);
                    }
                    else
                    {
                        SnippetsItems.Add(item);
                    }
                }
            }
        }
 private void RemoveSnippet(SnippetTreeItem obj)
 {
     initSnippets();
 }