CÁC GIẢI PHÁP LẬP TRÌNH C# - Trang 302

302
Chương 8: Đồ họa, đa phương tiện, và in ấn

Hình 8.5 Thêm tính năng cuộn cho bức hình với nội dung tùy biến

using System;

using System.Windows.Forms;

using System.Drawing;

public class PictureScroll : System.Windows.Forms.Form {

private System.Windows.Forms.PictureBox pictureBox1;

private System.Windows.Forms.Panel panel1;

// (Bỏ qua phần mã designer.)

private void PictureScroll_Load(object sender, System.EventArgs e) {

string text = "The quick brown fox jumps over the lazy dog.";

Font font = new Font("Tahoma", 20);

// Tạo một hình bitmap trong-bộ-nhớ.

Bitmap b = new Bitmap(600, 600);

Graphics g = Graphics.FromImage(b);

g.FillRectangle(Brushes.White, new Rectangle(0, 0, b.Width,

b.Height));

// Vẽ nhiều dòng text lên hình bitmap.

for (int i=0; i < 10; i++) {