Beispiel #1
0
        private async void loadBtn_MouseUp(object sender, MouseEventArgs e)
        {
            if (this.comboBox1.Items.Count == 0)
            {
                // If no routes exist, don't allow "delete"
                if (this.comboBox1.Items.Count == 0)
                {
                    MessageBox.Show("Cannot Load. No Routes Exist", "No Routes Exist",
         MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            myThread = new Thread(new ThreadStart(parentForm.DisplayLoadingScreen));
            myThread.Start();

            // Load Selected Route
            // Get Name of Route
            string routeName = (string)this.comboBox1.SelectedItem;

            // Get All of the Anchors for that Route
            HttpClient c = new HttpClient();
            Task<string> allAnchorsAndInfo = c.GetStringAsync("https://sharingservice20200308094713.azurewebsites.net" + "/api/anchors/allForRoute/" +routeName);

            // Populate the table
            Console.WriteLine(allAnchorsAndInfo.Result);
            string[] outStrArray = allAnchorsAndInfo.Result.Replace("\"","").Replace("[", "").Replace("]", "").Split(',');
            parentForm.clearNewRouteTable();
            for (int i = 0; i < outStrArray.Length; i++)
            {
                List<string> outList = new List<string>();

                outList.Add(outStrArray[i].Split(':')[0]);
                outList.Add(outStrArray[i].Split(':')[1]);
                outList.Add(outStrArray[i].Split(':')[2]);
                outList.Add(outStrArray[i].Split(':')[3]);
                outList.Add(outStrArray[i].Split(':')[4]);
                parentForm.addRowToCurrentRouteTable(i, outList);
          }
            parentForm.newRouteTable.Visible = true;
            parentForm.newRouteTable.ReadOnly = true; // Don't allow edits
                                                      //    parentForm.newRouteTable.Rows[parentForm.newRouteTable.Rows.Count - 1].Cells["routeAnchorsForRemovalChkboxesCol"].Value = false;
            parentForm.newRouteTableLabel.Text = "Loaded Route";
            LoadingForm.setAbort();
            this.Close();
        }