public unsafe void ApplyBackground(IPenContext context) { if (context == null) { return; } IBufferPen Pen = (context is IBufferPen) ? context as IBufferPen : context.ToPen(Width, Height); if (Pen == null || Pen.ID == BackgroundPen) { return; } var rc = Factory.newRectangle(0, 0, Pen.Width, Pen.Height); Pen.CopyTo(rc, Pixels, Length, Width, 0, 0); BackgroundPen = Pen.ID; Factory.Add(Pen, ObjType.Buffer); PendingUpdates.Clear(); BackgroundChanged?.Invoke(this, Factory.EventArgsEmpty); //RefreshAll(); PendingUpdates.Clear(); PendingUpdates.Invalidate(rc); }
public unsafe void ClearBackground(IRectangle target) { IBufferPen pen = null; var rc = this.CompitibleRC(target?.X, target?.Y, target?.Width, target?.Height); if (!string.IsNullOrEmpty(BackgroundPen)) { Factory.Get(BackgroundPen, out pen, ObjType.Buffer); if (pen is IPenContext && (pen.Width != Width || pen.Height != Height)) { Factory.Remove(pen.ID, ObjType.Buffer); pen = (pen as IPenContext).ToPen(Width, Height); BackgroundPen = pen.ID; Factory.Add(pen, ObjType.Buffer); } } if (pen != null) { pen.CopyTo(rc, Pixels, Length, Width, rc.X, rc.Y); goto mks; } int[] array = new int[rc.Width * rc.Height]; fixed(int *p = array) { CopyMemory(p, 0, (int *)Pixels, IndexOf(rc.X, rc.Y, true), array.Length); } mks: PendingUpdates.Invalidate(target); }