/// <summary> /// �R���X�g���N�^ /// </summary> /// <param name="doc">�h�L�������g</param> public Canvas(Document doc) { _surface = doc.Surface; _drawBrush = new SolidBrush(Color.Black); _pen = new Pen(_drawBrush); this.DoubleBuffered = true; doc.SurfaceChangeEvent += new Document.SurfaceChangeEventHandler(onSurfaceChange); }
/// <summary> /// �R���X�g���N�^ /// </summary> /// <param name="id">�h�L�������gID</param> public Document(Int32 id) { _id = id; _penSize = 1; _fileName = ""; _dirty = false; _surface = new Surface(50, 50); _backSurface = _surface.Clone() as Surface; _historyList = new HistoryActionList(); }
/// <summary> /// ���̃T�[�t�F�C�X�̃f�[�^��������g�ɃR�s�[���� /// </summary> /// <param name="dstX">�R�s�[���X���W</param> /// <param name="dstY">�R�s�[���Y���W</param> /// <param name="src">�R�s�[���̃T�[�t�F�C�X</param> /// <param name="srcX">�R�s�[����X���W</param> /// <param name="srcY">�R�s�[����Y���W</param> /// <param name="w">����</param> /// <param name="h">�c��</param> public void copy(Int32 dstX, Int32 dstY, Surface src, Int32 srcX, Int32 srcY, Int32 w, Int32 h) { Byte[,] srcBuffer = src.getBuffer(); //�R�s�[�̈�̃N���b�s���O //�摜���]�����A�]����̗̈悩��͂ݏo���Ă��������������B Rectangle dstRect = getRect(), srcRect = src.getRect(); dstRect.Intersect(new Rectangle(dstX, dstY, w, h)); srcRect.Intersect(new Rectangle(srcX, srcY, w, h)); //���ۂɃR�s�[����̈�̕��E������w,h�ŗǂ��Ƃ͌���Ȃ��B //�R�s�[��A�R�s�[���̗̈�̕��̂����A���������̒l��g�p���� Int32 copyW = Math.Min(dstRect.Width, srcRect.Width), copyH = Math.Min(dstRect.Height, srcRect.Height); if(copyW < 1 || copyH < 1) { return; } Int32 ptDstX,ptDstY,ptSrcX,ptSrcY; for(Int32 y=0; y < copyH; y++) { for(Int32 x=0; x < copyW; x++) { ptDstX = dstRect.Left + x; ptDstY = dstRect.Top + y; ptSrcX = srcRect.Left + x; ptSrcY = srcRect.Top + y; _buffer[ptDstX,ptDstY] = srcBuffer[ptSrcX,ptSrcY]; } } }
/// <summary> /// �������g�̕�����Ԃ� /// </summary> /// <returns>�������g�̕���</returns> public object Clone() { Surface clone = new Surface(_w, _h); clone.copy(0,0, this, 0, 0, _w, _h); return clone; }
/// <summary> /// �R���X�g���N�^ /// </summary> /// <param name="doc">�ҏW�Ώۂ̃h�L�������g</param> /// <param name="surface">�ҏW��̃T�[�t�F�C�X</param> /// <param name="backSurface">�ҏW�O�̃T�[�t�F�C�X</param> public SurfaceCopyAction(Document doc, Surface surface, Surface backSurface) { _doc = doc; _surface = surface; _backSurface = backSurface; }