using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FormatFileSizes
{
    public partial class frm10FormatFileSizes : Form
    {
        public frm10FormatFileSizes()
        {
            InitializeComponent();
        }

        private void frm10FormatFileSizes_Load(object sender, EventArgs e)
        {
            // Set tabs.
            int[] tabs = { 75, 125 };
            valuesListBox.SetTabs(tabs);

            // Display some sample values.
            double value = 12.345;
            for (int i = 1; i < 11; i++)
            {
                string text = "";
                text += value.ToString("E") + "\t" + value.ToFileSize();

                if (value <= long.MaxValue)
                {
                    long long_size = (long)value;
                    text += "\t" + long_size.ToFileSizeApi();
                }

                valuesListBox.Items.Add(text);

                value *= 1000;
            }

            //// Try 1,000,000.
            //string str = "";
            //value = 1000000;
            //str += value.ToString("E") + "\t" + value.ToFileSize();
            //long s2 = (long)value;
            //str += "\t" + s2.ToFileSizeApi();
            //valuesListBox.Items.Add(str);
        }


        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.valuesListBox = new System.Windows.Forms.ListBox();
            this.SuspendLayout();
            // 
            // valuesListBox
            // 
            this.valuesListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
            | System.Windows.Forms.AnchorStyles.Left) 
            | System.Windows.Forms.AnchorStyles.Right)));
            this.valuesListBox.FormattingEnabled = true;
            this.valuesListBox.IntegralHeight = false;
            this.valuesListBox.Location = new System.Drawing.Point(12, 12);
            this.valuesListBox.Name = "valuesListBox";
            this.valuesListBox.Size = new System.Drawing.Size(297, 144);
            this.valuesListBox.TabIndex = 1;
            // 
            // frm10FormatFileSizes
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(321, 168);
            this.Controls.Add(this.valuesListBox);
            this.Name = "frm10FormatFileSizes";
            this.Text = "FormatFileSizes";
            this.Load += new System.EventHandler(this.frm10FormatFileSizes_Load);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.ListBox valuesListBox;
    }
}