DImage img = new DImage(System.Drawing.Image.FromFile(Server.MapPath("images/b.bmp")), Color.Red);
BinaryFormatter f = new BinaryFormatter();
System.IO.MemoryStream stream = new System.IO.MemoryStream();
f.Serialize(stream, img);
public override void RefrushHandsLocation()
{
Point LeftTop = new Point(this.bounding.Left,this.bounding.Top);
Point TopRight = new Point(this.bounding.Right,this.bounding.Top);
Point BottomRight = new Point(this.bounding.Right,this.bounding.Bottom);
Point LeftBottom = new Point(this.bounding.Left,this.bounding.Bottom);
Point Center = new Point(this.bounding.Left + (int)(this.bounding.Size.Width / 2),this.bounding.Top + (int)(this.bounding.Size.Height / 2));
this.ActiveHands = new Point[]{LeftTop,TopRight,BottomRight,LeftBottom,Center};
}
public override void Draw(System.Drawing.Graphics g)
{
using (Pen p = new Pen(penColor))
{
g.DrawImage(this.m_Image,this.bounding);
g.DrawRectangle(p,this.bounding);
}
public override Point CenterPoint
{
get
{
return this.ActiveHands[4];
}
set
{
this.ChangeSize(System.Windows.Forms.Cursors.SizeAll,value);
}
}
public override DShape Clone()
{
return (DShape)this.MemberwiseClone();
}
}
}
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
namespace FlyerDesign
{
/// <summary>
/// 图形抽象基类
/// </summary>
[Serializable]
public abstract class DShape
{
public abstract void Draw(Graphics g); //自身重画
protected Rectangle bounding; //图形所在区域
protected Color penColor; //图形常规颜色
protected Point CurrentHande = Point.Empty; //当前选择的操作柄
public abstract DShape Clone(); //创建当前对象的浅备份
public abstract Point CenterPoint
{
get;set;
}
public bool CanSelect(Point p) //是否能被选中
{
Region m_Region = new Region(this.bounding);