/// <summary> /// Agent that runs a scheduled task /// </summary> /// <param name="task"> /// The invoked task /// </param> /// <remarks> /// This method is called when a periodic or resource intensive task is invoked /// </remarks> protected override void OnInvoke(ScheduledTask task) { UpdateTile.Start(); // Call NotifyComplete to let the system know the agent is done working. NotifyComplete(); }
private void SetUpNotifications() { // Update live title anyway: UpdateTile.Start(); periodicTask = ScheduledActionService.Find(periodicTaskName) as PeriodicTask; // If the task already exists and background agents are enabled for the // application, you must remove the task and then add it again to update // the schedule if (periodicTask != null) { RemoveAgent(periodicTaskName); } try { periodicTask = new PeriodicTask(periodicTaskName); // The description is required for periodic agents. This is the string that the user // will see in the background services Settings page on the device. periodicTask.Description = "This is the Live Tile support for the Days Until Xmas application. Live tiles will not work without this running."; ScheduledActionService.Add(periodicTask); } catch (InvalidOperationException exception) { if (exception.Message.Contains("BNS Error: The action is disabled")) { MessageBox.Show( "Background agents for this application have been disabled by the user. Please enable for Live Tiles.", "Whoops!", MessageBoxButton.OK); } } }
private async void buttonSync_Click(object sender, RoutedEventArgs e) { if (ViewModel.CurrentFeed != null) { await ViewModel.CurrentFeed.RefreshAsync(); UpdateTile.UpDateTile(ViewModel.CurrentFeed.NewestArticles); } }
public void AddTree(int x, int y) { var size = Rand.Next(1, 4); if (Equals(MapBiomes[x], ArrayResource.Grass)) { for (var i = -size; i < size; i++) { if (x + i < 0) { continue; } if (x + i >= SizeGeneratior.WorldWidth) { continue; } if (MapHeight[x + i] != y + 1) { continue; } if (MapTile[x + i, y].Active) { continue; } //Reset(x + i, y); //map[x + i, y].water = 180; if (Rand.Next(0, 2) == 0) { SetTexture(x + i, y, 27, (byte)Rand.Next(0, 2)); UpdateTile.Add(new Point(x + i, y)); } else if (Rand.Next(0, 5) == 0) { SetTexture(x + i, y, 29, (byte)Rand.Next(0, 3)); } //else map[x + i, y].waterType = 2; } } //if (MapBiomes[x] == ArrayResource.snow || MapBiomes[x] == ArrayResource.worldshow) subId = 1; SetTexture(x, y, 13); var b = Program.Game.Rand.Next(2, 5); SetTexture(x, y - 1, 14); MapTile[x, y].Blockheight = 1; MapTile[x, y - 1].Blockheight = (short)(b + 1); for (var i = 0; i < b; i++) { SetTexture(x, y - 2 - i, 15); MapTile[x, y - 2 - i].Blockheight = (short)(b - i + 2); if (i < b / 2 || i >= b - 1 || Rand.Next(100) > 40) { continue; } SetTexture(x + 1, y - 2 - i, 38); if (x + 1 < MapTile.GetUpperBound(0)) { ((TreeDate)MapTile[x + 1, y - 2 - i].TileDate).TypeTree = (short)Rand.Next(0, 2); } } SetTexture(x, y - 2 - b, 16); ((TreeDate)MapTile[x, y - 2 - b].TileDate).TypeTree = (short)Rand.Next(0, 3); // map[x, y].blockheight = 2; UpdateBlock(x, y - 2 - b, 2, 1); //liquId.Add(new LiquId(new Vector2(x*16,(y-2-b-1)*16))); }