asciipumper- mspaint style program to create irc ascii art |
git clone git://git.acid.vegas/asciipumper.git |
Log | Files | Refs | Archive | README |
PaintAction.cs (1135B)
1 using System; 2 using System.Collections.Generic; 3 using System.Text; 4 using System.Drawing; 5 6 namespace AsciiPumper 7 { 8 public class PaintAction : IUndoableAction 9 { 10 11 public List<Point> PaintedPoints = new List<Point>(); 12 public byte OldPaintColor = 0; 13 public byte NewPaintColor = 1; 14 public bool IsForeground = false; 15 16 public bool PointExists(Point point) 17 { 18 foreach (Point p in PaintedPoints) 19 { 20 if (p.X == point.X && p.Y == point.Y) 21 return true; 22 } 23 return false; 24 } 25 26 #region IUndoableAction Members 27 public void Undo(PaintCanvas canvas) 28 { 29 foreach (Point p in PaintedPoints) 30 { 31 if (IsForeground) 32 canvas.CellRows[p.Y][p.X].ForeColor = OldPaintColor; 33 else 34 canvas.CellRows[p.Y][p.X].BackColor = OldPaintColor; 35 } 36 canvas.RepaintAll(); 37 } 38 39 public void Redo(PaintCanvas canvas) 40 { 41 foreach (Point p in PaintedPoints) 42 { 43 if (IsForeground) 44 canvas.CellRows[p.Y][p.X].ForeColor = NewPaintColor; 45 else 46 canvas.CellRows[p.Y][p.X].BackColor = NewPaintColor; 47 } 48 canvas.RepaintAll(); 49 } 50 51 #endregion 52 } 53 }