/// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
        {
            // Allow saved page state to override the initial item to display

            App app = (App)Application.Current;
            incident= app.ActiveIncident;

            ActiveDeployment = app.ActiveMap;

            DataContext = incident;
            CategoryTextBlock.Text = " ";
            foreach (Category cat in incident.categories)
            {

                CategoryTextBlock.Text += cat.category.title + " | ";
            }

            Pushpin pushpin = new Pushpin();
            pushpin.Tag = incident.incident.incidenttitle;
               // pushpin.Text = incident.incident.incidentdescription;

            Location location = new Location()
            {
                Latitude = incident.incident.Latitude,
                Longitude = incident.incident.Longitude
            };

            ToolTipService.SetToolTip(pushpin, incident.incident.incidenttitle);

            MapLayer.SetPosition(pushpin, location);
            ReportMap.Children.Add(pushpin);

            ReportMap.SetView(location, 14);
        }
示例#2
0
        public List<Deployment> Add(Deployment dep)
        {
            
            this.Deployment.Add(dep);
            write();

            return this.Deployment;
        }
示例#3
0
        public async Task<List<Incident>> _GetIncidents(Deployment deployment) {
            string url = deployment.url +"api?task=incidents";

            var response= await client.GetStringAsync(new Uri(url));

            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(RootObject));
            RootObject root;
            using (MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(response.ToString())))
            {
                root = serializer.ReadObject(stream) as RootObject;
            }

            return root.payload.incidents;
           
        }
示例#4
0
        async void load()
        {

            WebProxy proxy = new WebProxy();
            App app = (App)Application.Current;

            activeDeplyment = app.ActiveMap;
            pageTitle.Text = activeDeplyment.name;

            await proxy.GetIncidents(activeDeplyment);
            ProgressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
            var incidents = proxy.Incidents;

            app.Incidents = incidents;

            IncidentListview.ItemsSource = incidents;

            Location loc = new Location()
            {
                Latitude = activeDeplyment.Latitude,
                Longitude = activeDeplyment.Longitude
            };

            IncidentMap.SetView(loc, 8);

            foreach (Incident i in incidents)
            {
                Pushpin pushpin = new Pushpin();
                pushpin.Tag = i;

                Location location = new Location()
                {
                    Latitude = i.incident.Latitude,
                    Longitude = i.incident.Longitude
                };
                pushpin.Tapped += pushpin_Tapped;

                ToolTipService.SetToolTip(pushpin, i.incident.incidenttitle);

                MapLayer.SetPosition(pushpin, location);
                IncidentMap.Children.Add(pushpin);
            }

        }
        private void SaveButton_Click_1(object sender, RoutedEventArgs e)
        {
            if (ValidateAndGetUri(UrlTextbox.Text))
            {
                Deployment deploy = new Deployment()
                {
                    name = TitleTextbox.Text,
                    description = DescriptionTextbox.Text,
                    url = UrlTextbox.Text
                };

                LocalStorage l = new LocalStorage();
                l.Add(deploy);
                App myapp = (App)Application.Current;
                myapp.Deployments.Add(deploy);
                myapp.ActiveMap = deploy;

            }
            else
            {
                MessageDialog md = new MessageDialog("Wrong URL Format", "Wrong URL");
                md.ShowAsync();
            }
        }
        private bool GetShareContent(DataRequest request)
        {
            bool succeeded = false;

            App app = (App)Application.Current;
            incident = app.ActiveIncident;

            ActiveDeployment = app.ActiveMap;

            Uri dataPackageUri = ValidateAndGetUri(ActiveDeployment.url + "reports/view/"+incident.incident.incidentid);
            if (dataPackageUri != null)
            {

                request.Data.SetUri(dataPackageUri);
                request.Data.Properties.Title = incident.incident.incidenttitle+" @ushahidi 4 #Windows8";
                request.Data.Properties.Description = incident.incident.incidentdescription;

                //request.Data.SetText(
                //            "@Ushahidi Deployment, " + ": " + incident.incident.incidentdescription.Substring(0, 50) + " "
                //   );

                succeeded = true;
            }
            else
            {
                request.FailWithDisplayText("Enter the link you would like to share and try again.");
            }
            return succeeded;
        }
示例#7
0
        public async Task<List<Deployment>> GetDeployments(int mDistance=0, double lat=0,double lon=0)
        {


            List<Deployment> deployments = new List<Deployment>();

            string url = "http://tracker.ushahidi.com/list/";

            StringBuilder fullUrl = new StringBuilder(url);           

            fullUrl.Append("?return_vars=name,latitude,longitude,description,url,category_id,discovery_date,id,ss1");
            fullUrl.Append("&units=km");
           // fullUrl.Append("&distance=" + mDistance);
            //fullUrl.Append("&lat=" + (lat));
            //fullUrl.Append("&lon=" + lat);
            client.MaxResponseContentBufferSize = Int32.MaxValue;

           var response = await client.GetStringAsync(new Uri(fullUrl.ToString()));

            JsonObject objs = JsonObject.Parse(response);           

            foreach (JsonValue jsonvalue in objs.Values)
            {
                
                
                Object objects = jsonvalue.GetObject();
                JsonObject jsonobj = (JsonObject)objects;
                try
                {
                    Deployment deploy = new Deployment
                    {
                        id = jsonobj.GetNamedString("id"),
                        description = jsonobj.GetNamedString("description"),
                        url = jsonobj.GetNamedString("url"),
                        name = jsonobj.GetNamedString("name"),                        
                        latitude = jsonobj.GetNamedString("latitude"),
                        longitude = jsonobj.GetNamedString("longitude"),

                    };


                    try { deploy.ss1 = jsonobj.GetNamedString("ss1"); }
                    catch (Exception exp) { }


                    deployments.Add(deploy);
                }
                     
                catch (Exception ex)
                {

                }

              
            }
            return deployments;

          
        }
示例#8
0
        public async Task GetIncidents(Deployment deployment)
        {
 
          var value= await this._GetIncidents(deployment);
          this.Incidents = value;
        }
示例#9
0
        protected bool GetShareContent(DataRequest request)
        {
            bool succeeded = false;

            App app = (App)Application.Current;


            activeDeplyment = app.ActiveMap;

            Uri dataPackageUri = ValidateAndGetUri(activeDeplyment.url);
            if (dataPackageUri != null)
            {

                request.Data.SetUri(dataPackageUri);
                request.Data.Properties.Title = activeDeplyment.name;
                request.Data.Properties.Description = activeDeplyment.description;

                //request.Data.SetText(
                //           "@Ushahidi Deployment, "  + ": " + activeDeplyment.description.Substring(0, 50) + " "
                //   );


                succeeded = true;
            }
            else
            {
                request.FailWithDisplayText("Enter the link you would like to share and try again.");
            }
            return succeeded;
        }