using System;

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

namespace TransparentLabel
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            #if DEBUG
                MinimizeBox = false;
            #else
                MinimizeBox = true;
            #endif
        }

        // Метод для вывода текста, использующий настройки элемента Label
        private void DrawLabel(Label label, Graphics g)
        {
            if (label.TextAlign == ContentAlignment.TopLeft)
            {

                g.DrawString(label.Text, label.Font, new SolidBrush(label.ForeColor), label.Bounds);
            }

            else if (label.TextAlign == ContentAlignment.TopCenter)
            {
                SizeF size = g.MeasureString(label.Text, label.Font);

                int left = this.Width / 2 - (int)size.Width / 2;

                Rectangle rect = new Rectangle(left, label.Top, (int)size.Width, (int)label.Height);

                g.DrawString(label.Text, label.Font, new SolidBrush(label.ForeColor), rect);
            }

            else if (label.TextAlign == ContentAlignment.TopRight)
            {
                SizeF size = g.MeasureString(label.Text, label.Font);

                int left = label.Width - (int)size.Width + label.Left;

                Rectangle rect = new Rectangle(left, label.Top, (int)size.Width, (int)size.Height);

                g.DrawString(label.Text, label.Font, new SolidBrush(label.ForeColor), rect);
            }
        }

        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            DrawLabel(label1,e.Graphics);
        }
    }
}