Beispiel #1
0
        private async void HospName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //This code runs whenever the ComboBoxes selected index is changed.
            if (HospName.SelectedIndex != 0)
            {
                //This code checks to see if the app is in snapped view, if it is it unsnappes it.
                if (Windows.UI.ViewManagement.ApplicationView.Value != Windows.UI.ViewManagement.ApplicationViewState.Snapped ||
                    Windows.UI.ViewManagement.ApplicationView.TryUnsnap() == true)
                {
                }

                //HospName is the name of the ComboBox.
                string hospSelected = (string)HospName.SelectedItem;
                userSelection = HospName.SelectedIndex;
                for (int i = 0; i < hospitalDetails.Count; i++)
                {
                    if (hospSelected == hospitalDetails[i].Name)
                    {
                        code = hospitalDetails[i].Code;
                        break;
                    }
                }

                try
                {
                    // Get the list of quarter data from the web service.
                    HttpClient          client   = new HttpClient();
                    HttpResponseMessage response = await client.GetAsync("http://aeactivityapp.azurewebsites.net/get_data.php?section=hospData&code=" + code);

                    response.EnsureSuccessStatusCode();
                    using (Stream stream = await response.Content.ReadAsStreamAsync())
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(List <QuarterData>), new XmlRootAttribute("ArrayOfData"));
                        quarterData = (List <QuarterData>)serializer.Deserialize(stream);
                    }
                }
                catch
                {
                    Error.Text = "Failed to connect to database, please close application and try again later.";
                }

                //If the text block Error's text contains nothing, there hasn't been an error.
                if (Error.Text == "")
                {
                    //ChartItems is a class that organises the quarter data so it can be used in the VisiFire graph.
                    ChartItems items = new ChartItems(quarterData, hospSelected);
                    VisiChart.DataContext = items;
                }
            }
        }
Beispiel #2
0
        //This method populates the VisiFire Chart.
        private void TryToPopulate()
        {
            if (quarterData != null && quarterData2 != null)
            {
                /*The reson for these 2 code statements is so that if a user changes one of the ComboBoxes to the default discriptive text (which is the "Please select ect")
                 * and then selects a different item in the next ComboBox, this code will ensure that both ComboBoxes contain the items selected so the user can be sure of what
                 * they have selected.*/
                selection1.SelectedIndex = userSelection1;
                selection2.SelectedIndex = userSelection2;

                items = new ChartItems(quarterData, quarterData2, hospSelected1, hospSelected2);

                VisiChart.DataContext = items;

                //If the app is in snapped view this code unsnappes it.
                if (Windows.UI.ViewManagement.ApplicationView.Value != Windows.UI.ViewManagement.ApplicationViewState.Snapped ||
                    Windows.UI.ViewManagement.ApplicationView.TryUnsnap() == true)
                {
                }
            }
        }