Step 1: Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "QRCode" and then click OK
Step 2: Right click on your project select Manage NuGet Packages -> Search qrcode -> Install
Step 3: Design your form as below

Step 4: Add code to handle your form
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnEncode_Click(object sender, EventArgs e)
{
using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "JPEG|*.jpg", ValidateNames = true })
{
if (sfd.ShowDialog() == DialogResult.OK)
{
//Encode qrcode, then save image
MessagingToolkit.QRCode.Codec.QRCodeEncoder encoder = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();
encoder.QRCodeScale = 8;
Bitmap bmp = encoder.Encode(txtEncode.Text);
pictureBox.Image = bmp;
bmp.Save(sfd.FileName, ImageFormat.Jpeg);
}
}
}
private void btnDecode_Click(object sender, EventArgs e)
{
using (OpenFileDialog ofd = new OpenFileDialog() { Filter = "JPEG|*.jpg", ValidateNames = true, Multiselect = false })
{
if (ofd.ShowDialog() == DialogResult.OK)
{
//Decode qrcode from image
pictureBox.Image = Image.FromFile(ofd.FileName);
MessagingToolkit.QRCode.Codec.QRCodeDecoder decoder = new MessagingToolkit.QRCode.Codec.QRCodeDecoder();
txtDecode.Text = decoder.Decode(new QRCodeBitmapImage(pictureBox.Image as Bitmap));
}
}
}
VIDEO TUTORIALS