public virtual void Fill(Rectangle rect, CanvasElement ce) { rect.Restrict(new Rectangle(0, 0, Width, Height)); for (int y = rect.Top; y <= rect.InnerBottom; y++) { SetLine(rect.Left, y, ce, rect.Width); } OnUpdate(rect); }
public override void Fill(CanvasElement ce) { ceDefault = ce; for (int i = 0; i < Size.Height; i++) { canvas[i] = null; } base.Fill(ce); }
protected override void SetLine(int x, int y, CanvasElement ce, int width) { var line = GetLine(y); for (int i = x; i < x + width; i++) { line[i] = ce; } }
public override void InsertCharacter(int x, int y, CanvasElement ce) { var line = GetLine(y); for (int i = Width - 1; i > x; i--) { line[i] = line[i - 1]; } line[x] = ce; this.OnUpdate(new Rectangle(x, y, Width - x, 1)); }
public override void DeleteCharacter(int x, int y, CanvasElement ce) { var line = GetLine(y); for (int i = x; i < Width - 1; i++) { line[i] = line[i + 1]; } line[Width - 1] = ce; this.OnUpdate(new Rectangle(x, y, Width - x, 1)); }
public virtual int FindEndY(CanvasElement defaultElement) { for (int row = Height - 1; row >= 0; row--) { if (FindEndX(row, defaultElement) != -1) { return(row); } } return(-1); }
public int FindEndX(CanvasElement defaultElement) { int maxEndX = -1; for (int row = 0; row < Height; row++) { var endX = FindEndX(row, defaultElement); if (endX != -1) { maxEndX = Math.Max(maxEndX, endX); } } return(maxEndX); }
public override CanvasElement[] GetLine(int y) { var line = canvas[y]; if (line == null) { line = new CanvasElement[Size.Width]; for (int i = 0; i < Size.Width; i++) { line[i] = ceDefault; } canvas[y] = line; } return(line); }
public virtual int FindEndX(int y, int startx, int endx, CanvasElement defaultElement) { CanvasElement element; if (endx == 0) { endx = this.Width - 1; } var defaultBackground = defaultElement.Attribute.BackgroundOnly; for (int col = endx; col >= startx; col--) { element = this[col, y]; var ch = element.Character.character; if ((ch != 32 && ch != 0) || (element.Attribute.BackgroundOnly != defaultBackground)) { return(col); } } return(-1); }
public int FindEndX(int y, CanvasElement defaultElement) { return(FindEndX(y, 0, Width - 1, defaultElement)); }
public virtual void Fill(CanvasElement ce) { OnUpdate(new Rectangle(0, 0, Width, Height)); }
public abstract void InsertCharacter(int x, int y, CanvasElement ce);
public abstract void DeleteCharacter(int x, int y, CanvasElement ce);
protected abstract void Set(int x, int y, CanvasElement ce);
public static void Write(this NetOutgoingMessage message, CanvasElement element) { message.WriteVariableInt32(element.Character); message.Write(element.Attribute); }
protected override void Set(int x, int y, CanvasElement ce) { var line = GetLine(y); line[x] = ce; }
protected abstract void SetLine(int x, int y, CanvasElement ce, int width);
public MemoryCanvas(Size canvasSize) : base(canvasSize) { ceDefault = CanvasElement.Default; canvas = new CanvasElement[canvasSize.Height][]; }