示例#1
0
 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);
 }
示例#2
0
 public override void Fill(CanvasElement ce)
 {
     ceDefault = ce;
     for (int i = 0; i < Size.Height; i++)
     {
         canvas[i] = null;
     }
     base.Fill(ce);
 }
示例#3
0
        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;
            }
        }
示例#4
0
        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));
        }
示例#5
0
        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));
        }
示例#6
0
 public virtual int FindEndY(CanvasElement defaultElement)
 {
     for (int row = Height - 1; row >= 0; row--)
     {
         if (FindEndX(row, defaultElement) != -1)
         {
             return(row);
         }
     }
     return(-1);
 }
示例#7
0
        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);
        }
示例#8
0
        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);
        }
示例#9
0
        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);
        }
示例#10
0
 public int FindEndX(int y, CanvasElement defaultElement)
 {
     return(FindEndX(y, 0, Width - 1, defaultElement));
 }
示例#11
0
 public virtual void Fill(CanvasElement ce)
 {
     OnUpdate(new Rectangle(0, 0, Width, Height));
 }
示例#12
0
 public abstract void InsertCharacter(int x, int y, CanvasElement ce);
示例#13
0
 public abstract void DeleteCharacter(int x, int y, CanvasElement ce);
示例#14
0
 protected abstract void Set(int x, int y, CanvasElement ce);
示例#15
0
 public static void Write(this NetOutgoingMessage message, CanvasElement element)
 {
     message.WriteVariableInt32(element.Character);
     message.Write(element.Attribute);
 }
示例#16
0
        protected override void Set(int x, int y, CanvasElement ce)
        {
            var line = GetLine(y);

            line[x] = ce;
        }
示例#17
0
 protected abstract void SetLine(int x, int y, CanvasElement ce, int width);
示例#18
0
 public MemoryCanvas(Size canvasSize) : base(canvasSize)
 {
     ceDefault = CanvasElement.Default;
     canvas    = new CanvasElement[canvasSize.Height][];
 }