Esempio n. 1
0
        } // void OnImageOpened(object sender, RoutedEventArgs e)


        // Only called if they've selected to Show On Live Tile
        // Updates the text on the live tile
        public static void UpdateLiveTile()
        {
            ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault();
            if (tile != null)
            {
                FormatResultsClass frc = new FormatResultsClass();

                FlipTileData flipTile = new FlipTileData();
                flipTile.Title = AppResources.AppTitle;
                flipTile.BackTitle = AppResources.AppTitle;

                flipTile.BackContent = " ";
                flipTile.WideBackContent = " ";

                String strBackContent = "";
                frc.FormatLiveTileText((Application.Current as App).gdtSelectedDate, DateTime.Now, out strBackContent );

                //Medium size Tile 336x336 px
                //Create image for BackBackgroundImage in IsoStore
                frc.RenderText(strBackContent, c_n336, c_n336, 28, "BackBackgroundImage");

                flipTile.BackBackgroundImage = new Uri(@"isostore:/Shared/ShellContent/BackBackgroundImage.jpg", UriKind.Absolute); //Generated image for Back Background 336x336
                flipTile.BackgroundImage = new Uri("/Content/MediumBlankTileImage336x336.png", UriKind.Relative); //Default image for Background Image Medium Tile 336x336 px
                //End Medium size Tile 336x336 px

                //Wide size Tile 691x336 px
                //flipTile.WideBackgroundImage = new Uri("/Content/WideBlankTileIcon691x336.png", UriKind.Relative); // Default image for Background Image Wide Tile 691x336 px
                flipTile.WideBackgroundImage = new Uri("/Content/WideBackBackgroundTileIcon691x336WithGlow.png", UriKind.Relative); // Default image for Background Image Wide Tile 691x336 px

                //Create image for WideBackBackgroundImage in IsoStore
                frc.RenderText(strBackContent, 691, c_n336, 40, "WideBackBackgroundImage");
                flipTile.WideBackBackgroundImage = new Uri(@"isostore:/Shared/ShellContent/WideBackBackgroundImage.jpg", UriKind.Absolute);
                
                //End Wide size Tile 691x336 px

                //Update Live Tile
                tile.Update(flipTile);
            }
        } // public static void UpdateLiveTile(string info)
Esempio n. 2
0
        protected override void OnInvoke(ScheduledTask task)
        {
            // NOTE: determine if this needs to run.
            // maybe save the "number of days" in isostorage and check it to see if it has changed?

            IsolatedStorageSettings settings     = IsolatedStorageSettings.ApplicationSettings;
            DateTime dtDaysSinceDate             = DateTime.Now;
            bool     bWasSaveSelectedDateChecked = false;

            // only load a 'selected' date if gbSaveDate == true
            if (!settings.TryGetValue <bool>("saveSelectedDateIsChecked", out bWasSaveSelectedDateChecked))
            {
                NotifyComplete();
                return;
            }

            if (!settings.TryGetValue <DateTime>("selectdate", out dtDaysSinceDate))
            {
                NotifyComplete();
                return;
            }

            // We'll be using UIElements and WriteableBitmaps to build an image so we have to call BeginInvoke
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                // If the agent crashes twice WP7 will shut us down so let make sure if there's an error we catch it
                try
                {
                    ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault();
                    if (tile != null)
                    {
                        FormatResultsClass frc = new FormatResultsClass();

                        FlipTileData flipTile = new FlipTileData();
                        flipTile.Title        = LiveTileScheduledTaskAgentResources.AppTitle;
                        flipTile.BackTitle    = LiveTileScheduledTaskAgentResources.AppTitle;

                        flipTile.BackContent     = " ";
                        flipTile.WideBackContent = " ";

                        String strBackContent = "";
                        frc.FormatLiveTileText(dtDaysSinceDate, DateTime.Now, out strBackContent);

                        //Medium size Tile 336x336 px
                        //Create image for BackBackgroundImage in IsoStore
                        frc.RenderText(strBackContent, c_n336, c_n336, 28, "BackBackgroundImage");

                        flipTile.BackBackgroundImage = new Uri(@"isostore:/Shared/ShellContent/BackBackgroundImage.jpg", UriKind.Absolute); //Generated image for Back Background 336x336
                        flipTile.BackgroundImage     = new Uri("/Content/MediumBlankTileImage336x336.png", UriKind.Relative);               //Default image for Background Image Medium Tile 336x336 px
                        //End Medium size Tile 336x336 px

                        //Wide size Tile 691x336 px
                        //flipTile.WideBackgroundImage = new Uri("/Content/WideBlankTileIcon691x336.png", UriKind.Relative); // Default image for Background Image Wide Tile 691x336 px
                        flipTile.WideBackgroundImage = new Uri("/Content/WideBackBackgroundTileIcon691x336WithGlow.png", UriKind.Relative); // Default image for Background Image Wide Tile 691x336 px

                        //Crete image for WideBackBackgroundImage in IsoStore
                        frc.RenderText(strBackContent, 691, c_n336, 40, "WideBackBackgroundImage");
                        flipTile.WideBackBackgroundImage = new Uri(@"isostore:/Shared/ShellContent/WideBackBackgroundImage.jpg", UriKind.Absolute);

                        //End Wide size Tile 691x336 px

                        //Update Live Tile
                        tile.Update(flipTile);
                    }
                } // try

                // catch
                catch (Exception e)
                {
                    //MessageBox.Show( e.ToString() );
                }
                finally
                {
                    NotifyComplete();
                } // finally
            }); //Deployment.Current.Dispatcher.BeginInvoke(() =>
        }         // OnInvoke(ScheduledTask task)