Esempio n. 1
0
        void OnSizeSelect(object sender, EventArgs e)
        {
            ToolStripItem item = sender as ToolStripItem;

            m_sizeDisplayType = (eSizeDisplayType)item.Tag;
            Invalidate();
        }
Esempio n. 2
0
        string GetSizeString(CommonTools.Node node, eSizeDisplayType displayType)
        {
            object data = node[(int)eColumns.Size];

            if (data == null)
            {
                return(string.Empty);
            }
            if (data is string)
            {
                return(data.ToString());
            }

            SizeInfo info = data as SizeInfo;

            if (info.Type == SizeInfo.SizeType.Partial)
            {
                return("> 2GB");
            }
            return(GetSizeString(info.Size, displayType));
        }
Esempio n. 3
0
        string GetSizeString(long size, eSizeDisplayType displayType)
        {
            double gb = 1024 * 1024 * 1024;
            double mb = 1024 * 1024;
            double kb = 1024;

            if (displayType == eSizeDisplayType.Bytes)
            {
                return(string.Format("{0} bytes", size));
            }
            if (displayType == eSizeDisplayType.KBytes)
            {
                return(string.Format("{0} KB", (int)Math.Ceiling((double)size / kb)));
            }
            if (displayType == eSizeDisplayType.MBytes)
            {
                double dsize = Math.Round((double)size / mb, 2);
                return(string.Format("{0:f2} MB", dsize));
            }
            if (displayType == eSizeDisplayType.Best)
            {
                long sizekb = (long)Math.Ceiling((double)size / kb);
                if (size <= 100)
                {
                    return(string.Format("{0} KB", sizekb));
                }

                if (size > (100 * gb))
                {
                    return(string.Format("{0:f2} GB", Math.Round((double)size / gb, 2)));
                }
                if (size > (100 * mb))
                {
                    return(string.Format("{0:f2} MB", Math.Round((double)size / mb, 2)));
                }
                return(string.Format("{0} KB", (int)Math.Ceiling(size / kb)));
            }
            return(string.Format("{0} KB", (int)Math.Ceiling(size / kb)));
        }