Ejemplo n.º 1
0
        void OnLocationType(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem == null)
            {
                return;
            }
            var index = (LocationTypes.ItemsSource as List <String>).IndexOf(e.SelectedItem.ToString());

            if (index == NEARBY)
            {
                var pos = LocationHelper.GetLocation();
                GlobalObjectsHelper.CwSearchOptions.Lat = pos.Latitude;
                GlobalObjectsHelper.CwSearchOptions.Lng = pos.Longitude;
            }
            else if (index == EVERYWHERE)
            {
                GlobalObjectsHelper.CwSearchOptions.Lat     = null;
                GlobalObjectsHelper.CwSearchOptions.Lng     = null;
                GlobalObjectsHelper.CwSearchOptions.Address = null;
            }
            else
            {
                GlobalObjectsHelper.CwSearchOptions.Address = e.SelectedItem.ToString();
                //GlobalObjectsHelper.CwSearchOptions.Lat = coord[e.SelectedItem.ToString()].X;
                //GlobalObjectsHelper.CwSearchOptions.Lng = coord[e.SelectedItem.ToString()].Y;
            }
            Navigation.PopAsync();
        }
Ejemplo n.º 2
0
        public App()
        {
            InitializeComponent();

            bool isEnabled = false;//DependencyService.Get<IPermissionRequester>().IsGPSEnabled();

            GlobalObjectsHelper.CwSearchOptions = DBHelper.Instance.GetOptions();
            GlobalObjectsHelper.CwSearchOptions.Update();

            if (isEnabled)
            {
                var ret = LocationHelper.GetLocation();
                GlobalObjectsHelper.CwSearchOptions.Lat = ret.Latitude;
                GlobalObjectsHelper.CwSearchOptions.Lng = ret.Longitude;
            }

            if (DBHelper.Instance.GetToken() == null)
            {
                MainPage = new NavigationPage(new LoginPage());
            }
            else
            {
                MainPage = new MainPage();
            }
        }
Ejemplo n.º 3
0
        public void OnShow(object sender, EventArgs e)
        {
            var options = GlobalObjectsHelper.CwSearchOptions;

            if (SortNear.IsToggled)
            {
                var pos = LocationHelper.GetLocation();
                options.Lat = pos.Latitude;
                options.Lng = pos.Longitude;
            }
            else
            {
                options.Lat = null;
                options.Lng = null;
            }

            options.FreeCount = count;
            //options.Amenties = amenties.ToList();

            DBHelper.Instance.SaveOptions(GlobalObjectsHelper.CwSearchOptions);
            //AAA SUKAAA
            var tab  = App.Current.MainPage as TabbedPage;
            var mp   = tab.CurrentPage as MDPage;
            var np   = mp.Detail as NavigationPage;
            var cwrk = np.Navigation.NavigationStack.Last() as CoworkingsListPage;

            cwrk.UpdateCoworkingList();
            mp.IsPresented = false;
        }
Ejemplo n.º 4
0
        async Task ExecuteLoginCommand()
        {
            if (IsBusy)
            {
                return;
            }
            IsBusy = true;

            try
            {
                App.CurrentPosition = await LocationHelper.GetLocation();

                var cloudService = ServiceLocator.Instance.Resolve <ICloudService>();
                await cloudService.LoginAsync();

                await cloudService.RetreiveExtraDataFromCloud();

                //await cloudService.RegisterForPushNotifications();
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"[Login] Error = {ex.Message}");
            }
            finally
            {
                IsBusy = false;
                Application.Current.MainPage = new Pages.RootMasterDetailPage();
                //Application.Current.MainPage = new NavigationPage(new Pages.TabbedMainPage());
            }
        }
Ejemplo n.º 5
0
        public async void GetLocationPermission()
        {
            var status = await PermissionsHelper.GetPermission(Permission.LocationWhenInUse);

            if (status == PermissionStatus.Granted)
            {
                await locationHelper.GetLocation(TimeSpan.FromMinutes(30), 500);
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("Access to location denied", "We don't have access to your location", "Ok");
            }
        }
Ejemplo n.º 6
0
        public async void GetLocationPermission()
        {
            // added using TenDaysOfXamarin.ViewModels.Helpers;
            // added using Plugin.Permissions.Abstractions;
            var status = await PermissionsHelper.GetPermission(Permission.LocationWhenInUse);

            // Already granted (maybe), go on
            if (status == PermissionStatus.Granted)
            {
                // Granted! Get the location
                await locationHelper.GetLocation(TimeSpan.FromMinutes(30), 500);
            }
            else
            {
                await App.Current.MainPage.DisplayAlert("Access to location denied", "We don't have access to your location", "Ok");
            }
        }
