Ketarin.Updater.GetDownloadSize C# (CSharp) Method

GetDownloadSize() public method

Returns the download size of a given application in bytes.
public GetDownloadSize ( ApplicationJob job ) : long
job ApplicationJob
return long
        public long GetDownloadSize(ApplicationJob job)
        {
            if (m_Size == null || !m_Size.ContainsKey(job)) return -1;

            return m_Size[job];
        }

Usage Example

            public override void Render(Graphics g, Rectangle r)
            {
                ApplicationJob job = RowObject as ApplicationJob;

                // Do not draw anything if the updater is not currently working
                if (m_Updater.GetProgress(job) == -1)
                {
                    base.DrawBackground(g, r);
                    return;
                }

                base.Render(g, r);

                long fileSize = m_Updater.GetDownloadSize(job);

                // No file size has been determined yet
                if (fileSize == -2)
                {
                    return;
                }

                using (Brush fontBrush = new SolidBrush(SystemColors.WindowText))
                {
                    StringFormat format = new StringFormat();
                    format.Alignment     = StringAlignment.Center;
                    format.LineAlignment = StringAlignment.Center;

                    string text = FormatFileSize.Format(fileSize);
                    if (fileSize < 0)
                    {
                        text = "(unknown)";
                    }
                    g.DrawString(text, new Font(this.Font, FontStyle.Bold), fontBrush, r, format);
                }
            }