﻿using System;
using UnityEngine;
using UnityEngine.UI;

namespace Toast.SmartDownloader.Example
{
    public class ProgressBar : Scrollbar
    {
        public event Action<float, double, double> OnPercentageChanged;

        public uint CompletedFileCount { get; set; }

        public uint TotalFileCount { get; set; }

        public double CompletedFileSizeKB { get; set; }

        public double TotalFileSizeKB { get; set; }

        public float Percentage
        {
            get { return size * 100.0f; }
            set
            {
                value /= 100.0f;
                size = Mathf.Clamp(value, 0.0f, 100.0f);
                if (OnPercentageChanged != null)
                {
                    OnPercentageChanged(size, CompletedFileSizeKB, TotalFileSizeKB);
                }
            }
        }
    }
}