Ejemplo n.º 7
0
        public async Task <ActionResult> AddMessage(Message param)
        {
            int    Code;
            string str;
            User   user = await userService.GetUserByIdAsync(param.UserId);

            if (await messageService.IsExistsMessageOnNewestByUserId(param.UserId))
            {
                if (user.UserEmail != null && user.UserEmail != "")
                {
                    param.Location = await LocationHelper.GetLocation(param.Location);//获取位置

                    param.MessageDate = DateTime.Now;
                    Code = await messageService.AddEntityAsync(param) ? 200 : 500;

                    if (param.TargetId != 0 && param.TargetUserId != Guid.Empty && param.TargetUserId != null)
                    {
                        bool ok = await sendEmail.ReplySendEmail(await messageService.GetMessageByIdAsync(param.TargetId), await messageService.GetMessageByIdAsync(param.MessageId), SendEmailType.回复留言);//发送邮件

                        if (ok)
                        {
                            str = Code == 200 ? "回复成功!" : "回复失败!请刷新页面后重试!";
                        }
                        else
                        {
                            str = Code == 200 ? "回复成功,但是该回复并未通知到用户!" : "回复失败!请刷新页面后重试!";
                        }
                    }
                    else
                    {
                        str = Code == 200 ? "评论成功!" : "评论失败!请刷新页面后重试!";
                    };
                }
                else
                {
                    Code = 401;
                    str  = "您还未填写邮箱,请填写邮箱后再留言,谢谢!";
                }
            }
            else
            {
                Code = 400;
                str  = "您在1分钟已经提交过一次了,有什么想说的欢迎直接联系我哦!";
            }
            return(Ok(new { code = Code, msg = str }));
        }
Ejemplo n.º 8
0
        private async Task InitMap()
        {
            var position = await LocationHelper.GetLocation();

            _map.MoveToRegion(MapSpan.FromCenterAndRadius(position, Distance.FromKilometers(1)));

            parties = await GetPartiesFromDataBase(position);

            if (parties == null || parties.Count < 1)
            {
                return;
            }
            PlacePoints();
            _map.PropertyChanged += async(o, e) =>
            {
                await RefreshPartiesFromDataBase();
            };
        }
Ejemplo n.º 9
0
        async Task <Position> GetLocationFromAddresse(string address)
        {
            if (!string.IsNullOrWhiteSpace(address))
            {
                IEnumerable <Position> approximateLocations = await GeoCoder.GetPositionsForAddressAsync(address);

                foreach (var position in approximateLocations)
                {
                    _searchResult += position.Latitude + ", " + position.Longitude + "\n";
                    return(position);
                }

                if (positions.Count < 1)
                {
                    await Application.Current.MainPage.DisplayAlert("Error", "No Locations found", "OK");
                }
            }
            return(await LocationHelper.GetLocation());
        }
Ejemplo n.º 10
0
        private void Location(Context context)
        {
            Location location = locationHelper.GetLocation(context); //Her får du den location tilbage med lat og long

            if (location == null)                                    //Spørger om du fik en lokation tilbage, og hvis ikke så laver en en toast og returner
            {
                Toast.MakeText(context, "Kan ikke finde din lokation", ToastLength.Long).Show();
                return;
            }

            LocationModel address = LocationService.getLocationAddress(location.Latitude, location.Longitude); //Gets the adress for the lat and long given

            var foundTask         = ViewModel.CheckIfLocationTaskExist(address);                               //Finds the task where the location maches
            int indexForFoundTask = ViewModel.Tasks.FindLastIndex(m => m.id == foundTask.id);                  //Finds the index for the task

            TaskDropDown.SetSelection(indexForFoundTask);                                                      //Sets the task as selected in the dropdown/spinner for tasks in the view

            Toast.MakeText(context, "Fandt opgaven: " + foundTask.name + ". Som var tættest på din placering", ToastLength.Long).Show();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 添加留言
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public async Task <bool> AddMessageAsync(MessageEntity t)
        {
            bool flag;
            var  user = await UserService.GetUserByIdAsync(t.userId);

            if (await IsExistsMessageOnNewestByUserId(t.userId))
            {
                // 判断用户是否为空
                if (user == null)
                {
                    return(false);
                }
                t.location = LocationHelper.GetLocation(t.location);
                flag       = await MessageRepository.AddAsync(t);
            }
            else
            {
                throw new Exception("你已经在一分钟前提交过一次了");
            }

            return(flag);
        }
Ejemplo n.º 12
0
        protected override void OnMapReady(GoogleMap map)
        {
            if (mapDrawn)
            {
                return;
            }
            base.OnMapReady(map);

            NativeMap.SetInfoWindowAdapter(this);

            NativeMap.MarkerClick     += OnMarkerClick;
            NativeMap.InfoWindowClick += OnInfoWindowClick;

            pins                  = new List <Pin>(formsMap.Pins);
            CoworkingClicked     += formsMap.OnCoworking;
            formsMap.PinsUpdated += OnPinsUpdate;

            bool isEnabled = DependencyService.Get <IPermissionRequester>().IsGPSEnabled();

            if (me != null)
            {
                me.Remove();
            }

            if (isEnabled)
            {
                var ret    = LocationHelper.GetLocation();
                var marker = new MarkerOptions();
                marker.SetPosition(new LatLng(ret.Latitude, ret.Longitude));

                var bitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.HereIcon);
                marker.SetIcon(BitmapDescriptorFactory.FromBitmap(Bitmap.CreateScaledBitmap(bitmap, 350, 200, false)));
                marker.Draggable(false);
                me = NativeMap.AddMarker(marker);
            }

            mapDrawn = true;
        }