Znalazłem taki o to kod, do drukowania kodów paskowych. Wiem, że na tym forum jest wiele pasjonatów c# i innych języków programowania. Czy ktoś mógłby mi chociaż odrobinę okomendować ten kod? Jestem newbie, oraz nigdy nie pisałem nic w c#. Wystarczy mi w sumie kilka linijek, za co odpowiedzialne są funkcje itp.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace kody_paskowe
{
class PortControl // Import dll to project
{
[System.Runtime.InteropServices.DllImport("inpout32.dll", EntryPoint = "Out32")]
public static extern void Output(int address, int value); // decimal
}

public partial class Form1 : Form
{
    //left
    private int[] jedenOl = { 0, 0, 1, 1, 0, 0, 1 };
    private int[] jedenEl = { 0,1,1,0,0,1,1 };

    private int[] dwaOl = { 0,0,1,0,0,1,1 };
    private int[] dwaEl = { 0,0,1,1,0,1,1 };

    private int[] trzyOl = { 0,1,1,1,1,0,1 };
    private int[] trzyEl = { 0,1,0,0,0,0,1 };

    private int[] czteryOl = { 0,1,0,0,0,1,1 };
    private int[] czteryEl = { 0,0,1,1,1,0,1 };

    private int[] piecOl = { 0,1,1,0,0,0,1 };
    private int[] piecEl = { 0,1,1,1,0,0,1 };

    private int[] szescOl = { 0,1,0,1,1,1,1 };
    private int[] szescEl = { 0,0,0,0,1,0,1 };

    private int[] siedemOl = { 0,1,1,1,0,1,1 };
    private int[] siedemEl = { 0,0,1,0,0,0,1 };

    private int[] osiemOl = { 0,1,1,0,1,1,1 };
    private int[] osiemEl = { 0,0,0,1,0,0,1 };

    private int[] dziewiecOl = { 0,0,0,1,0,1,1 };
    private int[] dziewiecEl = { 0,1,0,0,1,1,1 };

    private int[] zeroOl = { 0, 0, 1, 1, 0, 0, 1 };
    private int[] zeroEl = { 0, 0, 1, 1, 0, 0, 1 };

    private int[] jedenR = { 1,1,1,0,0,1,0 };
    private int[] dwaR = { 1,1,0,1,1,0,0 };
    private int[] trzyR = { 1,0,0,0,0,1,0 };
    private int[] czteryR = { 1,0,1,1,1,0,0 };
    private int[] piecR = { 1,0,0,1,1,1,0 };
    private int[] szescR = { 1,0,1,0,0,0,0 };
    private int[] siedemR = { 1,0,0,0,1,0,0 };
    private int[] osiemR = { 1,0,0,1,0,0,0 };
    private int[] dziewiecR = { 1,1,1,0,1,0,0 };
    private int[] zeroR = { 1,1,1,0,0,1,0 };

    private int[] guard = { 1, 0, 1 };
    private int[] center = { 0, 1, 0, 1, 0 };

    private int x = 50;

    public Form1()
    {
        InitializeComponent();
    }

    private void drukuj_do_panelu(int[] kod)
    {
        Graphics g = panel1.CreateGraphics();
        Pen myPen = new Pen(Color.Black, 2);
        Pen myPenWhite = new Pen(Color.White, 2);
        foreach (int line in kod)
        {
            if (line == 1){
                Point myStartPoint = new Point(x, 0);
                Point myEndPoint = new Point(x, 150);
                if (kod.Length < 7) myEndPoint = new Point(x, 180);
                g.DrawLine(myPen, myStartPoint, myEndPoint);
            }
            else {
                Point myStartPoint = new Point(x, 0);
                Point myEndPoint = new Point(x, 150);
                if (kod.Length < 7) myEndPoint = new Point(x, 180);
                g.DrawLine(myPenWhite, myStartPoint, myEndPoint);
            }
            x += 2;
        }                           
    }

    private void button1_Click(object sender, EventArgs e)
    {
        x = 50;         

        string text = textBox1.Text;
        if (text.Length < 12) return;
        Graphics g = panel1.CreateGraphics();
        g.FillRectangle(Brushes.White, 0, 0, 500, 500);
        g.DrawString(text[0].ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x-20, 140);
        drukuj_do_panelu(guard);
        //left
        for (int i = 1; i <= 6; i++)
        {
            int num = Int32.Parse(text[i].ToString());
            switch (num)
            {
                case 1:
                    if (i % 2 != 0) drukuj_do_panelu(jedenOl);
                    else drukuj_do_panelu(jedenEl);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 2:
                    if (i % 2 != 0) drukuj_do_panelu(dwaOl);
                    else drukuj_do_panelu(dwaEl);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 3:
                    if (i % 2 != 0) drukuj_do_panelu(trzyOl);
                    else drukuj_do_panelu(trzyEl);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 4:
                    if (i % 2 != 0) drukuj_do_panelu(czteryOl);
                    else drukuj_do_panelu(czteryEl);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 5:
                    if (i % 2 != 0) drukuj_do_panelu(piecOl);
                    else drukuj_do_panelu(piecEl);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 6:
                    if (i % 2 != 0) drukuj_do_panelu(szescOl);
                    else drukuj_do_panelu(szescEl);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 7:
                    if (i % 2 != 0) drukuj_do_panelu(siedemOl);
                    else drukuj_do_panelu(siedemEl);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 8:
                    if (i % 2 != 0) drukuj_do_panelu(osiemOl);
                    else drukuj_do_panelu(osiemEl);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 9:
                    if (i % 2 != 0) drukuj_do_panelu(dziewiecOl);
                    else drukuj_do_panelu(dziewiecEl);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 0:
                    if (i % 2 != 0) drukuj_do_panelu(zeroOl);
                    else drukuj_do_panelu(zeroEl);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                default:
                    break;
            }
        }

        drukuj_do_panelu(center);

        ///checksum
        int sum = 0;
        int tmp = 0;
        int j = 0;
        foreach (char c in text)
        {
            if (j >= 12) break;
            tmp = Int32.Parse(c.ToString());
            if (j % 2 == 0) sum += tmp*3;
            else sum += tmp;
            j++;
        }

        //right
        for (int i = 7; i <=12; i++)
        {
            int num = 0;
            if (i == 12)
            {
                num = sum % 10;
            }
            else {
                num = Int32.Parse(text[i].ToString());
            }
            switch (num)
            {
                case 1:
                    drukuj_do_panelu(jedenR);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x-15, 160);
                    break;
                case 2:
                    drukuj_do_panelu(dwaR);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 3:
                    drukuj_do_panelu(trzyR);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 4:
                    drukuj_do_panelu(czteryR);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 5:
                    drukuj_do_panelu(piecR);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 6:
                    drukuj_do_panelu(szescR);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 7:
                    drukuj_do_panelu(siedemR);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 8:
                    drukuj_do_panelu(osiemR);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x -15, 160);
                    break;
                case 9:
                    drukuj_do_panelu(dziewiecR);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                case 0:
                    drukuj_do_panelu(zeroR);
                    g.DrawString(num.ToString(), new Font("Segoe UI Light", 9), Brushes.Black, x - 15, 160);
                    break;
                default:
                    break;
            }
        }
        drukuj_do_panelu(guard);           
        int decData = 0;
        int decAdd = 888; // 378h Selected Default
        PortControl.Output(decAdd, decData);
    }
}

}