Пример #1
0
        //导出图片
        private void btnExportImg_Click(object sender, RoutedEventArgs e)
        {
            MyTreeNode node = GetSelectedNode();

            ExportIMG.SaveNode2Image(this, node);
            WindowView.Refresh_Online_time();
        }
Пример #2
0
        //导出图片
        private void btnExportImg_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFileDlg = new SaveFileDialog();

            saveFileDlg.Title    = "选择将节点信息导出为文件的位置";
            saveFileDlg.Filter   = "png格式|*.png";
            saveFileDlg.FileName = grpNodeInfo.Header.ToString().Split(new String[] { " - " }, StringSplitOptions.None)[1];
            if (saveFileDlg.ShowDialog() == true)
            {
                ExportIMG.SaveImage(mainContent, saveFileDlg.FileName);
            }
        }
Пример #3
0
        private static void ExportImg(MyTreeView mytreeview, MyTreeNode node)
        {
            mytreeview.SetRootNode(node);
            //如果全部子节点数量小于50,则直接全部打开
            if (node.ChildrenCountAll < 50)
            {
                mytreeview.ExpandRootNode(node.ChildrenLevels);
            }
            else
            {
                //已打开的节点数量
                int expNodeCount = node.ChildrenCount;

                //这个循环用于防止出现大量的上下级只有一个子节点的情况导致打开节点数量过少
                TreeViewItem rootItem = mytreeview.memberTreeView.Items[0] as TreeViewItem;
                MyTreeNode   rootNode = rootItem.Tag as MyTreeNode;
                while (rootNode.ChildrenCount == 1)
                {
                    mytreeview.ExpandNode(rootItem, 1);
                    rootItem = rootItem.Items[0] as TreeViewItem;
                    rootNode = rootItem.Tag as MyTreeNode;
                    expNodeCount++;
                }

                //打开一级子节点,再逐个判断数量
                mytreeview.ExpandNode(rootItem, 1);

                foreach (TreeViewItem subItem in rootItem.Items)
                {
                    MyTreeNode subNode = subItem.Tag as MyTreeNode;
                    if (subNode.ChildrenCountAll > 0)
                    {
                        if (subNode.ChildrenCountAll < 10 || subNode.ChildrenCountAll + expNodeCount < 50)
                        {                        //如果全部子节点数量小于10,或者全部子节点数量加上已打开的节点数量小于50,则该子节点全部打开
                            mytreeview.ExpandNode(subItem, subNode.ChildrenLevels);
                            expNodeCount += subNode.ChildrenCountAll;
                        }
                        else if (subNode.ChildrenCount + expNodeCount < 50)
                        {                        //如果则该节点一级子节点数量加上已打开的节点数量小于50,则该子节点打开子一级节点
                            mytreeview.ExpandNode(subItem, 1);
                            expNodeCount += subNode.ChildrenCount;
                            //遍历孙子节点
                            foreach (TreeViewItem grandItem in subItem.Items)
                            {
                                MyTreeNode grandNode = grandItem.Tag as MyTreeNode;
                                if (grandNode.ChildrenCountAll < 10 || grandNode.ChildrenCountAll + expNodeCount < 50)
                                {
                                    mytreeview.ExpandNode(grandItem, grandNode.ChildrenLevels);
                                    expNodeCount += grandNode.ChildrenCountAll;
                                }
                                else
                                {
                                    exportNodes.Add(grandNode);
                                }
                            }
                        }
                        else
                        {                        //如果全部子节点数量加上已打开的节点数量大于50,则该子节点不打开
                            exportNodes.Add(subNode);
                        }
                    }
                }
            }
            exportNodes.Remove(node);
            WindowView.notify.SetStatusMessage("正在导出图片" + node.SysId);
            ExportIMG.SaveImage(mytreeview.memberTreeView, MemData.MemDataTemp + "/" + node.SysId + ".png");
        }
Пример #4
0
        //导出图片
        private void btnExportImg_Click(object sender, RoutedEventArgs e)
        {
            MyTreeNode node = GetSelectedNode();

            ExportIMG.SaveNode2Image(this, node);
        }