Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Drawing.Imaging;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. //using System.Console;
  12.  
  13. namespace Kody
  14. {
  15.     public partial class Generator : Form
  16.     {
  17.         public Generator()
  18.         {
  19.             InitializeComponent();
  20.         }
  21.  
  22.         private void label1_Click(object sender, EventArgs e)
  23.         {
  24.  
  25.         }
  26.  
  27.         private void txtBarcode_TextChanged(object sender, EventArgs e)
  28.         {
  29.  
  30.         }
  31.         private void load_Click(object sender, EventArgs e)
  32.         {
  33.             string[] lines = System.IO.File.ReadAllLines("C:/Users/lab/Desktop/123.txt");
  34.             foreach (string line in lines) {
  35.                 System.Console.WriteLine(line);
  36.  
  37.                 Zen.Barcode.CodeEan13BarcodeDraw barcode = Zen.Barcode.BarcodeDrawFactory.CodeEan13WithChecksum;
  38.                 if (line.Length == 12)
  39.                 {
  40.                     pictureBox1.Image = barcode.Draw(line, 100, 2);
  41.                 }
  42.                
  43.             }
  44.            
  45.         }
  46.        
  47.         private void btnBarcode_Click(object sender, EventArgs e)
  48.         {
  49.             Zen.Barcode.CodeEan13BarcodeDraw barcode = Zen.Barcode.BarcodeDrawFactory.CodeEan13WithChecksum;
  50.             if (txtBarcode.TextLength == 12)
  51.             {
  52.                 pictureBox1.Image = barcode.Draw(txtBarcode.Text, 100, 2);
  53.             }
  54.             else
  55.             {
  56.                 MessageBox.Show("Podaj 12 cyfr");
  57.             }
  58.         }
  59.  
  60.         private void pictureBox1_Click(object sender, EventArgs e)
  61.         {
  62.  
  63.         }
  64.         private void myPrintDocument2_PrintPage(System.Object sender, System.Drawing.Printing.PrintPageEventArgs e)
  65.  
  66.         {
  67.  
  68.             Bitmap myBitmap1 = new Bitmap(pictureBox1.Width, pictureBox1.Height);
  69.  
  70.             pictureBox1.DrawToBitmap(myBitmap1, new Rectangle(0, 0, pictureBox1.Width*2, pictureBox1.Height));
  71.  
  72.             e.Graphics.DrawImage(myBitmap1, 0, 0);
  73.  
  74.             myBitmap1.Dispose();
  75.  
  76.         }
  77.  
  78.         private void btnPrint_Click(object sender, EventArgs e)
  79.         {
  80.            
  81.             System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();
  82.            
  83.             PrintDialog myPrinDialog1 = new PrintDialog();
  84.            
  85.             myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument2_PrintPage);
  86.  
  87.             myPrinDialog1.Document = myPrintDocument1;
  88.  
  89.  
  90.             if (myPrinDialog1.ShowDialog() == DialogResult.OK)
  91.  
  92.             {
  93.  
  94.                 myPrintDocument1.Print();
  95.  
  96.             }
  97.         }
  98.  
  99.         private void btnSave_Click(object sender, EventArgs e)
  100.         {
  101.             pictureBox1.Image.Save("kod_" + txtBarcode.Text + ".jpg");
  102.             MessageBox.Show("Zapisano plik " + "kod_" + txtBarcode.Text + ".jpg");
  103.  
  104.         }
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement