예제 #1
0
        private TreeViewItem NewTreeViewItem(MyTreeNode node)
        {
            TreeViewItem item = new TreeViewItem();

            if (node == null)
            {
                item.Header  = "none";
                item.ToolTip = "none type node";
            }
            else if (node.SysId == "moreNode")
            {
                item.Header  = "双击加载更多节点";
                item.ToolTip = string.Format("双击加载更多{0}({1})的子节点,已加载节点数:{2},未加载节点数{3}",
                                             node.Name, node.TopId, node.ChildrenCount, node.ChildrenCountAll - node.ChildrenCount);
                item.Tag = node;
                item.MouseDoubleClick += moreNode_Load;
                item.Foreground        = new SolidColorBrush(Colors.Red);
            }
            else
            {
                item.Header  = node.Name;
                item.ToolTip = node.ToString();
                item.Tag     = node;
                if (node.ChildrenCount > 0)
                {
                    item.Expanded += item_Expanded;
                }
            }
            return(item);
        }
예제 #2
0
 internal static void SaveNode2Image(MyTreeView mytreeview, MyTreeNode node)
 {
     if (node == null)
     {
         MessageBox.Show("必须选中一个节点!");
     }
     else
     {
         SaveFileDialog saveFileDlg = new SaveFileDialog();
         saveFileDlg.Title    = "选择将会员树导出为文件的位置";
         saveFileDlg.Filter   = "png格式|*.png";
         saveFileDlg.FileName = node.ToString();
         if (saveFileDlg.ShowDialog() == true)
         {
             SaveImage(mytreeview.memberTreeView, saveFileDlg.FileName);
         }
     }
 }
예제 #3
0
        private TreeViewItem NewTreeViewItem(MyTreeNode node)
        {
            TreeViewItem item = new TreeViewItem();

            if (node == null)
            {
                item.Header  = "更多";
                item.ToolTip = "加载更多";
            }
            else
            {
                item.Header  = node.Name;
                item.ToolTip = node.ToString();
                item.Tag     = node;
                if (node.ChildrenCount > 0)
                {
                    item.Expanded += item_Expanded;
                }
            }
            return(item);
        }
예제 #4
0
        public static void ExportNodes(MyTreeNode node)
        {
            if (node == null)
            {
                MessageBox.Show("必须选中一个节点!");
                return;
            }
            SaveFileDialog saveFileDlg = new SaveFileDialog();

            saveFileDlg.Title = "选择将会员树导出为文件的位置";
//		    saveFileDlg.Filter = "CSV文件|*.csv|Excel2007文件|*.xlsx";
            saveFileDlg.Filter   = "CSV文件|*.csv";
            saveFileDlg.FileName = node.ToString();
            if (saveFileDlg.ShowDialog() == true)
            {
                if (File.Exists(saveFileDlg.FileName))
                {
                    File.Delete(saveFileDlg.FileName);
                }
                ExportCSV.Export2CSV(node, saveFileDlg.FileName);
            }
        }
예제 #5
0
//		private const string TMP_DIR = "temp";

        public static void Export2PDF(MyTreeView mytreeview, MyTreeNode node)
        {
            if (node == null)
            {
                MessageBox.Show("必须选中一个节点!");
                return;
            }
            // disable once SuggestUseVarKeywordEvident
            SaveFileDialog openfileDlg = new SaveFileDialog();

            openfileDlg.Title    = "选择将会员树导出为pdf文件的位置";
            openfileDlg.Filter   = "pdf文件|*.pdf";
            openfileDlg.FileName = node.ToString();
            if (openfileDlg.ShowDialog() == true)
            {
                TimingUtil.StartTiming();
                Directory.CreateDirectory(MemData.MemDataTemp);
                ExportAllImgs(mytreeview, node);

                //定义一个Document,并设置页面大小为A4,竖向
                //			Document doc = new Document(PageSize.A4);
                Document doc = new Document();
                PdfWriter.GetInstance(doc, new FileStream(openfileDlg.FileName, FileMode.Create));

                //设置PDF的头信息,一些属性设置,在Document.Open 之前完成
                doc.AddAuthor("TomChen");
                doc.AddCreationDate();
                doc.AddCreator("湖南警察学院");
                doc.AddSubject("将选中的会员树导出为PDF格式,如果数据量大,则导出为多张PDF页面");
                doc.AddTitle("将选中的会员树导出为PDF");
                doc.AddKeywords("会员树,会员层级,PDF");
                //自定义头
                //doc.AddHeader("Expires", "0");

                doc.Open();

                string[] imgfiles = Directory.GetFiles(MemData.MemDataTemp, "*.png");

                //首页
                //写入文字
                Paragraph paragraph = new Paragraph("ID:" + node.SysId, new Font(Font.FontFamily.TIMES_ROMAN, 30, 0, BaseColor.BLUE));
                doc.Add(paragraph);
                paragraph = new Paragraph("TopID:" + node.TopId, new Font(Font.FontFamily.TIMES_ROMAN, 30, 0, BaseColor.BLUE));
                doc.Add(paragraph);
                paragraph = new Paragraph("Level:" + node.Level, new Font(Font.FontFamily.TIMES_ROMAN, 30, 0, BaseColor.BLUE));
                doc.Add(paragraph);
                paragraph = new Paragraph("Sub1:" + node.ChildrenCount, new Font(Font.FontFamily.TIMES_ROMAN, 30, 0, BaseColor.BLUE));
                doc.Add(paragraph);
                paragraph = new Paragraph("SubLevel:" + node.ChildrenLevels, new Font(Font.FontFamily.TIMES_ROMAN, 30, 0, BaseColor.BLUE));
                doc.Add(paragraph);
                paragraph = new Paragraph("SubAll:" + node.ChildrenCount, new Font(Font.FontFamily.TIMES_ROMAN, 30, 0, BaseColor.BLUE));
                doc.Add(paragraph);
                paragraph = new Paragraph("----------------------------------------", new Font(Font.FontFamily.COURIER, 20, 0, BaseColor.GREEN));
                doc.Add(paragraph);
                paragraph = new Paragraph("Export pictures count:" + imgfiles.Length, new Font(Font.FontFamily.COURIER, 20, 0, BaseColor.GREEN));
                doc.Add(paragraph);

                WindowView.notify.SetProcessBarVisible(true);

                for (int i = 0; i < imgfiles.Length; i++)
                {
                    //写入图片
                    iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(imgfiles[i]);
                    doc.SetPageSize(new Rectangle(img.Width, img.Height));
                    //新建一页
                    doc.NewPage();
                    //img.ScaleAbsoluteWidth(PageSize.A4.Width);
                    //img.ScaleAbsoluteHeight(PageSize.A4.Height - 100);
                    //img.SetAbsolutePosition((PageSize.POSTCARD.Width - img.ScaledWidth) / 2, (PageSize.POSTCARD.Height - img.ScaledHeight) / 2);
                    doc.Add(img);
                    WindowView.notify.SetStatusMessage("正在生成PDF文件" + i + "/" + imgfiles.Length);
                    WindowView.notify.SetProcessBarValue(i * 100.0 / imgfiles.Length);
                }

                doc.Close();
                Directory.Delete(MemData.MemDataTemp, true);
                WindowView.notify.SetProcessBarVisible(false);
                WindowView.notify.SetStatusMessage(TimingUtil.EndTiming());
                MessageBox.Show("导出PDF完成!");
            }
        }