Пример #1
0
 private void AddShop_Loaded(object sender, RoutedEventArgs e)
 {
     if (PhoneApplicationService.Current.State.ContainsKey("place"))
     {
         place         = (PlaceHelper)PhoneApplicationService.Current.State["place"];
         tbName.Text   = place.title;
         tbAdress.Text = place.vicinity.Split('\n')[0];
         tbCity.Text   = place.vicinity.Split('\n')[1];
     }
 }
Пример #2
0
        private void PushpinTap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            //ignoreMapTap = true;
            Pushpin     pushpin = (sender as Pushpin);
            PlaceHelper place   = places.Where(p => p.position == pushpin.Location).FirstOrDefault();

            this.DataContext = place;
            if (NavigationService.CanGoBack)
            {
                PhoneApplicationService.Current.State["place"] = place;
                NavigationService.GoBack();
            }
        }
    /// <summary>
    /// Initialize the points of interest list.
    /// </summary>
    private void InitializeLocationItems()
    {
        if (cbxLocation.Items.Count == 0)
        {
            int startIndex = 0;
            cbxLocation.Items.Add(new ListItem(GetLocalResourceObject("Location_CustomLocation").ToString(), LOCATION_CUSTOM));

            if (Request.QueryString["start"] != null)
            {
                try
                {
                    string entityId = Request.QueryString["start"];
                    var    acct     = EntityFactory.GetById <IAccount>(entityId);
                    if (acct != null && acct.Address != null && acct.Address.IsGeocoded())
                    {
                        cbxLocation.Items.Add(new ListItem(acct.AccountName, acct.Address.Id.ToString()));
                        startIndex = 1;
                    }
                }
                catch { }
            }

            IUser currentUser = Sage.SalesLogix.BusinessRules.BusinessRuleHelper.GetCurrentUser();
            if (currentUser.Id.ToString().Trim() != "ADMIN" && currentUser.UserInfo.Address != null && currentUser.UserInfo.Address.IsGeocoded())
            {
                cbxLocation.Items.Add(new ListItem(GetLocalResourceObject("Location_MyOffice").ToString(), currentUser.UserInfo.Address.Id.ToString()));
            }
            if (currentUser.Id.ToString().Trim() != "ADMIN" && currentUser.UserInfo.HomeAddress != null && currentUser.UserInfo.HomeAddress.IsGeocoded())
            {
                cbxLocation.Items.Add(new ListItem(GetLocalResourceObject("Location_MyHouse").ToString(), currentUser.UserInfo.HomeAddress.Id.ToString()));
            }

            // Get the places this user can use
            var userPlaces = PlaceHelper.GetPlaces(currentUser);
            if (userPlaces != null)
            {
                foreach (IPlace plc in userPlaces)
                {
                    cbxLocation.Items.Add(new ListItem(plc.Name, plc.Address.Id.ToString()));
                }
            }

            cbxLocation.SelectedIndex = startIndex;
            if (startIndex > 0)
            {
                cbxLocation_ChangeAction(this, new EventArgs());
                btnSearch_OnClick(this, new EventArgs());
            }
        }
    }
Пример #4
0
        private List <PlaceHelper> ParsePlaces(string json)
        {
            List <PlaceHelper> places = new List <PlaceHelper>();

            if (json == string.Empty)
            {
                return(places);
            }

            JToken jToken = JObject.Parse(json)["results"]["items"];

            if (jToken == null)
            {
                return(places);
            }

            IList <JToken> jlList = jToken.Children().ToList();

            foreach (JToken token in jlList)
            {
                PlaceHelper place = JsonConvert.DeserializeObject <PlaceHelper>(token.ToString());

                if (place.type == "urn:nlp-types:place")
                {
                    IList <JToken> jTokenListPosition = token["position"].ToList();
                    GeoCoordinate  position           = new GeoCoordinate();
                    position.Latitude  = double.Parse(jTokenListPosition[0].ToString());
                    position.Longitude = double.Parse(jTokenListPosition[1].ToString());
                    place.position     = position;

                    places.Add(place);
                }
            }

            return(places);
        }