Exemplo n.º 1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            TemplateNameComboBox.Items.Clear();
            string           model     = PrintModelComboBox.Text.Trim();
            TemplateCore     core      = new TemplateCore();
            IList <Template> templates = core.GetAllTemplate();

            foreach (Template temp in templates)
            {
                if (temp.PrintSetting != null && temp.PrintSetting.PrintModule == model && (voucher == (temp.Template_Type == TemplateType.Vouch)))
                {
                    TemplateObj obj = new TemplateObj(temp);
                    TemplateNameComboBox.Items.Add(obj);
                }
            }
            if (TemplateNameComboBox.Items.Count != 0)
            {
                TemplateNameComboBox.SelectedIndex = 0;
            }
        }
Exemplo n.º 2
0
        private void TemplateNameComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            TemplateObj templateObj = TemplateNameComboBox.SelectedItem as TemplateObj;

            template = templateObj.Template;
            //printPreviewControl1.Width = (int)MillimetersToPixelsWidth(template.Background.ImageWidth);
            //printPreviewControl1.Height = (int)MillimetersToPixelsWidth(template.Background.ImageHeight);

            printPreviewControl1.Document = printDocument1;
            // printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("123", (int)(template.Background.ImageWidth/2.54), (int)(template.Background.ImageHeight/2.54));
            if (!voucher)
            {
                printDocument1.DefaultPageSettings.PaperSize = new PaperSize("comaond", 433, 219);
            }
            else
            {
                printDocument1.DefaultPageSettings.PaperSize = new PaperSize("comaond", (int)(template.Background.ImageWidth / 2.54), (int)(template.Background.ImageHeight / 2.54));
            }
            this.model = CreateDemoTemplatePrintModel();
            //printDocument1.Print();
            printDocument1.PrinterSettings.PrinterName = template.PrintSetting.PrintModule;
            printPreviewControl1.InvalidatePreview();
        }