Facebook
From rozaq, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 266
  1. program.cs
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7.  
  8. namespace Chapter3._1
  9. {
  10.     static class Program
  11.     {
  12.         /// <summary>
  13.         /// The main entry point for the application.
  14.         /// </summary>
  15.         [STAThread]
  16.         static void Main()
  17.         {
  18.             Application.EnableVisualStyles();
  19.             Application.SetCompatibleTextRenderingDefault(false);
  20.             Application.Run(new Form1());
  21.         }
  22.     }
  23. }
  24.  
  25. QRManager.cs
  26. using System;
  27. using System.Collections.Generic;
  28. using System.Linq;
  29. using System.Text;
  30. using System.Threading.Tasks;
  31. using System.Windows.Forms;
  32. using System.Drawing;
  33. using QRCoder;
  34.  
  35. namespace Chapter3._1
  36. {
  37.     class QRManager
  38.     {
  39.         public static void TukarInfo(ref TextBox textBox1, ref TextBox textBox2)
  40.         {
  41.             string temp = textBox1.Text;
  42.             textBox1.Text = textBox2.Text;
  43.             textBox2.Text = temp;
  44.         }
  45.  
  46.         public static string GenerateInfo(string namaAsal, string alamatAsal, string NoHpAsal, string namaTujuan, string alamatTujuan, string NoHpTujuan)
  47.         {
  48.             string result = "#" + namaAsal + "*" + alamatAsal + "*" + NoHpAsal + "*" + namaTujuan + "*" + alamatTujuan + "*" + NoHpTujuan;
  49.             return result;
  50.         }
  51.  
  52.         public static string GenerateInfo(string namaAsal, string alamatAsal, string NoHpAsal, string namaTujuan, string alamatTujuan, string NoHpTujuan, out Bitmap QrBitmap)
  53.         {
  54.             string text = GenerateInfo(namaAsal, alamatAsal, NoHpAsal, namaTujuan, alamatTujuan, NoHpTujuan);
  55.  
  56.             QRCodeGenerator qrGenerator = new QRCodeGenerator();
  57.             QRCodeData qrCodeData = qrGenerator.CreateQrCode(text, QRCodeGenerator.ECCLevel.Q);
  58.             QRCode qrCode = new QRCode(qrCodeData);
  59.             QrBitmap = qrCode.GetGraphic(20);
  60.  
  61.             return text;
  62.         }
  63.     }
  64. }
  65.  
  66. Form1.cs
  67. using System;
  68. using System.Collections.Generic;
  69. using System.ComponentModel;
  70. using System.Data;
  71. using System.Drawing;
  72. using System.Linq;
  73. using System.Text;
  74. using System.Threading.Tasks;
  75. using System.Windows.Forms;
  76.  
  77. namespace Chapter3._1
  78. {
  79.     public partial class Form1 : Form
  80.     {
  81.         public Form1()
  82.         {
  83.             InitializeComponent();
  84.         }
  85.  
  86.         private void btTukar_Click(object sender, EventArgs e)
  87.         {
  88.             QRManager.TukarInfo(ref tbNamaPenerima, ref tbNamaPengirim);
  89.             QRManager.TukarInfo(ref tbAlamatAsal, ref tbAlamatTujuan);
  90.             QRManager.TukarInfo(ref tbHpPenerima, ref tbHpPengirim);
  91.         }
  92.  
  93.         private void btProses_Click(object sender, EventArgs e)
  94.         {
  95.             Bitmap qr;
  96.             tbQrText.Text = QRManager.GenerateInfo(
  97.                 tbNamaPengirim.Text,
  98.                 tbAlamatAsal.Text,
  99.                 tbHpPengirim.Text,
  100.                 tbNamaPenerima.Text,
  101.                 tbAlamatTujuan.Text,
  102.                 tbHpPenerima.Text,
  103.                 out qr);
  104.             pbQR.BackgroundImage = qr;
  105.         }
  106.     }
  107. }
  108.