using GrapeCity.ActiveReports;
using GrapeCity.ActiveReports.Document;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinformQuietPrint
{
    public partial class Form1 : Form
    {
        private PageDocument _document;
        public Form1()
        {
            InitializeComponent();
            //this.viewer1.Sidebar.Visible = true;
            //GrapeCity.ActiveReports.PageReport rpt1 = new GrapeCity.ActiveReports.PageReport(new FileInfo(@"RdlReport1.rdlx"));
            //rpt1.Document.LocateDataSource += new LocateDataSourceEventHandler(LocateData);
            //viewer1.LoadDocument(rpt1.Document);
        }
        private void tsbPrint_Click(object sender, EventArgs e)
        {
            //string file_name = @"..\..\RdlReport1.rdlx";
            //GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(file_name));
            //pageReport.Document.LocateDataSource += new LocateDataSourceEventHandler(LocateData);
            //this._document = pageReport.Document;
            //GrapeCity.ActiveReports.PrintExtension.Print(_document, true, true);
        }
        //    private void LocateData(object sender, LocateDataSourceEventArgs args)
        //    {
        //        #region
        //        if (args.DataSourceName == "DataSource1")
        //        {
        //            if (args.DataSetName == "DataSet1")
        //            {
        //                List<FormData> data = new List<FormData>();
        //                for (int i = 1; i <= 3; i++)
        //                {
        //                    for (int j = 1; j <= 5; j++)
        //                    {
        //                        for (int k = 1; k <= 2; k++)
        //                        {
        //                            data.Add(new FormData()
        //                            {
        //                                Main = i + "CM主控制器",
        //                                Sub = "T-80" + i + j + "子控制器",
        //                                Variable = "T-80" + i + j + k + ".PV",
        //                                Type = "CV投用情况",
        //                                Active = 0 + (i + j + k) % 2,
        //                                Value = (95 - i / 10.0 + j / 10.0 + k / 100.0) / 100.0
        //                            });
        //                        }
        //                    }
        //                }
        //                args.Data = data;
        //            }
        //        }
        //        #endregion
        //        #region
        //        if (args.DataSourceName == "DataSource2")
        //        {
        //            if (args.DataSetName == "DataSet2")
        //            {
        //                List<TimeInfo> info = new List<TimeInfo>();
        //                info.Add(new TimeInfo() { Type = "开始时间", Value = Convert.ToDateTime("22/08/2017 09:00:00") });
        //                info.Add(new TimeInfo() { Type = "结束时间", Value = Convert.ToDateTime("22/08/2017 10:00:00") });
        //                info.Add(new TimeInfo() { Type = "CV投用指标", Value = 0.95 });
        //                args.Data = info;
        //            }
        //        }
        //        #endregion
        //        #region
        //        if (args.DataSourceName == "DataSource3")
        //        {
        //            if (args.DataSetName == "DataSet3")
        //            {
        //                List<Operate> operate = new List<Operate>();
        //                operate.Add(new Operate() { Number = 1, Type = "SVCTL61", Count = 838 });
        //                operate.Add(new Operate() { Number = 2, Type = "SVCTL64", Count = 226 });
        //                operate.Add(new Operate() { Number = 3, Type = "SVCTL23", Count = 222 });
        //                operate.Add(new Operate() { Number = 4, Type = "SVCTL55", Count = 37 });
        //                operate.Add(new Operate() { Number = 5, Type = "SVCTL63", Count = 35 });
        //                operate.Add(new Operate() { Number = 6, Type = "SVCTL01", Count = 30 });
        //                operate.Add(new Operate() { Number = 7, Type = "SVCTL14", Count = 29 });
        //                operate.Add(new Operate() { Number = 8, Type = "SVCTL25", Count = 27 });
        //                operate.Add(new Operate() { Number = 9, Type = "SVCTL02", Count = 26 });
        //                operate.Add(new Operate() { Number = 10, Type = "SVCTL54", Count = 20 });
        //                operate.Add(new Operate() { Number = 11, Type = "其他", Count = 969 });
        //                args.Data = operate;
        //            }
        //        }
        //        #endregion
        //    }
        //}
        //public class FormData
        //{
        //    public string Main { get; set; }
        //    public string Sub { get; set; }
        //    public string Variable { get; set; }
        //    public string Type { get; set; }
        //    public double Active { get; set; }
        //    public double Value { get; set; }
        //}

        //public class TimeInfo
        //{
        //    public string Type { get; set; }
        //    public object Value { get; set; }
        //}

        //public class Operate
        //{
        //    public int Number { get; set; }
        //    public string Type { get; set; }
        //    public int Count { get; set; }
        //}

    }
}