private void formatResults(Label lbl, object value)
        {
            if (lbl.Equals(lblResKBps)) {
                double KBps = (double)value;
                if (KBps < 0) {
                    lblResKBps.Text = "N/A";
                }else if (KBps < 950) {
                    lblResKBps.Text = String.Format("{0:#,#0.0#} KB/s", KBps);
                } else {
                    lblResKBps.Text = String.Format("{0:#,#0.0#} MB/s", KBps / 1000);
                }
            } else if (lbl.Equals(lblResRemaining)) {
                double remaining = (double)value;
                string temp = "";

                if (remaining < 0) {
                    lblResRemaining.Text = "N/A";
                } else if (double.IsPositiveInfinity(remaining) || double.IsNegativeInfinity(remaining)) {
                    lblResRemaining.Text = "Infinito";
                } else {
                    temp = String.Format("{0:0}s", remaining % 60);
                    remaining = Math.Floor(remaining / 60);
                    if (remaining > 0) temp = String.Format("{0:0}m", remaining % 60) + temp;
                    remaining = Math.Floor(remaining / 60);
                    if (remaining > 0) temp = String.Format("{0:0}h", remaining % 24) + temp;
                    remaining = Math.Floor(remaining / 24);
                    if (remaining > 0) temp = String.Format("{0:0}d", remaining % 365) + temp;
                    remaining = Math.Floor(remaining / 365);
                    if (remaining > 0) temp = String.Format("{0:0}a", remaining) + temp;
                    lblResRemaining.Text = temp;
                }
            } else if (lbl.Equals(lblResCurrentSize)) {
                Int64 currentSize = (Int64)value;
                if (currentSize < 0) {
                    lblResCurrentSize.Text = "N/A";
                }else if (currentSize < 1000000) {
                    lblResCurrentSize.Text = String.Format("{0:0.00} KB", currentSize / 1000.0);
                } else if (currentSize < 1000000000) {
                    lblResCurrentSize.Text = String.Format("{0:0.00} MB", currentSize / 1000000.0);
                } else {
                    lblResCurrentSize.Text = String.Format("{0:#,#0.00} GB", currentSize / 1000000000.0);
                }
            } else if (lbl.Equals(lblResProgress)) {
                double progress = (double)value;
                if (double.IsNaN(progress) || progress < 0) {
                    progBarUpload.Value = 0;
                    lblResProgress.Text = "N/A";
                } else {
                    progress = Math.Max(0, Math.Min(100, progress));
                    progBarUpload.Value = (int)Math.Round(progress);
                    lblResProgress.Text = String.Format("{0:0.00} %", progress);
                }
            }
        }
Exemple #2
0
		public void LabelEqualsTest () {
			Label s1 = new Label ();
			Label s2 = new Label ();
			s1.Text = "abc";
			s2.Text = "abc";
			Assert.IsFalse (s1.Equals (s2), "#69");
			Assert.IsTrue (s1.Equals (s1), "#70");
		}
Exemple #3
0
        private int FindSlotNo(Label[] txtBoxs, Label txtBox)
        {
            for (int i = 0; i < txtBoxs.Length; i++)
            {
                if (txtBox.Equals(txtBoxs[i])) return i;
            }

            return -1;
        }