基本信息
源码名称:wpf,c#,流文档打印以及打印浏览
源码大小:0.48M
文件格式:.zip
开发语言:C#
更新时间:2018-04-11
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍
:wpf打印实例


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Printing;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using HappyPrint;

namespace PrintHelperTestDemo
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window, INotifyPropertyChanged
    {
        private double _btnHeight;

        public MainWindow()
        {
            InitializeComponent();

            this.DataContext = this;
        }

        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            DataTable dt = new DataTable("PrintHelper");

            DataColumn column;

            for (int i = 0; i < 2; i  )
            {
                column = new DataColumn(string.Format("控制器{0}", i));

                dt.Columns.Add(column);
            }

            for (int i = 0; i < 1000; i  )
            {
                var row = dt.NewRow();

                for (int j = 0; j < dt.Columns.Count; j  )
                {
                    if (j % 2 == 0)
                    {
                        row[string.Format("控制器{0}", j)] = i   "探测器为了增加字符串长度而是用的"   j;
                    }
                    else
                    {
                        row[string.Format("控制器{0}", j)] = i   "探测器"   j;
                    }
                }

                dt.Rows.Add(row);
            }

            PrintHelper.PrintDataTable(dt);
        }

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName = null)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyName));
        }

        private void ButtonBase2_OnClick(object sender, RoutedEventArgs e)
        {
            BitmapImage bitmapImage = new BitmapImage(new Uri("test.jpg", UriKind.RelativeOrAbsolute));

            PrintHelper.PrintPicture(bitmapImage);
        }

        private void ButtonBase3_OnClick(object sender, RoutedEventArgs e)
        {
            PrintHelper.PrintControl(window);
        }
    }
}