Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 9326

cscの作法 その7

$
0
0

概要

cscの作法、調べてみた。
graphicやってみた。

写真

image.png

サンプルコード

using System;
using System.Windows.Forms;
using System.Drawing;

class form1: Form {
    public form1() {
        this.Text = "図";
        this.BackColor = SystemColors.Window;
        this.ClientSize = new Size(500, 300);
    }
    protected override void OnPaint(PaintEventArgs e) {
        Graphics g = e.Graphics;
        Pen penBlue = new Pen(Color.Blue, 2);
        Pen penRed = new Pen(Color.Yellow, 2);
        SolidBrush brush = new SolidBrush(Color.Red);
        g.DrawLine(penBlue, 10, 10, 100, 100);
        e.Graphics.DrawRectangle(penBlue, 110, 10, 100, 100);
        e.Graphics.DrawEllipse(penRed, 110, 10, 100, 100);
        Rectangle rect = new Rectangle(220, 10, 100, 100);
        e.Graphics.FillEllipse(brush, rect);
        penBlue.Dispose();
        penRed.Dispose();
        brush.Dispose();
        Font fontv = new Font("@MS ゴシック", 10);
        StringFormat sf = new StringFormat(StringFormatFlags.DirectionVertical);
        g.DrawString("あけまして", fontv, Brushes.Blue, 330, 10);
        g.DrawString("おめでとう", fontv, Brushes.Red, 410, 10, sf);
    }
    [STAThread]
    public static void Main() {
        Application.Run(new form1());
    }
}

以上。


Viewing all articles
Browse latest Browse all 9326

Latest Images

Trending Articles