Пример #1
0
        public void CreateLiveTile(string Uri)
        {
            if (ShellTile.ActiveTiles.Any())
            {
                var tile = ShellTile.ActiveTiles.First();
                var flipTileData = new RadFlipTileData
                {
                    Count = 0,
                    Title = Domain.AppBase.Current.Config.AppName,
                    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),
                    BackBackgroundImage = new Uri("/",UriKind.RelativeOrAbsolute),
                    WideBackBackgroundImage = new Uri("/", UriKind.RelativeOrAbsolute), BackTitle=""

                };
                if (!string.IsNullOrEmpty(Uri))
                    LiveTileHelper.CreateOrUpdateTile(flipTileData, new Uri(Uri, UriKind.RelativeOrAbsolute), true, true);
                else
                    LiveTileHelper.CreateOrUpdateTile(flipTileData, new Uri("/Home.xaml", UriKind.RelativeOrAbsolute), true, true);

            }
        }
Пример #2
0
 public void CreateLiveTile(string Uri)
 {
     if (ShellTile.ActiveTiles.Any())
     {
         var tile         = ShellTile.ActiveTiles.First();
         var flipTileData = new RadFlipTileData
         {
             Count = 0,
             Title = Domain.AppBase.Current.Config.AppName,
             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),
             BackBackgroundImage     = new Uri("/", UriKind.RelativeOrAbsolute),
             WideBackBackgroundImage = new Uri("/", UriKind.RelativeOrAbsolute), BackTitle = ""
         };
         if (!string.IsNullOrEmpty(Uri))
         {
             LiveTileHelper.CreateOrUpdateTile(flipTileData, new Uri(Uri, UriKind.RelativeOrAbsolute), true, true);
         }
         else
         {
             LiveTileHelper.CreateOrUpdateTile(flipTileData, new Uri("/Home.xaml", UriKind.RelativeOrAbsolute), true, true);
         }
     }
 }
Пример #3
0
 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);
         }
     }
 }
Пример #4
0
        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>
        /// 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();
        }
Пример #6
0
        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);
            }



        }
Пример #7
0
        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);
                }
            }
        }
Пример #8
0
        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>
        /// 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();
        }