/// <summary>
        /// Updates the download progress.
        /// </summary>
        /// <param name="intProgress">Int progress.</param>
        /// <param name="size">Size.</param>
        public void UpdateDownloadProgress(int intProgress, long size)
        {
            float floatProgress = ((float)intProgress) / 100;            //floatProgress range from 0 ~ 1

            RightTopView.DownloadProgressView.UpdateProgress(floatProgress);

            if (intProgress == 100)
            {
                RightTopView.InvisibleCancelDownloadButton.RemoveFromSuperview();
                RightTopView.ActionView.UserInteractionEnabled = false;
                RightTopView.ActionView.RemoveFromSuperview();
                RightTopView.RemoveFromSuperview();
            }
        }
        public void Refresh()
        {
            switch (p.PublicationStatus)
            {
            case PublicationStatusEnum.Downloaded:
                StatusLabel.Text     = "Up to date";
                MoreStatusLabel.Text = "Currency Date " + ((DateTime)p.LastUpdatedDate).ToString("dd MMM yyyy");
                break;

            case PublicationStatusEnum.NotDownloaded:
                StatusLabel.Text = "Download";
                double mbSize    = ((double)p.Size) / 1024 / 1024;
                string mbSizeStr = mbSize.ToString();
                int    count     = mbSizeStr.LastIndexOf(".");
                MoreStatusLabel.Text = mbSizeStr.Substring(0, count + 3) + " MB";
                break;

            case PublicationStatusEnum.RequireUpdate:
                StatusLabel.Text     = p.UpdateCount + (p.UpdateCount > 1 ? " Updates avaiable" : " Update avaiable");
                MoreStatusLabel.Text = "Currency Date " + ((DateTime)p.LastUpdatedDate).ToString("dd MMM yyyy");
                break;
            }
            if (p.DaysRemaining < 0)
            {
                StatusLabel.Text     = "Expired";
                MoreStatusLabel.Text = "Currency Date " + ((DateTime)p.LastUpdatedDate).ToString("dd MMM yyyy");
            }

            //TODO, the text of StatusLabel should be determined by publication status other than whether it is empty or not
            if (StatusLabel.Text == "")
            {
                StatusLabel.Text = "Download Failed";
            }

            if (p.PublicationStatus == PublicationStatusEnum.NotDownloaded)
            {
                InfoButton.TintColor = UIColor.LightGray;
            }
            else
            {
                InfoButton.TintColor = UIColor.Red;
            }

            //If publication has not been downloaded or publication has update
            if (p.PublicationStatus == PublicationStatusEnum.NotDownloaded || p.PublicationStatus == PublicationStatusEnum.RequireUpdate)
            {
                RightTopView.TriangleBackgroundColor = UIColor.FromRGB(22, 132, 250);
            }

            //If publication expired
            if (p.DaysRemaining < 0)
            {
                RightTopView.TriangleBackgroundColor = UIColor.FromRGB(253, 59, 47);
            }
            if (p.PublicationStatus == PublicationStatusEnum.RequireUpdate)
            {
                RightTopView.ShowHintText("Update");
            }


            if (p.DaysRemaining < 0)
            {
                RightTopView.ShowHintText("Expired");
                RightTopView.AddGestureRecognizer(new UITapGestureRecognizer(delegate() {
                    AppDataUtil.Instance.SetCurrentPublication(P);
                    AppDisplayUtil.Instance.ShowPublicationInfoView();
                }));
            }
            if (p.DaysRemaining >= 0 && (p.PublicationStatus == PublicationStatusEnum.NotDownloaded || p.PublicationStatus == PublicationStatusEnum.RequireUpdate))
            {
                RightTopView.ShowDownloadActionView(p, StartDownload, ShowDownloadAlert);
            }

            if (p.DaysRemaining >= 0 && p.PublicationStatus == PublicationStatusEnum.Downloaded)
            {
                RightTopView.Hidden = true;
                RightTopView.RemoveFromSuperview();
            }
            else
            {
                RightTopView.Hidden = false;
                AddSubview(RightTopView);
            }
            RightTopView.ZoomRate = ZoomRate;

            RightTopView.SetNeedsDisplay();


            if (p.PublicationStatus == PublicationStatusEnum.NotDownloaded)
            {
                InfoButton.Enabled = false;
            }
            else
            {
                InfoButton.Enabled = true;
            }

            if (p.PublicationStatus == PublicationStatusEnum.NotDownloaded)
            {
                Cover.InvisibleOpenPublicationButton.Enabled = false;
            }
            else
            {
                Cover.InvisibleOpenPublicationButton.Enabled = true;
            }


            DownloadCancelTokenSource = new CancellationTokenSource();

            //TODO, update publication cover
            if (p.IsLoan)
            {
                if (p.DaysRemaining == 0)
                {
                    Cover.LoanTagLabel.Text = "Due to Expire";
                }
                else
                {
                    Cover.LoanTagLabel.Text = "LOAN" + Environment.NewLine + p.DaysRemaining + (p.DaysRemaining > 1 ? " days Remaining" : " day Remaining");
                }
            }
            Cover.TitleLabel.Text = p.Name;


            Cover.BackgroundColor = ColorUtil.ConvertFromHexColorCode(p.ColorPrimary);

            Cover.TitleBackgroundView.BackgroundColor = ColorUtil.ConvertFromHexColorCode(p.ColorSecondary);
            Cover.TitleBackgroundView.SetNeedsDisplay();

            Cover.TitleOuterLineView.Layer.BorderColor = ColorUtil.ConvertFromHexColorCode(p.FontColor).CGColor;
            Cover.TitleOuterLineView.SetNeedsDisplay();

            Cover.TitleInnerLineView.Layer.BorderColor = ColorUtil.ConvertFromHexColorCode(p.FontColor).CGColor;
            Cover.TitleInnerLineView.SetNeedsDisplay();

            Cover.TitleLabel.TextColor = ColorUtil.ConvertFromHexColorCode(p.FontColor);

            Cover.FirstBottomLine.BackgroundColor = ColorUtil.ConvertFromHexColorCode(p.FontColor);
            Cover.FirstBottomLine.SetNeedsDisplay();

            Cover.SecondBottomLine.BackgroundColor = ColorUtil.ConvertFromHexColorCode(p.FontColor);
            Cover.SecondBottomLine.SetNeedsDisplay();

            Cover.LoanTagLabel.TextColor = ColorUtil.ConvertFromHexColorCode(p.FontColor);

            Cover.SetNeedsDisplay();
        }