public void Initialize(string name, Image icon, double amount, RoundingBehaviour rounding) { NameLabel.Text = name; if (icon != null && iconBox.Image == null) // without this line, setting iconBox.Image causes another repaint, hence an infinite loop iconBox.Image = icon; ValueMB = Util.ToMB(amount, rounding); setSpinnerValueDisplay(amount); initializing = false; }
public void Initialize(string name, Image icon, double amount, RoundingBehaviour rounding) { NameLabel.Text = name; if (icon != null && iconBox.Image == null) // without this line, setting iconBox.Image causes another repaint, hence an infinite loop { iconBox.Image = icon; } ValueMB = Util.ToMB(amount, rounding); setSpinnerValueDisplay(amount); initializing = false; }
public void Initialize(string name, Image icon, long amount, RoundingBehaviour rounding) { NameLabel.Text = name; if (icon != null && iconBox.Image == null) // without this line, setting iconBox.Image causes another repaint, hence an infinite loop { iconBox.Image = icon; } long amountMB = Util.ToMB(amount, rounding); Spinner.Value = amountMB; }
public static long ToMB(long bytes, RoundingBehaviour rounding) { switch (rounding) { case RoundingBehaviour.Up: return((long)Math.Ceiling((double)(((double)bytes) / 1048576.0))); case RoundingBehaviour.Down: return((long)Math.Floor((double)(((double)bytes) / 1048576.0))); } return((long)Math.Round((double)(((double)bytes) / 1048576.0), MidpointRounding.AwayFromZero)); }
public static long ToMB(long bytes, RoundingBehaviour rounding) { switch (rounding) { case RoundingBehaviour.Down: return((long)Math.Floor(bytes / (double)BINARY_MEGA)); case RoundingBehaviour.Up: return((long)Math.Ceiling(bytes / (double)BINARY_MEGA)); default: // case RoundingBehaviour.Nearest: return((long)Math.Round(bytes / (double)BINARY_MEGA, MidpointRounding.AwayFromZero)); } }
public static double ToGB(double bytes, int dp, RoundingBehaviour rounding) { double value = (double)bytes / BINARY_GIGA; int decimalsAdjustment = (int)Math.Pow(10, dp); switch (rounding) { case RoundingBehaviour.None: return(value); case RoundingBehaviour.Down: return(Math.Floor(value * decimalsAdjustment) / decimalsAdjustment); case RoundingBehaviour.Up: return(Math.Ceiling(value * decimalsAdjustment) / decimalsAdjustment); default: // case RoundingBehaviour.Nearest: return(Math.Round(value, 1, MidpointRounding.AwayFromZero)); } }
private static double DecimalAdjustment(double value, RoundingBehaviour rounding, int decimalPlaces) { int decimalsAdjustment = (int)Math.Pow(10, decimalPlaces); switch (rounding) { case RoundingBehaviour.None: return(value); case RoundingBehaviour.Down: return(Math.Floor(value * decimalsAdjustment) / decimalsAdjustment); case RoundingBehaviour.Up: return(Math.Ceiling(value * decimalsAdjustment) / decimalsAdjustment); case RoundingBehaviour.Nearest: default: return(Math.Round(value, decimalPlaces, MidpointRounding.AwayFromZero)); } }
public static double ToMB(double bytes, RoundingBehaviour rounding, int decimalPlaces = 0) { double value = bytes / BINARY_MEGA; return(DecimalAdjustment(value, rounding, decimalPlaces)); }
public void Initialize(double amount, RoundingBehaviour rounding) { ValueMB = Util.ToMB(amount, rounding); setSpinnerValueDisplay(amount); initializing = false; }
public void Initialize(string name, Image icon, long amount, RoundingBehaviour rounding) { NameLabel.Text = name; if (icon != null && iconBox.Image == null) // without this line, setting iconBox.Image causes another repaint, hence an infinite loop iconBox.Image = icon; long amountMB = Util.ToMB(amount, rounding); Spinner.Value = amountMB; }