【发布时间】:2014-11-24 17:02:41
【问题描述】:
在 WinForms(最好是 C#)中,我如何制作一个简单的“缩放”工具来在光标位置下方显示一个矩形视图?理想情况下,只放大控件(按钮、标签……)
不过,首先,标准库 (.dll) 可以做到这一点吗?我在处理图形方面完全是新手……
提前致谢!
编辑:此问题/答案 (Zoom a Rectangle in .NET) 涉及缩放图像,而不是输入控件。我只想缩放控件。
Edit2:通过每个控件的 MouseEnter 事件,我定位一个面板,该面板应包含放大的控件图像。我只在正确的站点上获得面板......
private void anyControl_MouseEnter(object sender, EventArgs e)
{
Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height);
//Create the Graphic Variable with screen Dimensions
Graphics graphics = Graphics.FromImage(printscreen as Image);
//Copy Image from the screen
graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);
Control auxControl = (Control) sender;
panel.Width = auxControl + 20;
panel.Height = auxControl + 20;
panel.Location = new Point (auxControl.Location.X - 10, auxControl.Location.Y - 10);
control.DrawToBitmap(printscreen, panel.Bounds)
}
【问题讨论】: