private void Button_Click(object sender, RoutedEventArgs e) { TextSearchR.Text = ""; ManagedClient user = new ManagedClient(); int port = Convert.ToInt32(Tport.Text); int LN = Convert.ToInt32(TLN.Text); string Msg = TCN.Text; for (int i = 0; i < l1.Items.Count; i++) Msg +="||"+l1.Items[i]; for (int i = 0; i < KeyWord.Items.Count; i++) Msg += "||#" + KeyWord.Items[i]; Random rd = new Random(); int rand = rd.Next(); port += rand % 100; string tport = port.ToString(); user.start(port, 5, 0, LN, Msg,tport); string useit = user.getResult(); string big = DateTime.Now.ToString(); string[] vect = useit.Split('?'); string display = ""; //for (int i = 1; i < vect.Length; i++) //{ // string[] vect2 = vect[i].Split('&'); // display = display + vect2[0] + "\n---Duration: " + vect2[1] + "ms\n---Endtime: " + big + "." + vect2[2] + "\n\n"; //} List<string> listArr = new List<string>(); for (int i = 1; i < vect.Length; i++) { string[] vect2 = vect[i].Split('&'); display = display + vect2[0] + "\n---Duration: " + vect2[1] + "ms\n---Endtime: " + big + "." + vect2[2] + "\n\n"; listArr.Add(vect2[1]); } string[] time = listArr.ToArray(); int amount = 0; int largest = 0; int shortest = 0; for (int i = 0; i < time.Length; i++) { int each = Convert.ToInt32(time[i]); if (each > largest) largest = each; if (i == 0) shortest = largest; if (each < shortest) shortest = each; amount += each; } int average = amount / time.Length; string Saverage = average.ToString(); STT4.Text = shortest.ToString()+"ms"; LGT_Copy2.Text = largest.ToString()+"ms"; Saverage += "ms"; UAV2.Text = Saverage; TextSearchR.Text = display; }
private void Button_Click_4(object sender, RoutedEventArgs e) { SResult.Text = ""; ManagedClient user = new ManagedClient(); int port = Convert.ToInt32(Uport.Text); int LN = Convert.ToInt32(ULN.Text); string Msg = ""; for (int i = 0; i < FileBox2.Items.Count; i++) { if (i == 0) Msg += FileBox2.Items[i]; else Msg += "||" + FileBox2.Items[i]; } Random rd = new Random(); int rand = rd.Next(); port += rand % 100; string uport = port.ToString(); user.start(port, 4, 0, LN, Msg, uport); string useit = user.getResult(); string big = DateTime.Now.ToString(); string[] vect = useit.Split('?'); List<string> listArr = new List<string>(); string display = ""; for (int i = 1; i < vect.Length; i++) { string[] vect2 = vect[i].Split('&'); display = display + vect2[0] + "\n---Duration: " + vect2[1] + "ms\n---Endtime: " + big + "." + vect2[2] + "\n\n"; listArr.Add(vect2[1]); } string[] time = listArr.ToArray(); int amount = 0; int largest = 0; int shortest = 0; for (int i = 0; i < time.Length;i++ ) { int each = Convert.ToInt32(time[i]); if (each > largest) largest = each; if (i == 0) shortest = largest; if (each < shortest) shortest = each; amount += each; } int average = amount / time.Length; string Saverage = average.ToString(); Saverage+="ms"; UAV.Text = Saverage; STT1.Text = shortest.ToString()+"ms"; LGT.Text = largest.ToString()+"ms"; ShowResult1.Text = display; }
static void Main(string[] args) { ManagedClient user = new ManagedClient(); user.start(8082, 1, 0, 2, "test test test", "8082"); }