-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormPreview.cs
46 lines (37 loc) · 1.21 KB
/
FormPreview.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Drawing;
using System.Windows.Forms;
namespace UnitaleFontMaker
{
/// <summary>
/// 字体图像预览窗口
/// </summary>
public partial class FormPreview : Form
{
private FontPainter painter;
private Size imageSize;
private Image image;
public FormPreview(FontPainter painter)
{
InitializeComponent();
//设置图片
this.painter = painter;
image = painter.GetImage();
imageSize = new Size(image.Width, image.Height);
pictureBox1.Image = Image.FromHbitmap(painter.GetImage().GetHbitmap());
//调整图片框大小
pictureBox1.Size = pictureBox1.Image.Size;
//设置滚动条
hScrollBar1.Maximum = pictureBox1.Image.Width - panel1.Width;
vScrollBar1.Maximum = pictureBox1.Image.Height - panel1.Height;
}
private void hScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
pictureBox1.Location = new Point(-hScrollBar1.Value, pictureBox1.Location.Y);
}
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
pictureBox1.Location = new Point(pictureBox1.Location.X, -vScrollBar1.Value);
}
}
}