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

📄 shapepool.cs

📁 从设计模式角度介绍了updo redo的实现方法
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace ShapeLib
{
    [Serializable]
    public class ShapePool : IEnumerable<Shape>
    {
        List<Shape> shapes = new List<Shape>();

        public void Paint(System.Drawing.Graphics graphics)
        {
            foreach (Shape s in shapes)
            {
                s.Paint(graphics);
            }
        }

        public Shape this[int index]
        {
            get { return shapes[index]; }
        }

        public void Add(Shape shape)
        {
            shapes.Add(shape);
        }

        public void Insert(int index, Shape shape)
        {
            shapes.Insert(index, shape);
        }

        public void RemoveAt(int index)
        {
            shapes.RemoveAt(index);
        }

        public int IndexOf(Shape shape)
        {
            return shapes.IndexOf(shape);
        }

        public int Count
        {
            get { return shapes.Count; }
        }

        #region IEnumerable<Shape> Members

        public IEnumerator<Shape> GetEnumerator()
        {
            return shapes.GetEnumerator();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this.GetEnumerator();
        }

        #endregion
    }
}

⌨️ 快捷键说明

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