public static void SetTile() { if (LiveTileHelper.AreNewTilesSupported) { if (ShellTile.ActiveTiles.Any()) { var tile = ShellTile.ActiveTiles.First(); var flipTileData = new RadFlipTileData { IsTransparencySupported = true, //Title = International.Translations.AppName, //BackTitle = International.Translations.AppName, BackgroundImage = new Uri("/Assets/FlipCycleTileSmall_159_159.png", UriKind.RelativeOrAbsolute), WideBackgroundImage = new Uri("/Assets/FlipCycleTitleLarge_691_336.png", UriKind.RelativeOrAbsolute), }; LiveTileHelper.UpdateTile(tile, flipTileData); } } else { if (ShellTile.ActiveTiles.Any()) { var tile = ShellTile.ActiveTiles.First(); var flipTileData = new RadExtendedTileData { Title = string.Empty, BackgroundImage = new Uri("/Assets/Background_173_173.png", UriKind.RelativeOrAbsolute), }; LiveTileHelper.UpdateTile(tile, flipTileData); } } }
public static bool IsPinned(MetaData metaData) { string path = string.Format("/FolderPage.xaml?path={0}&icon={1}", metaData.Path, metaData.Icon); var tile = LiveTileHelper.GetTile(new Uri(path, UriKind.Relative)); return(tile != null); }
/// <summary> /// Event to pin tile to start screen /// </summary> /// <param name="sender">Object of event sender</param> /// <param name="e"> Event argument</param> private void pinBtn_Click(object sender, EventArgs e) { LiveTileHelper.CreateOrUpdateTile(new RadExtendedTileData() { Title = VehicleName.Text.ToString(), BackVisualElement = this.AverageMileage, BackTitle = "Average Mileage", BackgroundImage = new Uri("/Images/Car.png", UriKind.RelativeOrAbsolute) }, new Uri("/VehicleInfo.xaml?Name=" + VehicleName.Text.ToString(), UriKind.RelativeOrAbsolute)); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void PokemonsInventory_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (!SettingsService.Instance.IsLiveTileEnabled) { return; } // Using a Switch here because we might handle other changed events in other ways. switch (e.Action) { case NotifyCollectionChangedAction.Add: case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Replace: var images = new List <string>(); foreach (PokemonData pokemonData in e.NewItems) { var pokemon = new PokemonDataWrapper(pokemonData); images.Add($"Assets/Pokemons/{(int)pokemon.PokemonId}.png"); } var tile = LiveTileHelper.GetPeopleTile(images); LiveTileUpdater.Update(new TileNotification(tile.GetXml())); break; } }
public SettingsViewModel() { Themes = ThemeHelper.GetThemes(); Languages = LanguageHelper.GetLanguages(); LiveTileDesigns = LiveTileHelper.GetLiveTileDesigns().ToList(); CheckPrimaryTileStatus(); }
public static void RemoveTile(MetaData metaData) { string path = string.Format("/FolderPage.xaml?path={0}&icon={1}", metaData.Path, metaData.Icon); var tile = LiveTileHelper.GetTile(new Uri(path, UriKind.Relative)); if (tile != null) { tile.Delete(); } }
public static void RemoveTile(string url) { var uri = new Uri(url, UriKind.RelativeOrAbsolute); var tile = LiveTileHelper.GetTile(uri); if (tile != null) { tile.Delete(); } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { try { ApplicationView.GetForCurrentView().SetPreferredMinSize(LocalConfiguration.WindowMinSize); SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; // Update app constants from server AppConstants.Update(); // Update assets from server AssetManager.UpdateAssets(); // Play silent sound to avoid suspending the app when it's minimized. silentMediaPlayer.Play(); // Media controls are necessary for the audio to continue when app is minimized. MediaControlsHelper.Init(Dispatcher); MediaControlsHelper.TrackChanged += (ss, trackChangedArgs) => { if (nowPlaying.IsOpen) { nowPlaying.PlayChangeTrackAnimation( reverse: (trackChangedArgs.Direction == TrackChangeDirection.Backward)); } }; // Show what's new if necessary if (WhatsNewHelper.ShouldShowWhatsNew()) { shouldShowWhatsNew = true; } LyricsViewerIntegrationHelper.InitIntegration(); LiveTileHelper.InitLiveTileUpdates(); JumpListHelper.DeleteRecentJumplistEntries(); AnalyticsHelper.PageView("MainPage", setNewSession: true); AnalyticsHelper.Log("mainEvent", "appOpened", SystemInformation.OperatingSystemVersion.ToString()); developerMessage = await DeveloperMessageHelper.GetNextDeveloperMessage(); // Window.Current.CoreWindow.KeyDown does not capture Alt events, but AcceleratorKeyActivated does. // NOTE: This event captures all key events, even when WebView is focused. CoreWindow.GetForCurrentThread().Dispatcher.AcceleratorKeyActivated += Dispatcher_AcceleratorKeyActivated; } catch (Exception ex) { AnalyticsHelper.Log("mainPageLoadedException", ex.Message, ex.ToString()); await new MessageDialog(ex.ToString(), "MainPage:Loaded unhandled exception").ShowAsync(); } }
private void CreateShortCut(object obj) { var shortCutTile = new RadIconicTileData() { IconImage = new Uri("/Assets/Tiles/FolderIconImage.png", UriKind.Relative), SmallIconImage = new Uri("/Assets/Tiles/FolderSmallIconImage.png", UriKind.Relative), Title = FocusedNode.Name }; LiveTileHelper.CreateOrUpdateTile(shortCutTile, new Uri("/Views/MainPage.xaml?ShortCutBase64Handle=" + FocusedNode.OriginalMNode.getBase64Handle(), UriKind.Relative), false); }
private void ApplicationBarMenuItem_Click(object sender, EventArgs e) { //TODO: 7.0 - Create an array of incompeteTodoItems by querying ViewModel.TodoItems where item.IsCompleted == false (hint see 5.3) // Call LiveTileHelper.UpdateLiveTile passing false and the array of incompleteTodoItems (hint see 5.3) // Call TaskHelper.StartTileUpdaterTask #region Solution 7.0 TodoItem[] incompleteTodoItems = ViewModel.TodoItems.Where(item => !item.IsCompleted).ToArray(); LiveTileHelper.UpdateLiveTile(true, incompleteTodoItems); TaskHelper.StartTileUpdaterTask(); #endregion }
private void TodoItems_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { //TODO: 5.3 - Create an array of incompeteTodoItems by querying ViewModel.TodoItems where item.IsCompleted == false // Call DataProvider.SaveValue<TodoItem[]> passing in ViewModel.TodoItems.ToArray() // Call LiveTileHelper.UpdateLiveTile passing false and the array of incompleteTodoItems #region Solution 5.3 TodoItem[] incompleteTodoItems = ViewModel.TodoItems.Where(item => !item.IsCompleted).ToArray(); //bool saveSuccessful = DataProvider.SaveValue<TodoItem[]>(ViewModel.TodoItems.ToArray()); LiveTileHelper.UpdateLiveTile(false, incompleteTodoItems); #endregion }
public void CreateTileForBook(string bookId) { if (string.IsNullOrWhiteSpace(bookId)) { throw new ArgumentException("bookId is invalid"); } var book = _bookRepository.Get(bookId); var uri = _navigationService.UriFor <ReadPageViewModel>() .WithParam(vm => vm.BookId, bookId) .WithParam(vm => vm.ToLastReadPage, true) .BuildUri(); string title = book.Title; BitmapImage bmp; using (var storage = IsolatedStorageFile.GetUserStoreForApplication()) { if (storage.FileExists(ModelExtensions.GetBookCoverPath(book.BookID))) { bmp = new BitmapImage() { CreateOptions = BitmapCreateOptions.None }; using (var file = storage.OpenFile(ModelExtensions.GetBookCoverPath(book.BookID), FileMode.Open)) { bmp.SetSource(file); title = string.Empty; } } else { bmp = null;//.UriSource = new Uri("/Resources/Icons/tile.png", UriKind.RelativeOrAbsolute); } } BookTile tile = new BookTile(); tile.ImageSource = bmp; tile.Title = title; tile.UpdateLayout(); LiveTileHelper.CreateOrUpdateTile(new RadExtendedTileData() { VisualElement = tile }, uri); }
public static void CreateTile(MetaData metaData) { ImageSource imageSource = new BitmapImage(new Uri(string.Format("/TileIcon/{0}.png", metaData.Icon), UriKind.Relative)); var visual = new LiveTileVisual(); visual.SetProperties(metaData.Name, imageSource); var data = new RadExtendedTileData { VisualElement = visual }; string path = string.Format("/FolderPage.xaml?path={0}&icon={1}", metaData.Path, metaData.Icon); LiveTileHelper.CreateTile(data, new Uri(path, UriKind.Relative)); }
public bool IsPinnedToDesktop(string bookId) { if (string.IsNullOrWhiteSpace(bookId)) { throw new ArgumentException("bookId is invalid"); } var uri = _navigationService.UriFor <ReadPageViewModel>() .WithParam(vm => vm.BookId, bookId) .WithParam(vm => vm.ToLastReadPage, true) .BuildUri(); bool tileExists = LiveTileHelper.GetTile(uri) != null; return(tileExists); }
public static void SetTile() { if (ShellTile.ActiveTiles.Any()) { var tile = ShellTile.ActiveTiles.First(); var flipTileData = new RadFlipTileData { IsTransparencySupported = true, BackTitle = "iFixit", BackBackgroundImage = new Uri("/Assets/Tiles/Medium/3.png", UriKind.RelativeOrAbsolute), WideBackBackgroundImage = new Uri("/Assets/Tiles/Large/3.png", UriKind.RelativeOrAbsolute) }; LiveTileHelper.UpdateTile(tile, flipTileData); } }
/// <summary> /// /// </summary> public MainPage() { InitializeComponent(); ShellTile tile = LiveTileHelper.GetTile(new Uri("/AddFill.xaml", UriKind.RelativeOrAbsolute)); if (tile == null) { ApplicationBarMenuItem item = (ApplicationBarMenuItem)ApplicationBar.MenuItems[1]; item.IsEnabled = true; } else { ApplicationBarMenuItem item = (ApplicationBarMenuItem)ApplicationBar.MenuItems[1]; item.IsEnabled = false; } }
public static void UpdateLiveTile(string Title, string BackTitle, string BackContent, string PageUrl, string frontImg, string backImg) { RadExtendedTileData extendedData = new RadExtendedTileData(); //extendedData.VisualElement = LayoutRoot; //extendedData.BackgroundImage = new Uri("appdata:Images/tile_173x173.png"); extendedData.BackgroundImage = new Uri("appdata:Images/" + frontImg); extendedData.Title = Title; //extendedData.Count = 5000; extendedData.BackTitle = BackTitle; //extendedData.BackBackgroundImage = new Uri("appdata:Images/tile_173x173.png"); extendedData.BackBackgroundImage = new Uri("appdata:Images/" + backImg); extendedData.BackContent = BackContent; //this will create a tile looking exactly as your page if it is placed inside a layout panel named LayoutRoot LiveTileHelper.UpdateTile(LiveTileHelper.GetTile(new Uri(PageUrl, UriKind.RelativeOrAbsolute)), extendedData, false); }
public static void UpdateAllLiveTiles() { LiveTileHelper.CleanupUnpinnedTilesResources(); /* * //Calculate Savings, Incomes, Expenses Amount * App.ViewModel.UpdateSumStats(); * * try{ * //Update Savings Tile * UpdateLiveTile("Savings", "Total Savings", "", * "/Views/MainPage.xaml", "savingstile_173x173.png", "tile_173x173_back.png"); * } * catch (Exception ex) * { * //MessageBox.Show(ex.Message); * System.Diagnostics.Debug.WriteLine(ex.StackTrace); * } * * try{ * //Update Incomes Tile * UpdateLiveTile("Incomes", "Total Incomes", "", * "/Views/AllIncomes.xaml", "incomestile_173x173.png", "tile_173x173_back.png"); * } * catch (Exception ex) * { * //MessageBox.Show(ex.Message); * System.Diagnostics.Debug.WriteLine(ex.StackTrace); * } * * try{ * //Update Expenses Tile * UpdateLiveTile("Expenses", "Total Expenses", "", * "/Views/AllExpenses.xaml", "expensestile_173x173.png", "tile_173x173_back.png"); * } * catch (Exception ex) * { * //MessageBox.Show(ex.Message); * System.Diagnostics.Debug.WriteLine(ex.StackTrace); * } * * //!ONHOLD: Update Category Tiles * */ }
public static void CreateUpdateStartTile(string name, string summary, string url, bool remove) { if (remove) { RemoveTile(url); } var control = new ItemTileControl(); control.Initialize(name, summary); RadExtendedTileData extendedData = new RadExtendedTileData() { VisualElement = control, Title = ApplicationManifestHelper.Read().Title, }; LiveTileHelper.CreateOrUpdateTile(extendedData, new Uri(url, UriKind.RelativeOrAbsolute)); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { ApplicationView.GetForCurrentView().SetPreferredMinSize(LocalConfiguration.WindowMinSize); SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; // Update app constants from server AppConstants.Update(); // Update assets from server AssetManager.UpdateAssets(); // Play silent sound to avoid suspending the app when it's minimized. silentMediaPlayer.Play(); // Media controls are necessary for the audio to continue when app is minimized. MediaControlsHelper.Init(Dispatcher); MediaControlsHelper.TrackChanged += (ss, trackChangedArgs) => { if (nowPlaying.IsOpen) { nowPlaying.PlayChangeTrackAnimation( reverse: (trackChangedArgs.Direction == TrackChangeDirection.Backward)); } }; // Show what's new if necessary if (WhatsNewHelper.ShouldShowWhatsNew()) { shouldShowWhatsNew = true; } AnalyticsHelper.PageView("MainPage"); AnalyticsHelper.Log("mainEvent", "appOpened", SystemInformation.OperatingSystemVersion.ToString()); developerMessage = await DeveloperMessageHelper.GetNextDeveloperMessage(); LyricsViewerIntegrationHelper.InitIntegration(); LiveTileHelper.InitLiveTileUpdates(); JumpListHelper.DeleteRecentJumplistEntries(); }
public void DeleteTile(string bookId) { if (string.IsNullOrWhiteSpace(bookId)) { throw new ArgumentException("bookId is invalid"); } var uri = _navigationService.UriFor <ReadPageViewModel>() .WithParam(vm => vm.BookId, bookId) .WithParam(vm => vm.ToLastReadPage, true) .BuildUri(); var tile = LiveTileHelper.GetTile(uri); if (tile == null) { return; } tile.Delete(); }
/// <summary> /// Override of navigation to page /// </summary> /// <param name="e"></param> protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { string _name; if (NavigationContext.QueryString.TryGetValue("Name", out _name)) { RefreshPage(_name); } ShellTile tile = LiveTileHelper.GetTile(new Uri("/VehicleInfo.xaml?Name=" + VehicleName.Text.ToString(), UriKind.RelativeOrAbsolute)); if (tile == null) { ApplicationBarIconButton item = (ApplicationBarIconButton)ApplicationBar.Buttons[2]; item.IsEnabled = true; } else { ApplicationBarIconButton item = (ApplicationBarIconButton)ApplicationBar.Buttons[2]; item.IsEnabled = false; } base.OnNavigatedTo(e); }
private async void PinTileToStart_Click(object sender, RoutedEventArgs e) { await LiveTileHelper.PinToStart(); ViewModel.CheckPrimaryTileStatus(); }
/// <summary> /// /// </summary> /// <param name="pokemonList"></param> /// <remarks> /// advancedrei: The LiveTileUpdater is on teh App class, so this has to stay here for now. Might refactor later. /// </remarks> internal static void UpdateLiveTile(IList <PokemonData> pokemonList) { // Let's run this on a separate thread. Task.Run(() => { try { TileContent tile = null; var images = new List <string>(); var mode = SettingsService.Instance.LiveTileMode; // Generate the images list for multi-image modes. if (mode == LiveTileModes.People || mode == LiveTileModes.Photo) { images.AddRange(pokemonList.Select(c => new PokemonDataWrapper(c).ImageFileName)); } foreach (ScheduledTileNotification scheduled in LiveTileUpdater.GetScheduledTileNotifications()) { LiveTileUpdater.RemoveFromSchedule(scheduled); } if (mode != LiveTileModes.Peek) { LiveTileUpdater.EnableNotificationQueue(true); } else { LiveTileUpdater.EnableNotificationQueue(false); LiveTileUpdater.Clear(); } switch (mode) { case LiveTileModes.Off: tile = LiveTileHelper.GetImageTile("Normal"); LiveTileUpdater.Update(new TileNotification(tile.GetXml())); break; case LiveTileModes.Official: tile = LiveTileHelper.GetImageTile("Official"); LiveTileUpdater.Update(new TileNotification(tile.GetXml())); break; case LiveTileModes.Transparent: tile = LiveTileHelper.GetImageTile("Transparent"); LiveTileUpdater.Update(new TileNotification(tile.GetXml())); break; case LiveTileModes.Peek: foreach (PokemonData pokemonData in pokemonList) { if (LiveTileUpdater.GetScheduledTileNotifications().Count >= 300) { return; } var peekTile = LiveTileHelper.GetPeekTile(new PokemonDataWrapper(pokemonData)); var scheduled = new ScheduledTileNotification(peekTile.GetXml(), DateTimeOffset.Now.AddSeconds((pokemonList.IndexOf(pokemonData) * 30) + 1)); LiveTileUpdater.AddToSchedule(scheduled); } break; case LiveTileModes.People: tile = LiveTileHelper.GetPeopleTile(images); LiveTileUpdater.Update(new TileNotification(tile.GetXml())); break; case LiveTileModes.Photo: tile = LiveTileHelper.GetPhotosTile(images); LiveTileUpdater.Update(new TileNotification(tile.GetXml())); break; } if (tile != null) { GameClient.CurrentSession.Logger.Debug(tile.GetContent()); } } catch (Exception ex) { GameClient.CurrentSession.Logger.Debug(ex.Message); HockeyClient.Current.TrackException(ex); } }); }
/// <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 async override void OnInvoke(ScheduledTask task) { //TODO: Add code to perform your task in background WP_to_WP.Shared.Services.UiSettings settings = new WP_to_WP.Shared.Services.UiSettings(); WP_to_WP.Shared.Services.UiStorage storage = new WP_to_WP.Shared.Services.UiStorage(); Domain.Services.AgentService service = new Domain.Services.AgentService(storage, settings); var result = await service.GetUpdates("112", storage); if (result.Count > 0) { string toastMessage = string.Format(International.Translations.NewPosts, result.Count); ShellToast toast = new ShellToast(); toast.Title = settings.AppName(); toast.Content = toastMessage; toast.Show(); if (ShellTile.ActiveTiles.Any()) { var tile = ShellTile.ActiveTiles.FirstOrDefault(o => o.NavigationUri == new Uri("/Home.xaml", UriKind.RelativeOrAbsolute)); var flipTileData = new RadFlipTileData { Count = result.Count, Title = Domain.AppBase.Current.Config.AppName, IsTransparencySupported = true, //Title = International.Translations.AppName, BackTitle = result[0].Title, BackgroundImage = new Uri("/Assets/FlipCycleTileSmall_159_159.png", UriKind.RelativeOrAbsolute), WideBackgroundImage = new Uri("/Assets/FlipCycleTitleLarge_691_336.png", UriKind.RelativeOrAbsolute), WideBackBackgroundImage = new Uri(result[0].Url, UriKind.RelativeOrAbsolute), BackBackgroundImage = new Uri(result[0].Url, UriKind.RelativeOrAbsolute) }; //List<Uri> images = new List<Uri>(); //RadCycleTileData RadTile = new RadCycleTileData(); //int start = 0; //int max = 10; //for (int i = 0; i < 9; i++) //{ // images.Add(null); //} //foreach (var item in result) //{ // images[start] = new Uri(item.Url, UriKind.Absolute); // start++; // if (start >= max) // break; //} //IEnumerable<Uri> CycleImages = images; //RadTile.CycleImages = CycleImages; LiveTileHelper.UpdateTile(tile, flipTileData); } } NotifyComplete(); }
private async void Page_Loaded(object sender, RoutedEventArgs e) { InitTitleBar(); ApplicationView.GetForCurrentView().SetPreferredMinSize(LocalConfiguration.WindowMinSize); Window.Current.CoreWindow.Activated += Window_Activated; SystemNavigationManager.GetForCurrentView().BackRequested += App_BackRequested; // Update app constants from server AppConstants.Update(); // Update assets from server AssetManager.UpdateAssets(); // Play silent sound to avoid suspending the app when it's minimized. silentMediaPlayer.Play(); // Media controls are necessary for the audio to continue when app is minimized. var mediaControls = SystemMediaTransportControls.GetForCurrentView(); mediaControls.IsEnabled = true; mediaControls.IsPreviousEnabled = true; mediaControls.IsNextEnabled = true; mediaControls.IsPlayEnabled = true; mediaControls.IsPauseEnabled = true; mediaControls.PlaybackStatus = MediaPlaybackStatus.Paused; mediaControls.ButtonPressed += SystemControls_ButtonPressed; await mediaControls.DisplayUpdater.CopyFromFileAsync(MediaPlaybackType.Music, await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Media/silent.wav"))); PlayStatusTracker.MediaControls = mediaControls; PlayStatusTracker.StartRegularRefresh(); // Show what's new if necessary if (WhatsNewHelper.ShouldShowWhatsNew()) { shouldShowWhatsNew = true; } webViewCheckTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1), }; webViewCheckTimer.Tick += WebViewCheckTimer_Tick; webViewCheckTimer.Start(); clipboardCheckTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(3), }; clipboardCheckTimer.Tick += ClipboardCheckTimer_Tick; clipboardCheckTimer.Start(); stuckDetectTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(4), }; stuckDetectTimer.Tick += StuckDetectTimer_Tick; stuckDetectTimer.Start(); AnalyticsHelper.PageView("MainPage"); AnalyticsHelper.Log("mainEvent", "appOpened", SystemInformation.OperatingSystemVersion.ToString()); if (ThemeHelper.GetCurrentTheme() == Theme.Light) { splashScreenToLightStoryboard.Begin(); } developerMessage = await DeveloperMessageHelper.GetNextDeveloperMessage(); LyricsViewerIntegrationHelper.InitIntegration(); LiveTileHelper.InitLiveTileUpdates(); JumpListHelper.DeleteRecentJumplistEntries(); }
public async void CheckPrimaryTileStatus() { PinToStartLinkVisibility = (await LiveTileHelper.CanPinToStart() && !await LiveTileHelper.IsPinnedToStart()) ? Visibility.Visible : Visibility.Collapsed; }
public void UpdateTileSynchronous(List <BirthdayContact> tileContacts, int count = 0, Action callback = null) { #if DEBUG DebugUtility.DebugOutputMemoryUsage("Beginning UpdateTileSynchronous"); #endif var displayName = ""; #if DEBUG DebugUtility.DebugOutputMemoryUsage("UpdateTileSynchronous - Loaded Data"); #endif Deployment.Current.Dispatcher.BeginInvoke(() => { #if DEBUG DebugUtility.DebugOutputMemoryUsage("UpdateTileSynchronous - Medium Tile Control Created"); #endif ShellTile mainTile = ShellTile.ActiveTiles.First(); using (IsolatedStorageFile appStorage = IsolatedStorageFile.GetUserStoreForApplication()) { #if WP8 RadFlipTileData tileData = null; if (tileContacts.Count > 0) { displayName = tileContacts.First().DisplayName; BirthdayTileBackViewModel backTileModel = new BirthdayTileBackViewModel(tileContacts); MediumTileBackUserControl medBackTile = new MediumTileBackUserControl() { DataContext = backTileModel }; WideTileBackUserControl wideBackTile = new WideTileBackUserControl() { DataContext = backTileModel }; tileData = new RadFlipTileData() { Title = Resources.AppTitle.ToTitleCase(), BackTitle = Resources.AppTitle.ToTitleCase(), BackgroundImage = appStorage.FileExists(string.Format(isoStorePath, displayName, "m")) ? new Uri(string.Format(isoStoreUri, displayName, "m"), UriKind.RelativeOrAbsolute) : new Uri("/Assets/Tiles/BirthdayTileMedium.png", UriKind.Relative), BackVisualElement = medBackTile, SmallBackgroundImage = appStorage.FileExists(string.Format(isoStorePath, displayName, "s")) ? new Uri(string.Format(isoStoreUri, displayName, "s"), UriKind.RelativeOrAbsolute) : new Uri("/Assets/Tiles/BirthdayTileSmall.png", UriKind.RelativeOrAbsolute), WideBackgroundImage = appStorage.FileExists(string.Format(isoStorePath, displayName, "w")) ? new Uri(string.Format(isoStoreUri, displayName, "w"), UriKind.RelativeOrAbsolute) : new Uri("/Assets/Tiles/BirthdayTileWide.png", UriKind.RelativeOrAbsolute), WideBackVisualElement = wideBackTile }; } else { tileData = new RadFlipTileData() { Title = Resources.AppTitle.ToTitleCase(), BackgroundImage = new Uri("/Assets/Tiles/BirthdayTileMedium.png", UriKind.Relative), SmallBackgroundImage = new Uri("/Assets/Tiles/BirthdayTileSmall.png", UriKind.RelativeOrAbsolute), WideBackgroundImage = new Uri("/Assets/Tiles/BirthdayTileWide.png", UriKind.RelativeOrAbsolute), }; } #if DEBUG DebugUtility.DebugOutputMemoryUsage("UpdateTileSynchronous - RadFlipTileData created"); #endif #else RadExtendedTileData tileData = null; if (tileContacts.Count > 0) { displayName = tileContacts.First().DisplayName; BirthdayTileBackViewModel backTileModel = new BirthdayTileBackViewModel(tileContacts); MediumTileBackUserControlWP7 medBackTile = new MediumTileBackUserControlWP7() { DataContext = backTileModel }; tileData = new RadExtendedTileData() { Title = Resources.AppTitle.ToTitleCase(), BackTitle = Resources.AppTitle, BackgroundImage = appStorage.FileExists(string.Format(isoStorePath, displayName, "m")) ? new Uri(string.Format(isoStoreUri, displayName, "m"), UriKind.RelativeOrAbsolute) : new Uri("/Assets/Tiles/BirthdayTileMedium.png", UriKind.RelativeOrAbsolute), BackVisualElement = medBackTile }; } else { tileData = new RadExtendedTileData() { Title = Resources.AppTitle.ToTitleCase(), BackgroundImage = new Uri("/Assets/Tiles/BirthdayTileMedium.png", UriKind.RelativeOrAbsolute) }; } #if DEBUG DebugUtility.DebugOutputMemoryUsage("UpdateTileSynchronous - RadExtendedTileData created"); #endif #endif try { LiveTileHelper.UpdateTile(mainTile, tileData); } catch (Exception ex) { DebugUtility.SaveDiagnosticException(ex); throw ex; } } #if DEBUG DebugUtility.SaveDiagnosticMessage("Completed tile update"); #endif if (callback != null) { callback.Invoke(); } }); }
/// <summary> /// /// </summary> /// <param name="pokemonList"></param> /// <remarks> /// advancedrei: The LiveTileUpdater is on teh App class, so this has to stay here for now. Might refactor later. /// </remarks> internal static void UpdateLiveTile(IList <PokemonData> pokemonList) { // Let's run this on a separate thread. Task.Run(() => { try { TileContent tile = null; var images = new List <string>(); var mode = SettingsService.Instance.LiveTileMode; // Generate the images list for multi-image modes. if (mode == LiveTileModes.People && mode == LiveTileModes.Photo) { images.AddRange(pokemonList.Select(c => new PokemonDataWrapper(c).ImageFileName)); } if (mode != LiveTileModes.Peek) { App.LiveTileUpdater.EnableNotificationQueue(true); } else { App.LiveTileUpdater.EnableNotificationQueue(false); LiveTileUpdater.Clear(); } switch (mode) { case LiveTileModes.Off: break; case LiveTileModes.Peek: foreach (PokemonData pokemonData in pokemonList) { if (LiveTileUpdater.GetScheduledTileNotifications().Count >= 300) { return; } var peekTile = LiveTileHelper.GetPeekTile(new PokemonDataWrapper(pokemonData)); var scheduled = new ScheduledTileNotification(peekTile.GetXml(), DateTimeOffset.Now.AddSeconds((pokemonList.IndexOf(pokemonData) * 30) + 1)); LiveTileUpdater.AddToSchedule(scheduled); } break; case LiveTileModes.People: tile = LiveTileHelper.GetPeopleTile(images); LiveTileUpdater.Update(new TileNotification(tile.GetXml())); break; case LiveTileModes.Photo: tile = LiveTileHelper.GetPhotosTile(images); LiveTileUpdater.Update(new TileNotification(tile.GetXml())); break; case LiveTileModes.Transparent: tile = LiveTileHelper.GetImageTile("LiveTiles/Transparent/Square44x44Logo.scale-400.png"); LiveTileUpdater.Update(new TileNotification(tile.GetXml())); break; } if (tile != null) { //Logger.Write(tile.GetXml().GetXml()); } } catch (Exception ex) { Logger.Write(ex.Message); if (!string.IsNullOrEmpty(ApplicationKeys.HockeyAppToken)) { HockeyClient.Current.TrackException(ex); } } }); }
public static bool Exists(string uri) { return(LiveTileHelper.GetTile(new Uri(uri, UriKind.RelativeOrAbsolute)) != null); }