Exemplo n.º 1
0
        public BioViewModel(ICacheService cacheService, ICommonErrorHandler errorHandler, IStateService stateService, INavigationService navigationService, IMTProtoService mtProtoService, ITelegramEventAggregator eventAggregator)
            : base(cacheService, errorHandler, stateService, navigationService, mtProtoService, eventAggregator)
        {
            _currentUser = stateService.CurrentContact as TLUser45;
            stateService.CurrentContact = null;

            About = _currentUser != null && _currentUser.About != null?_currentUser.About.ToString() : string.Empty;
        }
Exemplo n.º 2
0
        private TLInputGeoPointBase GetGeoPoint(TLUser45 user45)
        {
            TLInputGeoPointBase geoPoint = null;

            if (user45 != null && user45.IsBotInlineGeo)
            {
                geoPoint = new TLInputGeoPointEmpty();
                if (user45.BotInlineGeoAccess && _watcher != null && _watcher.Status == GeoPositionStatus.Ready && _watcher.Position.Location != GeoCoordinate.Unknown)
                {
                    geoPoint = new TLInputGeoPoint {
                        Lat = new TLDouble(_watcher.Position.Location.Latitude), Long = new TLDouble(_watcher.Position.Location.Longitude)
                    };
                }
            }
            return(geoPoint);
        }
Exemplo n.º 3
0
        private bool CheckBotInlineGeoAccess(TLUser45 user45)
        {
            if (user45 != null && user45.IsBotInlineGeo && !user45.BotInlineGeoAccess)
            {
                var now = TLUtils.DateToUniversalTimeTLInt(MTProtoService.ClientTicksDelta, DateTime.Now);
                if (user45.NotifyGeoAccessDate == null ||
                    user45.NotifyGeoAccessDate.Value + Constants.RecheckBotInlineGeoAccessInterval <= now.Value)
                {
                    user45.NotifyGeoAccessDate = now;

                    var result = MessageBox.Show(AppResources.ShareLocationInlineConfirmation, AppResources.ShareLocationCaption, MessageBoxButton.OKCancel);
                    if (result != MessageBoxResult.OK)
                    {
                        return(false);
                    }

                    user45.BotInlineGeoAccess = true;
                }
            }

            return(true);
        }
Exemplo n.º 4
0
        private bool StartGeoWatching(string text, TLUser45 user45)
        {
            if (user45 != null && user45.IsBotInlineGeo && user45.BotInlineGeoAccess)
            {
                if (_watcher == null)
                {
                    _readyText = text;

                    _watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
                    _watcher.StatusChanged += (o, e) =>
                    {
                        if (_watcher.Status == GeoPositionStatus.Ready)
                        {
                            if (_suppressGetResultsOnReady)
                            {
                                _suppressGetResultsOnReady = false;
                                //System.Diagnostics.Debug.WriteLine("    ReGetInlineBotReesults suppress status={0} text={1}", _watcher.Status, text);
                                return;
                            }
                            //System.Diagnostics.Debug.WriteLine("    ReGetInlineBotReesults status={0} text={1}", _watcher.Status, text);
                            GetInlineBotResults(_readyText);
                            _readyText = null;
                        }
                        else if (_watcher.Status == GeoPositionStatus.Initializing)
                        {
                        }
                        else if (_watcher.Status == GeoPositionStatus.Disabled)
                        {
                            var result = MessageBox.Show(AppResources.LocationServicesDisabled, AppResources.AppName,
                                                         MessageBoxButton.OKCancel);
                            if (result == MessageBoxResult.OK)
                            {
#if WP8
                                Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-location:"));
#endif
                            }
                        }
                    };
                    _watcher.Start(true);

                    return(true);
                }

                if (_disableWatching)
                {
                    _disableWatching = false;

                    _watcher.Start(true);
                    if (_watcher.Position.Location != GeoCoordinate.Unknown)
                    {
                        _suppressGetResultsOnReady = true;
                    }
                }

                if (_watcher.Status == GeoPositionStatus.Initializing)
                {
                    if (_watcher.Position.Location == GeoCoordinate.Unknown)
                    {
                        //System.Diagnostics.Debug.WriteLine("    SetReadyText status={0} text={1}", _watcher.Status, text);
                        _readyText = text;
                        return(true);
                    }
                }
            }
            return(false);
        }