如题
解决方案 »
- 突然发下一个问题:DbParameter传入参数不需要加ref?
- 关于C#控制台无法切换输入法
- 通过VS的OLEDB连接novell服务器上Foxpro表的问题
- image data binding source
- winform中 textbox键盘控制问题
- C#不支持多继承,郁闷那。。。
- 急!二次筛选 用dataview 在线等
- 求个程序的思路,请高手们指点
- winform直接使用fr3文件
- 怎样修改默认设置,使DateTime.Now.ToString()在Web页面显示时间格式为2003/12/09 08:10:12 而不是 2003/12/9 8:10:12
- 问一个关于SOCKET的问题
- 请教正则表达式
如果你要可以设计,拖拉线条什么的,那全要自己去控制了,设计中所有单独图形都要保存成对象放入图形列表以供绘制和控制鼠标点2下在2点间画线,右键保存到c:\a.jpgusing System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;namespace WindowsApplication110
{
public partial class Form1 : Form
{
PictureBox PB = null;
Bitmap OrgBmp = null;
List<Point> Points = new List<Point>();
List<Point[]> Lines = new List<Point[]>();
public Form1()
{
InitializeComponent(); PB = new PictureBox();
PB.Dock = DockStyle.Fill;
PB.Parent = this; OrgBmp = new Bitmap(PB.ClientRectangle.Width, PB.ClientRectangle.Height); using (Graphics G = Graphics.FromImage(OrgBmp))
G.FillRectangle(Brushes.Black, PB.ClientRectangle); Draw(); PB.MouseDown += new MouseEventHandler(PB_MouseDown);
PB.MouseUp += new MouseEventHandler(PB_MouseUp);
} void PB_MouseUp(object sender, MouseEventArgs e)
{
if (Points.Count == 2)
{
Lines.Add(Points.ToArray());
Points.Clear();
Draw();
}
} void PB_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
Points.Add(e.Location);
else
if (e.Button == MouseButtons.Right)
{
Save();
MessageBox.Show("ok");
}
} void Draw()
{
Bitmap CacheBmp = GetCacheBmp();
PB.Image = CacheBmp;
} void Save()
{
Bitmap CacheBmp = GetCacheBmp();
CacheBmp.Save(@"c:\a.jpg", ImageFormat.Jpeg);
} Bitmap GetCacheBmp()
{
Bitmap CacheBmp = new Bitmap(OrgBmp); using (Graphics G = Graphics.FromImage(CacheBmp))
{
foreach (Point[] Line in Lines)
G.DrawLine(Pens.Red, Line[0], Line[1]);
}
return CacheBmp;
}
}
}