示例#1
0
        private async Task <bool> UnpinLocationOnStart(LocationItem location)
        {
            // 1.Unpin
            var locationId = TileDesigner.ConvertLocationNameToTileId(location.Name);
            var isUnpinned = await TileDesigner.UnpinSecondaryTile(locationId);

            if (!isUnpinned)
            {
                return(false);
            }

            // 2.Delete task config
            await Settings.DeleteSecondaryTaskLocation(locationId);

            // 3.Unregister task
            BackgroundTasks.UnregisterSecondaryTileTask(locationId);

            return(true);
        }
示例#2
0
        private async Task <bool> PinLocationOnStart(LocationItem location)
        {
            // 1.Ask for pin
            var locationId = TileDesigner.ConvertLocationNameToTileId(location.Name);
            var isPined    = await TileDesigner.PinSecondaryTile(location);

            if (!isPined)
            {
                return(false);
            }

            // 2.Register task config
            await Settings.SaveSecondaryTaskLocation(locationId, location);

            // 3.Register task
            BackgroundTasks.RegisterSecondaryTileTask(locationId);

            // 4.Update the tile
            var forecast = await App.DataSource.GetCurrentForecast(location.Latitude, location.Longitude);

            TileDesigner.UpdateSecondary(locationId, forecast, location);

            return(true);
        }