Ejemplo n.º 1
0
            //            private void SelectedElement (nint index)
            public void SelectedElement(nint index)
            {
                this.selectedIndex = (int)index;
                string selectedElement = this.matchedElements [(int)this.selectedIndex];
                this.textField.Text = selectedElement;
                this.autoCompleteTableView.Hidden = true;
                runAsyncMethod = true;

                // check and see if elementsCopy has been used, if not copy the elements to it
                if (elementsCopy == null)
                {
                    elementsCopy = new List<string> (elements);
                }

                if (elementsCopy.Count == elements.Count)
                {
                    // hold removed element in placeholder
                    tempElementCopy = selectedElement;
                    // remove element so user can't select in other option
                    this.elements.Remove (selectedElement);
                    // set bool equal to true
                    runAsyncMethod = false;
                }

                if (selectedElement == "Your Location")
                {
                    CLLocationManager lm = new CLLocationManager();
                    string getLongitude = lm.Location.Coordinate.Longitude.ToString();
                    string getLatitude = lm.Location.Coordinate.Latitude.ToString();

                    // TODO send coordinate into the async method and call the bart API to find the nearest train station
                }

                // this fires off the search event if both an origin and destination are selected
                if (elements.Count < elementsCopy.Count && runAsyncMethod == true)
                {
                    getXMLViewController getXml = new getXMLViewController ();
                    string determineIfOriginOrDest = this.textField.Placeholder;
                    getXml.getResultAsync (this.textField.Text, tempElementCopy, determineIfOriginOrDest, elements, stationAbbrs);
                    this.elements.Add (tempElementCopy);
                }
            }