// 假设 CapDevice 类的定义如下
class CapDevice {
    public BitmapSource: any;
    public static FramerateProperty: any;
    public NewBitmapReady: (sender: any, e: any) => void;
    public Dispose(): void {}
    public Stop(): void {}
}

// CapPlayer 类的 TypeScript 实现
class CapPlayer {
    private _device: CapDevice | null = null;
    private _rotation: number = 0;
    private _framerate: number = 0;
    private _imageElement: HTMLImageElement;

    constructor(imageElement: HTMLImageElement) {
        this._imageElement = imageElement;
    }

    public get Device(): CapDevice | null {
        return this._device;
    }

    public set Device(value: CapDevice | null) {
        if (this._device) {
            this.cleanUpDevice(this._device);
        }
        this._device = value;
        if (this._device) {
            this._device.NewBitmapReady = this.device_OnNewBitmapReady.bind(this);
        }
    }

    public get Rotation(): number {
        return this._rotation;
    }

    public set Rotation(value: number) {
        this._rotation = value;
        this._imageElement.style.transform = `rotate(${value}deg)`;
    }

    public get Framerate(): number {
        return this._framerate;
    }

    public set Framerate(value: number) {
        this._framerate = value;
    }

    public get CurrentBitmap(): any {
        if (this._device) {
            // 这里简化处理，实际中需要实现图像旋转和变换
            return this._device.BitmapSource;
        }
        return null;
    }

    public dispose(): void {
        if (this._device) {
            this._device.Dispose();
            this._device = null;
        }
    }

    private cleanUpDevice(device: CapDevice): void {
        device.Stop();
        device.NewBitmapReady = () => {};
    }

    private device_OnNewBitmapReady(sender: any, e: any): void {
        // 简化绑定逻辑
        this._framerate = sender.Framerate;
        if (sender) {
            this._imageElement.src = sender.BitmapSource;
        }
    }
}

// 使用示例
const imageElement = document.createElement('img');
const capPlayer = new CapPlayer(imageElement);
const device = new CapDevice();
capPlayer.Device = device;