<commit_before>/// <reference path="../../Runtime/Nullstone.ts" />
/// <reference path="ImageSource.ts"/>
/// CODE
/// <reference path="../../Primitives/Uri.ts"/>

module Fayde.Media.Imaging {
    declare var Info;

    export interface IImageChangedListener {
        OnImageErrored(source: BitmapSource, e: Event);
        OnImageLoaded(source: BitmapSource, e: Event);
        ImageChanged(source: BitmapSource);
    }

    function intGreaterThanZeroValidator(instance: DependencyObject, propd: DependencyProperty, value: any) {
        if (typeof value !== "number")
            return false;
        return value > 0;
    }

    export class BitmapSource extends ImageSource {
        static PixelWidthProperty: DependencyProperty = DependencyProperty.RegisterFull("PixelWidth", () => Number, BitmapSource, 0, undefined, undefined, undefined, intGreaterThanZeroValidator);
        static PixelHeightProperty: DependencyProperty = DependencyProperty.RegisterFull("PixelHeight", () => Number, BitmapSource, 0, undefined, undefined, undefined, intGreaterThanZeroValidator);

        private _Listener: IImageChangedListener = null;
        private _Image: HTMLImageElement;

        get Image(): HTMLImageElement { return this._Image; }

        ResetImage() {
            this._Image = new Image();
            this._Image.onerror = (e) => this._OnErrored(e);
            this._Image.onload = (e) => this._OnLoad(e);
            this.PixelWidth = 0;
            this.PixelHeight = 0;
            var listener = this._Listener;
            if (listener) listener.ImageChanged(this);
        }
        UriSourceChanged(oldValue: Uri, newValue: Uri) {
            if (!this._Image)
                this.ResetImage();
            this._Image.src = newValue.toString();
            var listener = this._Listener;
            if (listener) listener.ImageChanged(this);
        }

        Listen(listener: IImageChangedListener) { this._Listener = listener; }
        Unlisten(listener: IImageChangedListener) { if (this._Listener === listener) this._Listener = null; }

        _OnErrored(e: Event) {
            Info("Failed to load: " + this._Image.src.toString());<commit_msg>Removed reference to old code.<commit_after>/// <reference path="../../Runtime/Nullstone.ts" />
/// <reference path="ImageSource.ts"/>
/// CODE
/// <reference path="../../Primitives/Uri.ts"/>

module Fayde.Media.Imaging {
    declare var Info;

    export interface IImageChangedListener {
        OnImageErrored(source: BitmapSource, e: Event);
        OnImageLoaded(source: BitmapSource, e: Event);
        ImageChanged(source: BitmapSource);
    }

    function intGreaterThanZeroValidator(instance: DependencyObject, propd: DependencyProperty, value: any) {
        if (typeof value !== "number")
            return false;
        return value > 0;
    }

    export class BitmapSource extends ImageSource {
        static PixelWidthProperty: DependencyProperty = DependencyProperty.RegisterFull("PixelWidth", () => Number, BitmapSource, 0, undefined, undefined, undefined, intGreaterThanZeroValidator);
        static PixelHeightProperty: DependencyProperty = DependencyProperty.RegisterFull("PixelHeight", () => Number, BitmapSource, 0, undefined, undefined, undefined, intGreaterThanZeroValidator);

        private _Listener: IImageChangedListener = null;
        private _Image: HTMLImageElement;

        get Image(): HTMLImageElement { return this._Image; }

        ResetImage() {
            this._Image = new Image();
            this._Image.onerror = (e) => this._OnErrored(e);
            this._Image.onload = (e) => this._OnLoad(e);
            this.PixelWidth = 0;
            this.PixelHeight = 0;
            var listener = this._Listener;
            if (listener) listener.ImageChanged(this);
        }
        UriSourceChanged(oldValue: Uri, newValue: Uri) {
            if (!this._Image)
                this.ResetImage();
            this._Image.src = newValue.toString();
            var listener = this._Listener;
            if (listener) listener.ImageChanged(this);
        }

        Listen(listener: IImageChangedListener) { this._Listener = listener; }
        Unlisten(listener: IImageChangedListener) { if (this._Listener === listener) this._Listener = null; }

        _OnErrored(e: Event) {
            console.info("Failed to load: " + this._Image.src.toString());
{'fraction_non_alphanumeric': 0.11783512217401233, 'fraction_numerical': 0.0022836263987211693, 'mean_word_length': 2.759656652360515, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3433825', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1111, 'n_words': 269}