⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 drawableobjectscs.cs

📁 画图程序
💻 CS
📖 第 1 页 / 共 2 页
字号:
	public class DText : DShape
	{
		protected Color brushColor;
		protected string Text;
		protected Font font;
		public DText(Point[] p,Color brushColor,string Text,Size size, Font font)
		{
			bounding = new Rectangle(p[0],size);
			this.brushColor = brushColor;
			this.Text = Text;
			this.font = font;
		}
		public override void pointchange(Point[] p)
		{
		}
		public override void Draw(Graphics g)
		{
			using(Brush b = new SolidBrush(brushColor))
			{
				g.DrawString(Text,font,b,bounding);
			}
		}
	}

	//画弧
	public class DArc : DHollowCircle
	{
		protected float angle1;
		protected float angle2;
		public DArc(Point[] p, Color penColor, float penWidth,float angle1, float angle2) : base(p, penColor,penWidth)
		{			
			this.angle1 = angle1;
			this.angle2 = angle2;
		}
		public override void Draw(Graphics g)
		{
			using(Pen p = new Pen(penColor,penWidth))
			{
				g.DrawArc(p, bounding, angle1, angle2);
			}
		}
	}

	//画多边形
	public class DPolygon : DShape
	{
		public DPolygon(Point[] p, Color penColor,float penWidth)
		{
			this.pointchange(p);
			this.penColor = penColor;
			this.penWidth = penWidth;
		}
		public override void pointchange(Point[] p)
		{
			pointlist = new Point[p.Length];
			int i = 0;
			foreach(Point tempPoint in p)
			{
				pointlist[i++] = tempPoint;
			}
		}
		public override void Draw(Graphics g)
		{
			using(Pen p = new Pen(penColor,penWidth))
			{
				g.DrawPolygon(p, pointlist);
			}
		}
	}

	//基数样条
	public class DCurve : DPolygon
	{
		public DCurve(Point[] p, Color penColor,float penWidth) : base(p, penColor,penWidth)
		{
		}
		public override void Draw(Graphics g)
		{
			using(Pen p = new Pen(penColor,penWidth))
			{
				g.DrawCurve(p,pointlist);
			}
		}
	}

	//闭合样条
	public class DClosedCurve : DCurve
	{
		public DClosedCurve(Point[] p, Color penColor,float penWidth) : base(p, penColor,penWidth)
		{
		}
		public override void Draw(Graphics g)
		{
			using(Pen p = new Pen(penColor,penWidth))
			{
				g.DrawClosedCurve(p,pointlist);
			}
		}
	}

	//Beziers
	public class DBeziers : DPolygon
	{
		public DBeziers(Point[] p, Color penColor,float penWidth) : base(p, penColor,penWidth)
		{
		}
		public override void Draw(Graphics g)
		{
			using(Pen p = new Pen(penColor,penWidth))
			{
				g.DrawBeziers(p,pointlist);
			}
		}
	}

	public class DRegion : DShape
	{
		protected Region newRegion;
		public DRegion(GraphicsPath path)
		{
			newRegion = new Region(path);
		}
		public override void pointchange(Point[] p)
		{
		}
		public override void Draw(Graphics g)
		{
		}

		public Region region
		{
			get
			{
				return newRegion;
			}
		}
	}

	//图像
	public class DImage : DShape
	{
		protected Image image;
		public DImage(Point p,Image image)
		{
			bounding = new Rectangle(p,new Size(image.Width,image.Height));
			this.image=image;
		}
		public override void pointchange(Point[] p)
		{
		}
		public override void Draw(Graphics g)
		{
			g.DrawImage(image,bounding);
		}
	}

	//图形集合
	public class DShapeList : CollectionBase
	{
		DrawCollection wholeList = new DrawCollection();
		public new int Count
		{
			get
			{
				return wholeList.Count;
			}
		}

		public void Add(DShape d) 
		{
			wholeList.Add(d);
		}

		public new void RemoveAt(int i)
		{
			wholeList.RemoveAt(i);
		}

        //索引器
		public DShape this[int newshapeIndex]
		{
			get
			{
				return (DShape)wholeList[newshapeIndex];
			}
			set
			{
				wholeList[newshapeIndex] = value;
			}
		}

		public void DrawList(Graphics g) 
		{
			if (wholeList.Count != 0) 
			{
				foreach (DShape d in wholeList)					
					d.Draw(g);
			}
		}
		//public IFillable[] GetFilledList() 
		//{
			//return (IFillable[])filledList.ToArray(typeof(IFillable));
		//}   
	}

	public class DrawCollection : CollectionBase
	{
		public void Add(DShape d)
		{
			List.Add(d);
		}

		public new void RemoveAt(int i)
		{
			List.RemoveAt(i);
		}
		public DShape this[int shapeIndex]
		{
			get
			{
				return (DShape)List[shapeIndex];
			}
			set
			{
				List[shapeIndex] = value;
			}
		}
	}
	public class NewRegion : CollectionBase
	{
		protected MainWindow.ImageType newType;
		public Region this[int regionIndex]
		{
			get
			{
				return (Region)List[regionIndex];
			}
			set
			{
				List[regionIndex] = value;
			}
		}
		public void Add(Region newRegion)
		{
			List.Add(newRegion);
		}

		public  new void RemoveAt(int i)
		{
			List.RemoveAt(i);
		}
		public void Remove(Region oldRegion)
		{
			List.Remove(oldRegion);
		}
		public NewRegion()
		{
		}		
	}

	public class NewRegionArray : CollectionBase
	{
		public Region[] this[int regionIndex]
		{
			get
			{
				return (Region[])List[regionIndex];
			}
			set
			{
				List[regionIndex] = value;
			}
		}
		public void Add(Region[] newRegion)
		{
			List.Add(newRegion);
		}
		public void Remove(Region[] oldRegion)
		{
			List.Remove(oldRegion);
		}

		public new void RemoveAt(int i)
		{
			List.RemoveAt(i);
		}

		public NewRegionArray()
		{
		}
	}

	public class PointCollection : CollectionBase
	{
		public Point this[int pointIndex]
		{
			get
			{
				return (Point)List[pointIndex];
			}
			set
			{
				List[pointIndex] = value;
			}
		}
		public void Add(Point newPoint)
		{
			List.Add(newPoint);
		}
		public void RemoveRange(int x,int y)
		{
			for(int i=y-1;i>=0;i--)
			{
				List.RemoveAt(i);
			}
		}
		public void AddRange(Point[] point)
		{
			foreach(Point p in point)
			{
				List.Add(p);
			}
		}       
		public PointCollection()
		{
		}
	}

	public class PointArrayCollection : CollectionBase
	{
		public Point[] this[int pointIndex]
		{
			get
			{
				return (Point[])List[pointIndex];
			}
			set
			{
				List[pointIndex] = value;
			}
		}
		public void Add(Point[] newPointArray)
		{
			List.Add(newPointArray);
		}
		public void RemoveRange(int x,int y)
		{
			for(int i=y-1;i>=0;i--)
			{
				List.RemoveAt(i);
			}
		}
		/*public void AddRange(Point[] point)
		{
			foreach(Point p in point)
			{
				List.Add(p);
			}
		} */      
		public PointArrayCollection()
		{
		}
	}
    
	public class Type : CollectionBase
	{
		public int this[int intIndex]
		{
			get
			{
				return (int)List[intIndex];
			}
			set
			{
				List[intIndex] = value;
			}
		}
		public void Add(MainWindow.ImageType type)
		{
			List.Add(type);
		}
		public new void RemoveAt(int i)
		{
			List.RemoveAt(i);
		}
	}
	public class Number : CollectionBase
	{
		public int this[int intIndex]
		{
			get
			{
				return (int)List[intIndex];
			}
			set
			{
				List[intIndex] = value;
			}
		}
		public void Add(int i)
		{
			List.Add(i);
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -