Draw string with HatchStyle : Draw String « 2D « C# / CSharp Tutorial






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

public class MainForm : Form {
    public MainForm() {
        CenterToScreen();
        InitializeComponent();
    }

    protected void OnPaint(PaintEventArgs e) {
        Graphics g = e.Graphics;
        int yOffSet = 10;
        Array obj = Enum.GetValues(typeof(HatchStyle));
        for (int x = 0; x < 5; x++) {
            HatchStyle temp = (HatchStyle)obj.GetValue(x);
            HatchBrush theBrush = new HatchBrush(temp, Color.White, Color.Black);
            g.DrawString(temp.ToString(), new Font("Times New Roman", 10),
                         Brushes.Black, 0, yOffSet);
            g.FillEllipse(theBrush, 150, yOffSet, 200, 25);
            yOffSet += 40;
        }
    }
}








27.12.Draw String
27.12.1.A rectangle with some textA rectangle with some text
27.12.2.Draw string along a circleDraw string along a circle
27.12.3.Draw string along a circle 2Draw string along a circle 2
27.12.4.Draw string with HatchStyle