Пример #1
0
        public void Start()
        {
            ToPrint.Print("");
            ConstantExpression   expA    = Expression.Constant(30.0d);
            MethodCallExpression expCall = Expression.Call(null, typeof(Math).GetMethod("Sin", BindingFlags.Static | BindingFlags.Public), expA);

            ToPrint.Print(expCall.ToString());
            Console.ReadKey();
        }
Пример #2
0
 public void Run()
 {
     try
     {
         tp           = new ToPrint(new Font("宋体", 8, FontStyle.Regular), new Font("幼圆", 20, FontStyle.Bold));
         tp.Landscape = Convert.ToBoolean(ClsCommon.Landscape);//纸张横向
         recodePrintMessage("初始化打印成功......", 0);
     }
     catch (Exception ex)
     {
         printalarmType(72);
         recodePrintMessage("初始化打印失败......" + ex.Message, 1);
     }
 }
Пример #3
0
        /// <summary>
        /// prints into the current line, absolute x position with width and alignment
        /// </summary>
        /// <returns>true if something was printed
        /// </returns>
        public override bool PrintString(String ATxt, eFont AFont, float AXPos, float AWidth, eAlignment AAlign)
        {
            String ToPrint;

            System.Int32 XPos;

            if ((ATxt == null) || (ATxt.Length == 0))
            {
                return(false);
            }

            ToPrint = GetFittedText(ATxt, AFont, AWidth);

            // eDefault
            XPos = Convert.ToInt32(AXPos);

            switch (AAlign)
            {
            case eAlignment.eCenter:
                XPos = Convert.ToInt32(AXPos) + (Convert.ToInt32(AWidth) - ToPrint.Length) / 2;
                break;

            case eAlignment.eLeft:
                XPos = Convert.ToInt32(AXPos);
                break;

            case eAlignment.eRight:

                if (Convert.ToInt32(AWidth) > ToPrint.Length)
                {
                    XPos = Convert.ToInt32(AXPos) + Convert.ToInt32(AWidth) - ToPrint.Length;
                }
                else
                {
                    XPos = Convert.ToInt32(AXPos);
                }

                break;
            }

            if (ToPrint.Length > Convert.ToInt32(AWidth))
            {
                ToPrint = ToPrint.Substring(0, Convert.ToInt32(AWidth));
            }

            Print(XPos, Convert.ToInt32(CurrentYPos), ToPrint);
            return(true);
        }
Пример #4
0
        public static void Save(MainViewModel viewModel, string path)
        {
            using (XpsDocument xpsdoc = new XpsDocument(path, FileAccess.Write))
            {
                XpsDocumentWriter    xpsdw   = XpsDocument.CreateXpsDocumentWriter(xpsdoc);
                VisualsToXpsDocument vToXpsD = (VisualsToXpsDocument)xpsdw.CreateVisualsCollator();

                var fixedDoc = new FixedDocument();

                var objReportToPrint = new ToPrint();

                var ReportToPrint = objReportToPrint as UserControl;
                ReportToPrint.DataContext = viewModel;

                vToXpsD.Write(ReportToPrint);
                vToXpsD.EndBatchWrite();
            }
        }
Пример #5
0
        public static void Print(MainViewModel viewModel)
        {
            //Set up the WPF Control to be printed

            var fixedDoc = new FixedDocument();

            var objReportToPrint = new ToPrint();

            var ReportToPrint = objReportToPrint as UserControl;

            ReportToPrint.DataContext = viewModel;

            var pageContent = new PageContent();
            var fixedPage   = new FixedPage();

            //Create first page of document
            fixedPage.Children.Add(ReportToPrint);
            ((IAddChild)pageContent).AddChild(fixedPage);
            fixedDoc.Pages.Add(pageContent);

            SendFixedDocumentToPrinter(fixedDoc);
        }
Пример #6
0
        private void imprimir_Click(object sender, EventArgs e)
        {
            int i = 0;


            if (nomeArch.Text == null || nomeArch.Text == "")
            {
                nomeArch.Focus();
                nomeArquivoLabel.Text = "É PRECISO SELECIONAR UM NOME";
            }
            else if (pictureBox1.Image == null)
            {
                CabecalhoTxt.Text = "É PRECISO SELECIONAR UM CABECALHO!";
                header.Focus();
            }
            else
            {
                folderBrowserDialog1.ShowDialog();
                var     path        = folderBrowserDialog1.SelectedPath.ToString() + "/";
                var     archiveName = nomeArch.Text + ".pdf";
                var     output      = path + archiveName;
                ToPrint print       = new ToPrint();

                print.imprimir(pictureBox1.Image, output, con, listBox2.Items, doc);
                pictureBox1.Image = null;
                nomeArch.Text     = null;
                CabecalhoTxt.Text = "Cabecalho Não Selecionado.";

                while (listBox2.Items.Count > i)
                {
                    listBox1.Items.Add(listBox2.Items[i]);

                    i++;
                }

                listBox2.Items.Clear();
            }
        }