예제 #1
0
        private async Task UpdateCycleTile()
        {
            AppLogs.WriteInfo("UpdateCycleTile", "Executed");
            try
            {
                var imageUrls = await CycleTileAgent.GetTileImages();
                if (imageUrls != null)
                {
                    AppLogs.WriteInfo("UpdateCycleTile", String.Join("\r\n", imageUrls));

                    var cycleTileData = new CycleTileData()
                    {
                        CycleImages = imageUrls
                    };

                    var appTile = ShellTile.ActiveTiles.FirstOrDefault();
                    if (appTile != null)
                    {
                        appTile.Update(cycleTileData);
                    }
                }
            }
            catch (Exception ex)
            {
                AppLogs.WriteInfo("UpdateCycleTile", ex.ToString());
            }
            AppLogs.WriteInfo("UpdateCycleTile", "Finished");
        }
예제 #2
0
        private void OnCreatingCycleTile(object sender, GestureEventArgs e)
        {
            var cycleTile = new CycleTileData
            {
                Title = "Leipzig Impressionen",
                Count = 3,
                SmallBackgroundImage = new Uri("Assets/CycleTile/Tiles-2.jpg", UriKind.Relative),
                CycleImages          = new List <Uri>
                {
                    new Uri("Assets/CycleTile/Tiles-1.jpg", UriKind.Relative),
                    new Uri("Assets/CycleTile/Tiles-2.jpg", UriKind.Relative),
                    new Uri("Assets/CycleTile/Tiles-3.jpg", UriKind.Relative),
                    new Uri("Assets/CycleTile/Tiles-4.jpg", UriKind.Relative),
                    new Uri("Assets/CycleTile/Tiles-5.jpg", UriKind.Relative),
                    new Uri("Assets/CycleTile/Tiles-6.jpg", UriKind.Relative),
                    new Uri("Assets/CycleTile/Tiles-7.jpg", UriKind.Relative),
                    new Uri("Assets/CycleTile/Tiles-8.jpg", UriKind.Relative),
                    new Uri("Assets/CycleTile/Tiles-9.jpg", UriKind.Relative),
                }
            };

            ShellTile.Create(new Uri("/MainPage.xaml?shellTemplateType=CycleTemplate",
                                     UriKind.Relative),
                             cycleTile,
                             true);
        }
 private void btnCycle_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (checkTile("cycleTile") == null)
         {
             CycleTileData flipTileData = new CycleTileData()
             {
                 Title = "VietNam",
                 Count = DateTime.Now.Second,
                 SmallBackgroundImage = new Uri("Images/h1.png", UriKind.RelativeOrAbsolute),
                 CycleImages          = new Uri[]
                 {
                     new Uri("Images/h1.png", UriKind.RelativeOrAbsolute),
                     new Uri("Images/h2.png", UriKind.RelativeOrAbsolute),
                     new Uri("Images/h3.png", UriKind.RelativeOrAbsolute),
                     new Uri("Images/h4.png", UriKind.RelativeOrAbsolute),
                     new Uri("Images/h5.png", UriKind.RelativeOrAbsolute),
                     new Uri("Images/h6.png", UriKind.RelativeOrAbsolute)
                 }
             };
             ShellTile.Create(new Uri("/MainPage.xaml?cycleTile", UriKind.RelativeOrAbsolute), flipTileData, true);
         }
         else
         {
             MessageBox.Show("CycleTile Existing!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #4
0
        private async static Task SetLockScreen(string fileName)
        {
            bool hasAccessForLockScreen = LockScreenManager.IsProvidedByCurrentApplication;

            if (!hasAccessForLockScreen)
            {
                var accessRequested = await LockScreenManager.RequestAccessAsync();

                hasAccessForLockScreen = (accessRequested == LockScreenRequestResult.Granted);
            }

            if (hasAccessForLockScreen)
            {
                Uri imgUri = new Uri("ms-appdata:///Local/" + BackgroundRoot + fileName, UriKind.Absolute);
                LockScreen.SetImageUri(imgUri);
            }

            var mainTile = ShellTile.ActiveTiles.FirstOrDefault();

            if (null != mainTile)
            {
                Uri iconUri = new Uri("isostore:///" + IconRoot + fileName, UriKind.Absolute);
                var images  = new List <Uri>();
                images.Add(iconUri);

                CycleTileData tileData = new CycleTileData();
                tileData.CycleImages = images;

                mainTile.Update(tileData);
            }
        }
예제 #5
0
        private async Task UpdateCycleTile()
        {
            AppLogs.WriteInfo("UpdateCycleTile", "Executed");
            try
            {
                var imageUrls = await CycleTileAgent.GetTileImages();

                if (imageUrls != null)
                {
                    AppLogs.WriteInfo("UpdateCycleTile", String.Join("\r\n", imageUrls));

                    var cycleTileData = new CycleTileData()
                    {
                        CycleImages = imageUrls
                    };

                    var appTile = ShellTile.ActiveTiles.FirstOrDefault();
                    if (appTile != null)
                    {
                        appTile.Update(cycleTileData);
                    }
                }
            }
            catch (Exception ex)
            {
                AppLogs.WriteInfo("UpdateCycleTile", ex.ToString());
            }
            AppLogs.WriteInfo("UpdateCycleTile", "Finished");
        }
예제 #6
0
    private void OnCreatingCycleTile(object sender, GestureEventArgs e)
    {
      var cycleTile = new CycleTileData
      {
        Title = "Leipzig Impressionen",
        Count = 3,
        SmallBackgroundImage = new Uri("Assets/CycleTile/Tiles-2.jpg", UriKind.Relative),
        CycleImages = new List<Uri>
        {
          new Uri("Assets/CycleTile/Tiles-1.jpg", UriKind.Relative),
          new Uri("Assets/CycleTile/Tiles-2.jpg", UriKind.Relative),
          new Uri("Assets/CycleTile/Tiles-3.jpg", UriKind.Relative),
          new Uri("Assets/CycleTile/Tiles-4.jpg", UriKind.Relative),
          new Uri("Assets/CycleTile/Tiles-5.jpg", UriKind.Relative),
          new Uri("Assets/CycleTile/Tiles-6.jpg", UriKind.Relative),
          new Uri("Assets/CycleTile/Tiles-7.jpg", UriKind.Relative),
          new Uri("Assets/CycleTile/Tiles-8.jpg", UriKind.Relative),
          new Uri("Assets/CycleTile/Tiles-9.jpg", UriKind.Relative),
        }
      };

      ShellTile.Create(new Uri("/MainPage.xaml?shellTemplateType=CycleTemplate",
                      UriKind.Relative), 
                      cycleTile,
                      true);
    }
        public static void UpdateCycleTile(
            Uri smallBackgroundImage, Uri backgroundImage,
            List <Uri> images, Random random, ShellTile currentTile)
        {
            Uri[] mediumImages = new Uri[9];

            mediumImages[0] = backgroundImage;

            if (Config.AnimateTiles)
            {
                var schema = "isostore:/Shared/ShellContent/{0}";

                for (int i = 1; i < 9; i++)
                {
                    int rand = random.Next(images.Count - 1);

                    mediumImages[i] = new Uri(String.Format(schema, Path.GetFileName(images[rand].OriginalString)), UriKind.Absolute);
                }
            }

            // Get the new cycleTileData type.
            CycleTileData cycleTileData = new CycleTileData
            {
                // Set the properties.
                SmallBackgroundImage = smallBackgroundImage,
                CycleImages          = mediumImages
            };

            // Invoke the new version of ShellTile.Update.
            currentTile.Update(cycleTileData);
        }
        private void EnableCyclecTileSwitch_Checked(object sender, RoutedEventArgs e)
        {
            if (CycleTile != null)
                return;

            CycleTileData oCycleicon = new CycleTileData();
            oCycleicon.Title = "Hello Cycle Icon!!";
            oCycleicon.Count = 9;

            oCycleicon.SmallBackgroundImage = new Uri("Assets/Tiles/Cycle/159x159.png", UriKind.Relative);

            //// Images could be max Nine images.
            oCycleicon.CycleImages = new Uri[]
               {
                  new Uri("Assets/Tiles/Cycle/001.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/002.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/003.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/004.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/005.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/006.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/007.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/008.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/009.jpg", UriKind.Relative),
               };

            ShellTile.Create(new Uri("/MainPage.xaml?tileType=cycle", UriKind.Relative), oCycleicon, true);

            CycleTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("tileType=cycle".ToString()));
        }
        private CycleTileData CreateCycleTileData(LiveTilesOptions liveTileOptions)
        {
            CycleTileData tileData = new CycleTileData();

            if (!string.IsNullOrEmpty(liveTileOptions.Title))
            {
                tileData.Title = liveTileOptions.Title;
            }
            if (liveTileOptions.Count > 0)
            {
                tileData.Count = liveTileOptions.Count;
            }
            if (!string.IsNullOrEmpty(liveTileOptions.Image))
            {
                string[] imgs    = liveTileOptions.Image.Split('|');
                Uri[]    imgUris = new Uri[imgs.Length];
                for (int i = 0; i < imgs.Length; ++i)
                {
                    imgUris[i] = new Uri(imgs[i], UriKind.Relative);
                }
                tileData.CycleImages          = imgUris;
                tileData.SmallBackgroundImage = imgUris[0];
            }
            return(tileData);
        }
예제 #10
0
        public void GetSecondaryTileData(long userOrGroupId, bool isGroup, string name, int maxImages, Action <bool, CycleTileData> completionCallback, string smallPhoto = null)
        {
            //Func<Tuple<int, string>, bool> func1;
            //Func<Tuple<int, string>, Uri> func2;
            this.GetRemoteUrisFor(Math.Abs(userOrGroupId), isGroup, (Action <bool, List <string> >)((res, resData) =>
            {
                if (res)
                {
                    List <Tuple <int, string> > imagesToDownloadData = new List <Tuple <int, string> >();
                    resData  = resData.Take <string>(maxImages).ToList <string>();
                    int num1 = 0;
                    foreach (string str in resData)
                    {
                        imagesToDownloadData.Add(new Tuple <int, string>(num1, str));
                        ++num1;
                    }
                    if (resData.Count == 0)
                    {
                        Action <bool, CycleTileData> action = completionCallback;
                        int num2 = 1;
                        CycleTileData cycleTileData = new CycleTileData();
                        string str = SecondaryTileManager.FormatNameForTile(name);
                        ((ShellTileData)cycleTileData).Title = str;
                        action(num2 != 0, cycleTileData);
                    }
                    else
                    {
                        if (!string.IsNullOrWhiteSpace(smallPhoto))
                        {
                            imagesToDownloadData.Add(new Tuple <int, string>(1000, smallPhoto));
                        }
                        List <WaitHandle> waitHandles = SecondaryTileManager.DownloadImages(imagesToDownloadData, "UserOrGroup", userOrGroupId.ToString() + isGroup.ToString());
                        new Thread((ThreadStart)(() =>
                        {
                            if (!WaitHandle.WaitAll(waitHandles.ToArray(), 15000))
                            {
                                completionCallback(false, null);
                            }
                            else
                            {
                                CycleTileData cycleTileData = new CycleTileData();
                                string str = SecondaryTileManager.FormatNameForTile(name);
                                ((ShellTileData)cycleTileData).Title = str;
                                List <Uri> list = imagesToDownloadData.Where <Tuple <int, string> >(/*func1 ?? (func1 = (*/ new Func <Tuple <int, string>, bool>(im => im.Item2 != smallPhoto)).Select <Tuple <int, string>, Uri>(/*func2 ?? (func2 = (*/ new Func <Tuple <int, string>, Uri>(im => new Uri("isostore:/" + SecondaryTileManager.GetLocalNameFor(im.Item1, "UserOrGroup", userOrGroupId.ToString() + isGroup.ToString()), UriKind.Absolute))).ToList <Uri>();

                                cycleTileData.CycleImages = ((IEnumerable <Uri>)list);
                                Uri uri = smallPhoto == null ?  null : new Uri("isostore:/" + SecondaryTileManager.GetLocalNameFor(1000, "UserOrGroup", userOrGroupId.ToString() + isGroup.ToString()), UriKind.Absolute);
                                cycleTileData.SmallBackgroundImage = uri;
                                completionCallback(true, cycleTileData);
                            }
                        })).Start();
                    }
                }
                else
                {
                    completionCallback(false, null);
                }
            }));
        }
    public static void UpdateCycleTile(Uri smallBackgroundImage, string folder, string[] filesToShow, ShellTile currentTile)
    {
        var cycleTile = new CycleTileData
        {
            Title = "Stitch",
            SmallBackgroundImage = smallBackgroundImage,
            CycleImages          = filesToShow.Select(str => String.Format("isostore:/{0}/{1}", folder, str).ToUri()).ToArray()
        };

        currentTile.Update(cycleTile);
    }
예제 #12
0
 public void InitSecondaryTile()
 {
     if (SecondaryTile == null)
     {
         var tileUri  = new Uri(string.Format("/BookteraMainPage.xaml?{0}=true", SecondTileFragment), UriKind.Relative);
         var tileData = new CycleTileData
         {
             Title = SecondaryTileTitle,
         };
         ShellTile.Create(tileUri, tileData, supportsWideTile: false);
     }
 }
        private void UpdateTiles(IEnumerable<Uri> localImagePaths)
        {          

            ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault();
   
            if (TileToFind != null)
            {
                CycleTileData oCycleicon = new CycleTileData();
                oCycleicon.CycleImages = localImagePaths;
                TileToFind.Update(oCycleicon);
            }
          
        }
예제 #14
0
 public static void UpdateTileCyclic(string title, IList <Uri> isoStorePrefixedImageUris)
 {
     if (isoStorePrefixedImageUris.Count > 0)
     {
         var tileData = new CycleTileData()
         {
             Title = title,
             SmallBackgroundImage = isoStorePrefixedImageUris[0],
             CycleImages          = isoStorePrefixedImageUris
         };
         UpdateTile(tileData);
     }
 }
예제 #15
0
        /// <summary>
        /// Agente que ejecuta una tarea programada
        /// </summary>
        /// <param name="task">
        /// Tarea invocada
        /// </param>
        /// <remarks>
        /// Se llama a este método cuando se invoca una tarea periódica o con uso intensivo de recursos
        /// </remarks>
        protected async override void OnInvoke(ScheduledTask task)
        {
            //TODO: Agregar código para realizar la tarea en segundo plano
            // Intentaremos descargar una nueva imagen
            bool result = await this.DownloadNewImageTest();

            ShellToast toast = new ShellToast()
            {
                Content = "Se ha descargado una nueva imagen",
                Title = "Nueva Imagen",
                NavigationUri = new Uri("/Views/MainPage.xaml",UriKind.Relative)
            };

            if(result)
                toast.Show();

            // Si ya hay imagenes descargadas, las agregamos al Tile
            List<Image> images = StorageHelper.GetImages();
            if (images.Count > 0)
            {
                CycleTileData tile = new CycleTileData();
                tile.Count = images.Count;
                tile.Title = StorageHelper.GetTag() ?? "Chihuahua";
                List<Uri> uris = new List<Uri>();
                
                foreach (var item in images)
                {                    
                    uris.Add(new Uri("isostore:" + item.UrlLocal, UriKind.Absolute));                    
                }

                tile.CycleImages = uris;
                var activeTile = Microsoft.Phone.Shell.ShellTile.ActiveTiles.First();

                if (activeTile != null)
                {
                    activeTile.Update(tile);
                }


                // Cambiamos el lockscreen por una imagen random
                var isProvider = Windows.Phone.System.UserProfile.LockScreenManager.IsProvidedByCurrentApplication;
                if (isProvider)
                {
                    int random = new Random().Next(0,images.Count - 1);
                    string tempUri = "ms-appdata:///local/" + images[random].UrlLocal;
                    Windows.Phone.System.UserProfile.LockScreen.SetImageUri(new Uri("ms-appdata:///local/" + images[random].UrlLocal, UriKind.Absolute));
                }
            }
            
            NotifyComplete();
        }
예제 #16
0
        public void CreateTile(string navSource)
        {
            var cycleTile = new CycleTileData();
            cycleTile.Title = Title ?? "";
            cycleTile.Count = Count;

            cycleTile.SmallBackgroundImage = new Uri(SmallBackgroundImagePath ?? "", UriKind.Relative);
            var images = new List<Uri>();
            images.Add(new Uri(BackgroundImagePath ?? "", UriKind.Relative));
            images.Add(new Uri(BackBackgroundImagePath ?? "", UriKind.Relative));
            cycleTile.CycleImages = images;

            ShellTile.Create(new Uri(string.Format("{0}&type=cycle", navSource), UriKind.Relative), cycleTile, true);
        }
예제 #17
0
        // This function updates the application live tile
        public static void UpdateLiveTile(Canvas canv)
        {
            var bmp = new WriteableBitmap(450, 600);
            bmp.Render(canv, null);
            bmp.Invalidate();

            CycleTileData tileData = new CycleTileData();
            tileData.Title = "Sliding Puzzle";
            ShellTile tile = ShellTile.ActiveTiles.First();
            tileData.SmallBackgroundImage = new Uri("Assets/Tiles/FlipCycleTileSmall.png", UriKind.Relative);

            // shifting value for filename rotation
            int shift = 0;
            if (IsolatedStorageSettings.ApplicationSettings.Contains("imageShift"))
            {
                shift = (int)IsolatedStorageSettings.ApplicationSettings["imageShift"];
            }

            if (shift == 7)
                IsolatedStorageSettings.ApplicationSettings["imageShift"] = 0;
            else
                IsolatedStorageSettings.ApplicationSettings["imageShift"] = shift + 1;

            string filename = "/Shared/ShellContent/";
            filename = filename + shift + ".jpg";

            List<Uri> cycleImages = new List<Uri>();
            using (var isf = IsolatedStorageFile.GetUserStoreForApplication())
            {
                if (!isf.DirectoryExists("/CustomLiveTiles"))
                {
                    isf.CreateDirectory("/CustomLiveTiles");
                }
                using (var stream = isf.OpenFile(filename, System.IO.FileMode.OpenOrCreate))
                {
                    bmp.SaveJpeg(stream, 450, 600, 0, 100);
                }
                for (int i = 0; i < 8; i++)
                {
                    string fname = "Shared/ShellContent/" + (i + shift) % 8 + ".jpg";
                    if (isf.FileExists(fname))
                        cycleImages.Add(new Uri("isostore:" + fname, UriKind.Absolute));
                }
            }
            // Clear and update live tile
            tileData.CycleImages = cycleImages;
            var clearTileData = new CycleTileData("<?xml version=\"1.0\" encoding=\"utf-8\"?><wp:Notification xmlns:wp=\"WPNotification\" Version=\"2.0\"> <wp:Tile Id=\"TileID\" Template=\"CycleTile\"> <wp:SmallBackgroundImage Action=\"Clear\" /> <wp:CycleImage1 Action=\"Clear\" /> <wp:CycleImage2 Action=\"Clear\" /> <wp:CycleImage3 Action=\"Clear\" /> <wp:CycleImage4 Action=\"Clear\" /> <wp:CycleImage5 Action=\"Clear\" /> <wp:CycleImage6 Action=\"Clear\" /> <wp:CycleImage7 Action=\"Clear\" /> <wp:CycleImage8 Action=\"Clear\" /> <wp:CycleImage9 Action=\"Clear\" /> <wp:Count Action=\"Clear\" /> <wp:Title Action=\"Clear\" /> </wp:Tile></wp:Notification>");
            tile.Update(clearTileData);
            tile.Update(tileData);
        }
예제 #18
0
        private void CycleTileButtonClick(object sender, RoutedEventArgs e)
        {
            CycleTileData cycleTile = new CycleTileData();
            cycleTile.Title = "Cycle Tile";
            cycleTile.Count = 25;

            cycleTile.SmallBackgroundImage = new Uri("Assets/Tiles/FlipCycleTileSmall.png", UriKind.Relative);

            List<Uri> images = new List<Uri>();
            images.Add(new Uri("Assets/Tiles/CycleTile1.png", UriKind.Relative));
            images.Add(new Uri("Assets/Tiles/CycleTile2.png", UriKind.Relative));
            cycleTile.CycleImages = images;

            ShellTile.Create(new Uri("/MainPage.xaml?id=cycle", UriKind.Relative), cycleTile, true);
        }
예제 #19
0
        public static void UpdateLiveTile()
        {
            ROMDatabase   db   = ROMDatabase.Current;
            ShellTile     tile = ShellTile.ActiveTiles.FirstOrDefault();
            CycleTileData data = new CycleTileData();

#if !GBC
            data.Title = AppResources.ApplicationTitle;
#else
            data.Title = AppResources.ApplicationTitle2;
#endif
            IEnumerable <String> snapshots = db.GetRecentSnapshotList();
            List <Uri>           uris      = new List <Uri>(snapshots.Count());
            if (snapshots.Count() == 0)
            {
                for (int i = 0; i < 9; i++)
                {
#if !GBC
                    uris.Add(new Uri("Assets/Tiles/tileIconLarge.png", UriKind.Relative));
#else
                    uris.Add(new Uri("Assets/Tiles/tileIconLargeGBC.png", UriKind.Relative));
#endif
                }
            }
            else
            {
                int x = 0;
                for (int j = 0; j <= (3 - snapshots.Count()); j++)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        foreach (var snapshot in snapshots)
                        {
                            uris.Add(new Uri("isostore:/" + snapshot, UriKind.Absolute));
                            x++;
                            if (x >= 9)
                            {
                                i = j = 3;
                                break;
                            }
                        }
                    }
                }
            }
            data.CycleImages = uris;

            tile.Update(data);
        }
예제 #20
0
        private void btnCycleTile_Click(object sender, RoutedEventArgs e)
        {
            CycleTileData oCycleicon = new CycleTileData();
            oCycleicon.Title = "Hello Cycle Icon!!";
            oCycleicon.Count = 9;

            oCycleicon.SmallBackgroundImage = new Uri("Assets/Tiles/Cycle/159x159.png", UriKind.Relative);

            //List<Uri> images = new List<Uri>();
            //images.Add(new Uri("Assets/Tiles/Cycle/001.jpg", UriKind.Relative));
            //images.Add(new Uri("Assets/Tiles/Cycle/002.jpg", UriKind.Relative));
            //images.Add(new Uri("Assets/Tiles/Cycle/003.jpg", UriKind.Relative));
            //images.Add(new Uri("Assets/Tiles/Cycle/004.jpg", UriKind.Relative));
            //images.Add(new Uri("Assets/Tiles/Cycle/005.jpg", UriKind.Relative));
            //images.Add(new Uri("Assets/Tiles/Cycle/006.jpg", UriKind.Relative));
            //images.Add(new Uri("Assets/Tiles/Cycle/007.jpg", UriKind.Relative));
            //images.Add(new Uri("Assets/Tiles/Cycle/008.jpg", UriKind.Relative));
            //images.Add(new Uri("Assets/Tiles/Cycle/009.jpg", UriKind.Relative));
            //oCycleicon.CycleImages = images;

            //// Images could be max Nine images.
            oCycleicon.CycleImages = new Uri[]
               {
                  new Uri("Assets/Tiles/Cycle/001.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/002.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/003.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/004.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/005.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/006.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/007.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/008.jpg", UriKind.Relative),
                  new Uri("Assets/Tiles/Cycle/009.jpg", UriKind.Relative),
               };

            // find the tile object for the application tile that using "cycle" contains string in it.
            ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("cycle".ToString()));

            if (TileToFind != null && TileToFind.NavigationUri.ToString().Contains("cycle"))
            {
                TileToFind.Delete();
                ShellTile.Create(new Uri("/MainPage.xaml?id=cycle", UriKind.Relative), oCycleicon, true);
            }
            else
            {
                ShellTile.Create(new Uri("/MainPage.xaml?id=cycle", UriKind.Relative), oCycleicon, true);
            }
        }
        public void CreateCycleData()
        {
            IEnumerable<Uri> images;
            using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())
            {
                images = isoStore.GetFileNames(LiveTileFolder).Take(9).Select(
                        k => new Uri("isostore:" + LiveTileFolder + Path.GetFileName(k), UriKind.Absolute));
            }
            var cycleTile = new CycleTileData()
            {
                CycleImages = images
            };

            ShellTile.ActiveTiles
                .First()
                .Update(cycleTile);
        }
예제 #22
0
        private void btUpdated_Click(object sender, RoutedEventArgs e)
        {
            
            ShellTile ShellTile = ShellTile.ActiveTiles.First();
            Uri mp = new Uri("/MainPage.xaml?", UriKind.Relative);
            CycleTileData TileData = new CycleTileData
            {
                Title = "Cycle Tile",
                Count = 10,
                SmallBackgroundImage = new Uri("/Assets/Tiles/Image1.png", UriKind.Relative),//Gets and sets the front-side background image for the small Tile size
                CycleImages = new Uri[]
                     {
                        new Uri("/Assets/Tiles/Image4.png",UriKind.Relative),
                        new Uri("/Assets/Tiles/Image5.png",UriKind.Relative)
                     }
            };
            ShellTile.Update(TileData);
            ShellTile.Create(mp, TileData, true);
            /*
            CycleTileData cycleTile = new CycleTileData
            {
                Title = "Cycle Tile",
                Count = 10,
                SmallBackgroundImage = new Uri("/Assets/Tiles/Image1.png", UriKind.Relative),//Gets and sets the front-side background image for the small Tile size
                CycleImages = new Uri[]
                     {
                         new Uri("/Assets/Tiles/Image1.png",UriKind.Relative),
                         new Uri("/Assets/Tiles/Image2.png",UriKind.Relative),
                          new Uri("/Assets/Tiles/Image3.png",UriKind.Relative),
                     }
            };

            string uri = string.Concat("/MainPage.xaml?", "id=cycle");
            ShellTile shellTile = checkTile(uri);

            if (shellTile == null)
            {
                ShellTile.Create(new Uri(uri, UriKind.Relative), cycleTile, true);
            }
            else
            {
                shellTile.Update(cycleTile);
            }
            */
        }
예제 #23
0
        private ShellTileData CreateCycleTileData()
        {
            string[] imageNames =
            {
                "bonfillet.jpg", "bucket.jpg", "burger.jpg", "caesar.jpg", "chicken.jpg", "corn.jpg",
                "fries.jpg",     "wings.jpg"
            };

            CycleTileData cycleTileData = new CycleTileData();

            cycleTileData.Title = "Cycle tile";
            cycleTileData.Count = 7;
            cycleTileData.SmallBackgroundImage = new Uri("/Assets/pizza.lockicon.png", UriKind.Relative);
            cycleTileData.CycleImages          =
                imageNames.Select(imageName => new Uri(string.Concat("/Assets/Images/", imageName), UriKind.Relative));

            return(cycleTileData);
        }
예제 #24
0
        private void btnPinSecondary_Click(object sender, EventArgs e)
        {
            Uri smallimage  = new Uri("Images/CycleSmall.png", UriKind.Relative);
            Uri mediumimage = new Uri("Images/CycleMedium.png", UriKind.Relative);

            Uri[] mediumImages = new Uri[1];
            mediumImages[0] = mediumimage;

            CycleTileData NewTileData = new CycleTileData
            {
                SmallBackgroundImage = smallimage,
                CycleImages          = mediumImages,
                Title = SelectedCinema.Name
            };

            // Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application.
            ShellTile.Create(new Uri(String.Format("/CinemaDetails.xaml?CinemaID={0}&Region={1}", SelectedCinema.ID, Config.Region.ToString("d")), UriKind.Relative), NewTileData, true);
        }
예제 #25
0
            public static void SetGroupTile(RecipeDataGroup group, string navDataSource)
            {
                List <Uri> list = new List <Uri>();

                foreach (var recipe in group.Items)
                {
                    list.Add(new Uri(recipe.ImagePath.LocalPath, UriKind.Relative));
                }

                CycleTileData tileData = new CycleTileData()
                {
                    Title = group.Title,
                    SmallBackgroundImage = new Uri(group.GetImageUri(), UriKind.RelativeOrAbsolute),
                    CycleImages          = list
                };

                ShellTile.Create(new Uri(navDataSource, UriKind.Relative), tileData, true);
            }
예제 #26
0
        /// <summary>
        /// Creates cycle tile
        /// </summary>
        public void createCycleTile(string options)
        {
            LiveTilesOptions tileOptions;

            try
            {
                tileOptions = JsonHelper.Deserialize <LiveTilesOptions>(options);
            }
            catch
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
                return;
            }

            if (string.IsNullOrEmpty(tileOptions.SecondaryTileUri))
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
                return;
            }

            try
            {
                ShellTile foundTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(tileOptions.SecondaryTileUri));
                if (foundTile != null)
                {
                    DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Tile already exist"));
                }
                else
                {
                    CycleTileData cycleTile = CreateCycleTileData(tileOptions);
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        PhoneApplicationPage currentPage = ((PhoneApplicationFrame)Application.Current.RootVisual).Content as PhoneApplicationPage;
                        string currentUri = currentPage.NavigationService.Source.ToString().Split('?')[0];
                        ShellTile.Create(new Uri(currentUri + "?Uri=" + tileOptions.SecondaryTileUri, UriKind.Relative), cycleTile, true);
                        DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
                    });
                }
            }
            catch
            {
                DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error creating cycle tile"));
            }
        }
예제 #27
0
 private void bt_Update(object sender, RoutedEventArgs e)
 {
     ShellTile ShellTile = ShellTile.ActiveTiles.First();
     Uri mp = new Uri("/MainPage.xaml?", UriKind.Relative);
     CycleTileData TileData = new CycleTileData
     {
         Title = "Cycle Tile",
         Count = 10,
         SmallBackgroundImage = new Uri("/Assets/Tiles/Image1.png", UriKind.Relative),//Gets and sets the front-side background image for the small Tile size
         CycleImages = new Uri[]
              {
                  new Uri("/Assets/Tiles/Image1.png",UriKind.Relative),
                  new Uri("/Assets/Tiles/Image2.png",UriKind.Relative),
                   new Uri("/Assets/Tiles/Image3.png",UriKind.Relative),
              }
     };
     ShellTile.Update(TileData);
     ShellTile.Create(mp, TileData, true);
 }
        /// <summary>
        /// Update the app tile
        /// </summary>
        /// <param name="notificationCount">Count of notifications to show</param>
        /// <param name="friendList"></param>
        private void UpdateTile(int notificationCount, IEnumerable <FriendEntity> friendList)
        {
            if (friendList == null)
            {
                return;
            }

            var tile = ShellTile.ActiveTiles.First();

            if (tile == null)
            {
                return;
            }

            //create live tile
            var tileData = new CycleTileData
            {
                Title       = Resources.BdayTileLabel,
                CycleImages = friendList.Where
                              (
                    (t, i) => i < 9
                              )
                              .Select
                              (
                    t =>
                    new Uri(@"isostore:/" + FileSystem.ProfilePictureDirectory + t.UniqueId + ".jpg",
                            UriKind.Absolute)
                              ).ToArray()
            };

            //build colelction of image urls

            //update notification count
            if (notificationCount != 0)
            {
                tileData.Count = notificationCount;
            }

            //update tile
            tile.Update(tileData);
        }
        private void CreateCycleTile_Click(object sender, RoutedEventArgs e)
        {
            var cycleTile = new CycleTileData()
            {
                Title = "cycle tile",
                Count = 6,
                SmallBackgroundImage =
                    new Uri("/Assets/Tiles/george-151.png", UriKind.Relative),
                CycleImages = new Uri[]
                {
                    new Uri("/Assets/Tiles/cycle01.jpg",
                            UriKind.Relative),
                    new Uri("/Assets/Tiles/cycle02.jpg",
                            UriKind.Relative),
                    new Uri("/Assets/Tiles/cycle03.jpg",
                            UriKind.Relative),
                    new Uri("/Assets/Tiles/cycle04.jpg",
                            UriKind.Relative),
                }
            };

            ShellTile.Create(new Uri("/MainPage.xaml?tile=cycle", UriKind.Relative), cycleTile, true);
        }
예제 #30
0
        public static void CreateOrUpdateSecondaryTile(bool forceCreate)
        {
            CycleTileData data = new CycleTileData();


#if !GBC
            data.Title = AppResources.ApplicationTitle;
#else
            data.Title = AppResources.ApplicationTitle2;
#endif
            IEnumerable <String> snapshots = ROMDatabase.Current.GetRecentSnapshotList();
            List <Uri>           uris      = new List <Uri>();
            if (snapshots.Count() == 0)
            {
#if !GBC
                uris.Add(new Uri("Assets/Tiles/FlipCycleTileLarge.png", UriKind.Relative));
#else
                uris.Add(new Uri("Assets/Tiles/FlipCycleTileLargeGBC.png", UriKind.Relative));
#endif
            }
            else
            {
                foreach (var snapshot in snapshots)
                {
                    uris.Add(new Uri("isostore:/" + snapshot, UriKind.Absolute));
                }
            }
            data.CycleImages = uris;



#if GBC
            data.SmallBackgroundImage = new Uri("Assets/Tiles/FlipCycleTileSmallGBC.png", UriKind.Relative);
#else
            data.SmallBackgroundImage = new Uri("Assets/Tiles/FlipCycleTileSmall.png", UriKind.Relative);
#endif
            //find the tile to update
            bool secondaryTileAlreadyExists = false;


            foreach (var tile in ShellTile.ActiveTiles)
            {
                //make sure if it is not the default
                if (tile.NavigationUri.OriginalString == "/")
                {
                    continue;
                }

                //rom tile has '=' sign, secondary does not have it
                int index = tile.NavigationUri.OriginalString.LastIndexOf('=');
                if (index >= 0)
                {
                    continue; //this is a rom tile
                }

                //if arrive at this point, it means secondary tile already exists
                secondaryTileAlreadyExists = true;

                tile.Update(data);

                if (forceCreate)
                {
                    MessageBox.Show(AppResources.TileAlreadyPinnedText);
                }

                //no need to find more tile
                break;
            }



            if (secondaryTileAlreadyExists == false && forceCreate)
            {
                ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), data, true);
            }
        }
예제 #31
0
        private CycleTileData _CreateCycleTileData()
        {
            var tileData = new CycleTileData
            {
                Count = 3,
                Title = "Title",
                SmallBackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileSmall.png", UriKind.Relative),
                CycleImages = new List<Uri>()
                {
                    new Uri("/Assets/Tiles/00.png", UriKind.Relative),
                     new Uri("/Assets/Tiles/01.png", UriKind.Relative),
                      new Uri("/Assets/Tiles/02.png", UriKind.Relative),
                       new Uri("/Assets/Tiles/03.png", UriKind.Relative),
                        new Uri("/Assets/Tiles/04.png", UriKind.Relative),
                       new Uri("/Assets/Tiles/05.png", UriKind.Relative),
                       new Uri("/Assets/Tiles/06.png", UriKind.Relative),
                     new Uri("/Assets/Tiles/07.png", UriKind.Relative),
                      new Uri("/Assets/Tiles/08.png", UriKind.Relative)
                }
            };

            return tileData;

        }
예제 #32
0
        private static async Task SetLockscreen(string fileName)
        {
            bool hasAccessForLockscreen = LockScreenManager.IsProvidedByCurrentApplication;
            if (!hasAccessForLockscreen)
            {
                var accessRequested = await LockScreenManager.RequestAccessAsync();
                hasAccessForLockscreen = (accessRequested == LockScreenRequestResult.Granted);
            }

            if (hasAccessForLockscreen)
            {
                Uri imgUri = new Uri("ms-appdata:///Local/" + BackgroundRoot + fileName, UriKind.Absolute);
                LockScreen.SetImageUri(imgUri);
            }

            var mainTile = ShellTile.ActiveTiles.FirstOrDefault();

            if (mainTile != null)
            {
                Uri iconUri = new Uri("isostore:/" + IconRoot + fileName, UriKind.Absolute);//need to use isostore for non-Windows API
                var imgs = new List<Uri>();
                imgs.Add(iconUri);
                CycleTileData tileData = new CycleTileData();
                tileData.CycleImages = imgs;
                mainTile.Update(tileData);
            }
        }
예제 #33
0
        private void RunPeriodicJob()
        {
            Uri tileUri = new Uri(string.Concat("/MainPage.xaml?", "tile=cycle"), UriKind.Relative);
            var i = 0;
            List<String> imageNames = new List<string>();
            foreach (AppsPreview prev in listOfPreviews.Values)
            {
                if (prev.MarketApp != null)
                {
                    var name = ScreenShot.TakeInIsolatedSotrage(prev.ImageDisplayPart, "image" + i + ".jpg");
                    if (name != null)
                    {
                        imageNames.Add(name);
                        i++;
                    }
                }
            }

            CycleTileData cycleTileData = new CycleTileData();
            cycleTileData.Title = "";
            cycleTileData.Count = i;
            cycleTileData.SmallBackgroundImage = new Uri("/Image/App Roulette.png", UriKind.Relative);
            
            cycleTileData.CycleImages = imageNames.Select(
            imageName => new Uri(imageName, UriKind.Absolute));
            ShellTile tile = ShellTile.ActiveTiles.First();
             if (tile!= null)
             {
                 tile.Update(cycleTileData);
             }
        }
        private async Task UpdateTileDate(IEnumerable<PhotoItem> photos)
        {
            if (photos == null || !photos.Any())
            {
                return;
            }
            var screenPhotoStats = IsoStoreHelper.LoadFromIsoStore<ScreenPhotoStats>(ScreenPhotoStats.ScreenPhotoStatsKeyName, _ => new ScreenPhotoStats());

            var photoUris = photos.Select(pi => new Uri(pi.ExternalUrl, UriKind.RelativeOrAbsolute)).ToArray();
            for (int i = 0; i < photoUris.Length; i++)
            {
                LifeTimePolicyAccessor.Instance.SetTimeToLive(photoUris[i], TimeSpan.FromMinutes(30));
                var photoStream = await ContentAccessors.Instance.GetContent(photoUris[i], LifeTimePolicyAccessor.Instance);
                var fileName = string.Concat("CycleTileDataImg", i);
                await TileManager.Instance.SaveToSharedShellDirectory(fileName, photoStream);
                photoUris[i] = new Uri(TileManager.Instance.GetShellDirectoryFilePath(fileName), UriKind.RelativeOrAbsolute);
            }

            CycleTileData oCycleicon = new CycleTileData();
            oCycleicon.SmallBackgroundImage = new Uri("Photovoltaic-Panel.png", UriKind.Relative);
            // Images could be max Nine images.
            oCycleicon.CycleImages = photoUris;
            oCycleicon.Count = photoUris.Length;
            oCycleicon.Title = screenPhotoStats.Topic; //DateTime.Now.ToString("o"); //string.Concat("New ", photoUris.Length, " pics!"); ;
            TileManager.Instance.SetApplicationTileData(oCycleicon);
        }
예제 #35
0
        // Form our cycle tile
        public void CycleTile(
            Uri tileId,
            string title = null,
            int count = 0,
            Uri smallbackgroundimage = null,
            Uri cycleimage1 = null,
            Uri cycleimage2 = null,
            Uri cycleimage3 = null,
            Uri cycleimage4 = null,
            Uri cycleimage5 = null,
            Uri cycleimage6 = null,
            Uri cycleimage7 = null,
            Uri cycleimage8 = null,
            Uri cycleimage9 = null,
            string tileAction = null,
            bool tileProperties = false)
        {
            try
            {
                var uris = new List<Uri>
                {
                    cycleimage1,
                    cycleimage2,
                    cycleimage3,
                    cycleimage4,
                    cycleimage5,
                    cycleimage6,
                    cycleimage7,
                    cycleimage8,
                    cycleimage9,
                };

                var tileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains(tileId.ToString()));

                CycleTileData tileData;

                if (tileProperties)
                {
                    tileData = new CycleTileData
                    {
                        Title = title,
                        Count = count,
                        SmallBackgroundImage = smallbackgroundimage,
                        CycleImages = uris,
                    };
                }
                else
                {
                    // Lazy templification of the elements
                    string titleElement = "<wp:Title";
                    string countElement = "<wp:Count";
                    string smallBackgroundImageElement = "<wp:SmallBackgroundImage>";
                    string cycleImage1Element = "<wp:CycleImage1>";
                    string cycleImage2Element = "<wp:CycleImage2>";
                    string cycleImage3Element = "<wp:CycleImage3>";
                    string cycleImage4Element = "<wp:CycleImage4>";
                    string cycleImage5Element = "<wp:CycleImage5>";
                    string cycleImage6Element = "<wp:CycleImage6>";
                    string cycleImage7Element = "<wp:CycleImage7>";
                    string cycleImage8Element = "<wp:CycleImage8>";
                    string cycleImage9Element = "<wp:CycleImage9>";

                    // Determine if we're supposed to be clearing some values
                    if (count == 0) { countElement = countElement + " Action=\"Clear\">"; } else { countElement = countElement + ">"; }
                    if (title == "") { titleElement = titleElement + " Action=\"Clear\">"; } else { titleElement = titleElement + ">"; }

                    // Form the XML template for the tile
                    string tileDataXmlString =
                        "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
                        "<wp:Notification xmlns:wp=\"WPNotification\" Version=\"2.0\">" +
                           "<wp:Tile Id=\"" + tileId + "\" Template=\"CycleTile\">" +
                              countElement + count + "</wp:Count>" +
                              titleElement + title + "</wp:Title>" +
                              smallBackgroundImageElement + smallbackgroundimage + "</wp:SmallBackgroundImage>" +
                              cycleImage1Element + cycleimage1 + "</wp:CycleImage1>" +
                              cycleImage2Element + cycleimage2 + "</wp:CycleImage2>" +
                              cycleImage3Element + cycleimage3 + "</wp:CycleImage3>" +
                              cycleImage4Element + cycleimage4 + "</wp:CycleImage4>" +
                              cycleImage5Element + cycleimage5 + "</wp:CycleImage5>" +
                              cycleImage6Element + cycleimage6 + "</wp:CycleImage6>" +
                              cycleImage7Element + cycleimage7 + "</wp:CycleImage7>" +
                              cycleImage8Element + cycleimage8 + "</wp:CycleImage8>" +
                              cycleImage9Element + cycleimage9 + "</wp:CycleImage9>" +
                           "</wp:Tile> " +
                        "</wp:Notification>";

                    // Construct IconicTileData using the overload with XML string
                    tileData = new CycleTileData(tileDataXmlString);
                }

                // Go do something to the tile based on the tile action
                DoTileAction(tileAction, tileId, tileToFind, tileData);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.ToString());
            }
        }
예제 #36
0
        private void startTileTask(ScheduledTask task)
        { 
            // You must use IconicTileData because TemplateIconic tile template is set in WMAppMainifest.xml.
            // However, if you change the tile template in WMAppMainifest.xml, you must change the constructor below to appropriately match, 
            // such as CycleTileData or StandardTileData.
            ShellTile ShellTile = ShellTile.ActiveTiles.First();
            Uri mp = new Uri("/MainPage.xaml?", UriKind.Relative);
            CycleTileData TileData = new CycleTileData
            {
                Title = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString(),
                Count = new Random().Next(1,10),
                SmallBackgroundImage = new Uri("/Assets/Tiles/Image1.png", UriKind.Relative),//Gets and sets the front-side background image for the small Tile size
                CycleImages = new Uri[]
                     {
                         new Uri("/Assets/Tiles/Image1.png",UriKind.Relative),
                         new Uri("/Assets/Tiles/Image2.png",UriKind.Relative),
                          new Uri("/Assets/Tiles/Image3.png",UriKind.Relative),
                        
                     }
            };
     

            ShellTile mainTile = ShellTile.ActiveTiles.First();
            if (mainTile != null)
            {
                mainTile.Update(TileData);
            }

            // If debugging is enabled, launch the agent again in one minute.
#if DEBUG_AGENT
            ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromSeconds(60));
           // ScheduledActionService.LaunchForTest(task.Name, TimeSpan.FromTicks(10));
#endif

            // Call NotifyComplete to let the system know the agent is done working.
            NotifyComplete();
        }
예제 #37
0
        public static void UpdateLiveTile()
        {
            ROMDatabase db = ROMDatabase.Current;
            ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault();
            CycleTileData data = new CycleTileData();
            data.Title = AppResources.ApplicationTitle;
            IEnumerable<String> snapshots = db.GetRecentSnapshotList();
            List<Uri> uris = new List<Uri>(snapshots.Count());
            if (snapshots.Count() == 0)
            {
                for (int i = 0; i < 9; i++)
                {
                    uris.Add(new Uri("Assets/Tiles/tileIconLarge.png", UriKind.Relative));
                }
            }
            else
            {
                int x = 0;
                for (int j = 0; j <= (3 - snapshots.Count()); j++)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        foreach (var snapshot in snapshots)
                        {
                            uris.Add(new Uri("isostore:/" + snapshot, UriKind.Absolute));
                            x++;
                            if (x >= 9)
                            {
                                i = j = 3;
                                break;
                            }
                        }
                    }
                }

            }
            data.CycleImages = uris;

            tile.Update(data);
        }
예제 #38
0
        private static void UpdateLiveTile(List<object> tileImages, int messageCount, int liveTileCounter, int startTileCounter)
        {
            var activeTiles = ShellTile.ActiveTiles;
            var activeTile = activeTiles.FirstOrDefault();
            if (activeTile != null)
            {
                var uris = new List<Uri>();

                Utility.Shuffle(tileImages);

                if (startTileCounter != liveTileCounter)
                {
                    uris.Add(new Uri(string.Format("isostore:/Shared/ShellContent/tileCache{0}.jpg", startTileCounter), UriKind.Absolute));
                }

                foreach (var image in tileImages.Take(startTileCounter != liveTileCounter ? 8 : 9))
                {
                    uris.Add(new Uri("isostore:/Shared/ShellContent/" + ((string)image), UriKind.Absolute));
                }

                if (uris.Count == 0)
                {
                    uris.Add(new Uri("/Assets/BaconographyPhoneIconWide.png", UriKind.Relative));
                }

                CycleTileData cycleTile = new CycleTileData()
                {
                    Title = "Baconography",
                    Count = messageCount,
                    SmallBackgroundImage = new Uri("/Assets/ApplicationIconSmall.png", UriKind.Relative),
                    CycleImages = uris
                };
                activeTile.Update(cycleTile);
            }
        }
예제 #39
0
        private ShellTileData CreateCycleTileData()
        {
            string[] imageNames = { 
        "bonfillet.jpg", "bucket.jpg", "burger.jpg", "caesar.jpg", 
        "chicken.jpg", "corn.jpg", "fries.jpg", "wings.jpg"
    };
            CycleTileData cycleTileData = new CycleTileData();
            cycleTileData.Title = "Cycle tile";
            cycleTileData.Count = 7;
            cycleTileData.SmallBackgroundImage = new Uri("/Assets/pizza.lockicon.png", UriKind.Relative);
            cycleTileData.CycleImages = imageNames.Select(
            imageName => new Uri(string.Concat("/Assets/Images/", imageName), UriKind.Relative));

            return cycleTileData;
        }
예제 #40
0
 private CycleTileData CreateCycleTileData(LiveTilesOptions liveTileOptions)
 {
     CycleTileData tileData = new CycleTileData();
     if (!string.IsNullOrEmpty(liveTileOptions.Title))
     {
         tileData.Title = liveTileOptions.Title;
     }
     if (liveTileOptions.Count > 0)
     {
         tileData.Count = liveTileOptions.Count;
     }
     if (!string.IsNullOrEmpty(liveTileOptions.Image))
     {
         string[] imgs = liveTileOptions.Image.Split('|');
         Uri[] imgUris = new Uri[imgs.Length];
         for (int i = 0; i < imgs.Length; ++i)
         {
             imgUris[i] = new Uri(imgs[i], UriKind.Relative);
         }
         tileData.CycleImages = imgUris;
         tileData.SmallBackgroundImage = imgUris[0];
     }
     return tileData;
 }
예제 #41
0
        private static async Task SetLockScreen(string filename) {

            //http://msdn.microsoft.com/en-us/library/windows/apps/jj206968(v=vs.105).aspx


            /*
            <Extensions>
                <Extension ExtensionName="LockScreen_Background" ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}" TaskID="_default" />
            </Extensions>
            */
            //place above code from above url in "WMAppManifest file" which should be opened with "xml editor" with "Encoding" and "Autodetecting"
            
            //This makes our app a Lockscreen background Provider
 
            //Lockscreen design guidelines
            //http://msdn.microsoft.com/en-us/library/windows/apps/jj662927(v=vs.105).aspx

            bool hasAccessForLockScreen = LockScreenManager.IsProvidedByCurrentApplication;

            if (!hasAccessForLockScreen)
            {
                //if request is not given , this will call prompt the user for permission
                var accessRequested = await LockScreenManager.RequestAccessAsync();

                //only do further work if the access is granted
                hasAccessForLockScreen = (accessRequested == LockScreenRequestResult.Granted);
            }

            if (hasAccessForLockScreen)
            {
                Uri imgUri = new Uri("ms-appdata:///local/" + Backgroundroot + filename,UriKind.Absolute);
                LockScreen.SetImageUri(imgUri);
            }


            var mainTille = ShellTile.ActiveTiles.FirstOrDefault();

            //setting main tile
            if (null != mainTille)
            {
                Uri iconUri = new Uri("isostore:///" + Iconroot +filename,UriKind.Absolute);
                var imgs = new List<Uri>();
                imgs.Add(iconUri);

                CycleTileData tileData = new CycleTileData();
                tileData.CycleImages = imgs;
                //tileData.IconImage = imgUri;

                mainTille.Update(tileData);

            }

        }
예제 #42
0
        //Wird am Anfang ausgeführt
        //--------------------------------------------------------------------------------------------------------------------
        static ScheduledAgent()
        {
            //Vorbereitung
            //-----------------------------------------------------------------------------------------------------------------

            //Variabeln erstellen
            bool   FullVersion = false;
            bool   Run         = true;
            string Settings;
            string SetFolder     = "*";
            string SetBgColor    = "#FF000000";
            string SetFrameColor = "NO";
            string SetAlphaColor = "NO";
            int    SetFrameSize  = 0;
            int    SetInfoAlpha  = 0;
            int    SwapImage     = 1;
            string FoldersAll    = "/";

            string[] Folders;
            string   ImagesAll = "/";
            string   DatFile;
            string   InfoSize     = "4";
            bool     InfoTop      = false;
            bool     SetCycleTile = true;
            bool     SetLogoStart = true;
            //Anzahl der Styles
            int cStyles = 4;
            //IsoStore file erstellen
            IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
            //bool IsLockscreenApp = true;
            DateTime dt     = DateTime.Now;
            DateTime dt_Now = DateTime.Now;
            //Prüfen ob CycleTile schon erstellt wurde
            ShellTile oTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("flip".ToString()));

            //Prüfen ob momentan Lockscreen App
            bool IsLockscreenApp = true;

            if (Windows.Phone.System.UserProfile.LockScreenManager.IsProvidedByCurrentApplication)
            {
                //IsLockscreenApp auf true stellen
                IsLockscreenApp = true;
            }
            else
            {
                IsLockscreenApp = false;
            }


            //FullVersion laden
            IsolatedStorageFileStream filestream = file.OpenFile("Settings/FullVersion.txt", FileMode.Open);
            StreamReader sr   = new StreamReader(filestream);
            string       temp = sr.ReadToEnd();

            filestream.Close();
            int temp2 = Convert.ToInt32(temp);

            if (temp2 == 1)
            {
                FullVersion = true;
            }

            if (FullVersion == false)
            {
                //FirstTime laden //Zeit der Installation
                filestream = file.OpenFile("Settings/FirstTime.txt", FileMode.Open);
                sr         = new StreamReader(filestream);
                temp       = sr.ReadToEnd();
                filestream.Close();
                dt = Convert.ToDateTime(temp);

                //Prüfen ob Trial Zeit abgelaufen
                TimeSpan diff    = dt_Now - dt;
                int      MinToGo = 1440 - Convert.ToInt32(diff.TotalMinutes);
                //Wenn Zeit abgelaufen
                if (MinToGo <= 0)
                {
                    //Angeben das Bild auf Leer gestellt wird
                    Run = false;
                }
            }


            //Settings laden //Einstellungen
            filestream = file.OpenFile("Settings/Settings.txt", FileMode.Open);
            sr         = new StreamReader(filestream);
            Settings   = sr.ReadToEnd();
            filestream.Close();


            //Folders.dat laden //Ordner Dateien
            filestream = file.OpenFile("Folders.dat", FileMode.Open);
            sr         = new StreamReader(filestream);
            FoldersAll = sr.ReadToEnd();
            filestream.Close();
            FoldersAll = FoldersAll.TrimEnd(new char[] { '\r', '\n' });


            //Einstellungen umsetzen
            string[] aSettings = Regex.Split(Settings, ";");
            //Ordner
            SetFolder = aSettings[0];
            //Hintergrundfarbe
            SetBgColor = aSettings[1];
            //Rahmenfarbe
            SetFrameColor = aSettings[2];
            //Alphafarbe
            SetAlphaColor = aSettings[3];
            //Rahmen Größe
            SetFrameSize = Convert.ToInt32(aSettings[4]);
            //Info Bereich Alpha
            SetInfoAlpha = Convert.ToInt32(aSettings[5]);
            //Swap Image
            SwapImage = Convert.ToInt32(aSettings[6]);
            //InfoSize
            InfoSize = Convert.ToString(aSettings[7]);
            //InfoTop
            InfoTop = Convert.ToBoolean(aSettings[8]);
            //Logo beim Start
            SetLogoStart = Convert.ToBoolean(aSettings[9]);


            //StyleSettings laden
            filestream = file.OpenFile("Settings/StylesSettings.txt", FileMode.Open);
            sr         = new StreamReader(filestream);
            string stylesSettings = sr.ReadToEnd();

            filestream.Close();

            //Variablen erstellen
            string iStyle  = "1.txt";
            int    iMirrow = 1;
            Random rand    = new Random();

            //Prüfen ob Settings vorhanden
            stylesSettings = stylesSettings.Trim(new char[] { '\r', '\n' });
            if (stylesSettings.Length > 1)
            {
                //StyleSettings zerlegen
                string[] splitStylesSettings = Regex.Split(stylesSettings, ";");
                int      selectedStyle       = rand.Next(1, splitStylesSettings.Count());
                if (selectedStyle == splitStylesSettings.Count())
                {
                    selectedStyle--;
                }
                //Nach hintern verschobenen Style zurücksetzen
                selectedStyle--;
                //Auswahl zerlegen
                splitStylesSettings[selectedStyle] = splitStylesSettings[selectedStyle].Trim(new char[] { '\r', '\n' });
                string[] splitTemp = Regex.Split(splitStylesSettings[selectedStyle], ",");
                //Auswahl erstellen
                iStyle  = splitTemp[0];
                iMirrow = Convert.ToInt32(splitTemp[1]);
            }

            //Set Spiegelung erstellen
            int MH = 1;
            int MV = 1;

            if (iMirrow == 2)
            {
                MH = 2;
            }
            if (iMirrow == 3)
            {
                MH = 2;
                MV = 2;
            }
            if (iMirrow == 4)
            {
                MV = 2;
            }

            //Style laden
            filestream = file.OpenFile("Styles/" + iStyle, FileMode.Open);
            sr         = new StreamReader(filestream);
            string style = sr.ReadToEnd();

            filestream.Close();


            //Style Datei zerlegen
            string[] images = Regex.Split(style, ";");
            //Anzahl der Bilder erstellen
            int cImages = images.Count() - 1;


            //Bilderliste erstellen
            bool noImage = true;

            string[] lImages = new string[cImages];


            //Ordner auswählen
            string loadFolder = "*";
            //Dat File
            string datFile = "";



            //Prüfen ob Random Bilder ausgewählt ist
            if (SetFolder == "**")
            {
                //Ordner Datei laden
                filestream = file.OpenFile("Folders.dat", FileMode.Open);
                sr         = new StreamReader(filestream);
                string FoldersDat = sr.ReadToEnd();
                FoldersDat = FoldersDat.TrimEnd(new char[] { '\r', '\n' });
                filestream.Close();

                //Ordnerdatei aufteilen
                string[] FoldersSplit  = Regex.Split(FoldersDat, "/");
                int      cFoldersSplit = FoldersSplit.Count();
                string   AllPictures   = "";

                //Unterordner Dateien laden
                for (int i = 1; i < (cFoldersSplit - 1); i++)
                {
                    //Pictures.Dat laden
                    filestream = file.OpenFile("Thumbs/" + FoldersSplit[i] + ".dat", FileMode.Open);
                    sr         = new StreamReader(filestream);
                    string ImagesDat = sr.ReadToEnd();
                    ImagesDat = ImagesDat.TrimEnd(new char[] { '\r', '\n' });
                    ImagesDat = ImagesDat.Trim(new char[] { '/' });
                    filestream.Close();

                    //Prüfen ob Bilder vorhanden
                    if (ImagesDat.Length >= 1)
                    {
                        //Pictures.Dat trennen
                        string[] ImagesSplit  = Regex.Split(ImagesDat, "/");
                        int      cImagesSplit = ImagesSplit.Count();
                        //Bilder durchlaufen und All Pictures erstellen
                        for (int i2 = 0; i2 < cImagesSplit; i2++)
                        {
                            AllPictures += "Folders/" + FoldersSplit[i] + "/" + ImagesSplit[i2] + "///";
                        }
                    }
                }

                //Doppelte Trennzeichen entfernen
                AllPictures = AllPictures.Trim(new char[] { '/' });

                //Wenn Bilder vorhanden
                if (AllPictures.Length >= 1)
                {
                    //Alle Bilder aus Ordner laden
                    string[] tImages  = Regex.Split(AllPictures, "///");
                    int      ctImages = tImages.Count();

                    //Bilder verarbeiten
                    string[] sImages = new string[ctImages];
                    for (int i = 0; i < ctImages; i++)
                    {
                        sImages[i] = tImages[i];
                    }
                    //Bilder aus Bilderliste wählen und Bilder liste dabei verkleinern
                    for (int i = 0; i < cImages; i++)
                    {
                        //Bild auswählen
                        int csImages = sImages.Count();
                        int c        = rand.Next(1, (csImages + 1));
                        if (c == (csImages + 1))
                        {
                            c--;
                        }
                        c--;

                        lImages[i] = sImages[c];
                        //Bilderliste neu erstellen
                        if (sImages.Count() == 1)
                        {
                            sImages = new string[ctImages];
                            for (int i2 = 0; i2 < ctImages; i2++)
                            {
                                sImages[i2] = tImages[i2];
                            }
                        }
                        else
                        {
                            int      cs       = sImages.Count();
                            int      x        = 0;
                            string[] nsImages = new string[(cs - 1)];
                            for (int i3 = 0; i3 < cs; i3++)
                            {
                                if (i3 != c)
                                {
                                    nsImages[x] = sImages[i3];
                                    x++;
                                }
                            }
                            sImages = new string[(cs - 1)];
                            for (int i3 = 0; i3 < sImages.Count(); i3++)
                            {
                                sImages[i3] = nsImages[i3];
                            }
                        }
                    }
                }
                //Wenn keine Bilder existieren
                else
                {
                    //Immer no Image laden
                    for (int i = 0; i < cImages; i++)
                    {
                        lImages[i] = "NoImage.jpg";
                    }
                }
            }



            //Wenn Ordner oder Random Ordner ausgewählt wurde
            else
            {
                //Prüfen ob Settings Folder besteht
                if (SetFolder != "*")
                {
                    string[] tFolders = Regex.Split(FoldersAll, "/" + SetFolder + "/");
                    if (tFolders.Count() <= 1)
                    {
                        //Settings neu erstellen
                        SetFolder = "*";
                        Settings  = SetFolder + ";" + SetBgColor + ";" + SetFrameColor + ";" + SetAlphaColor + ";" + SetFrameSize + ";" + SetInfoAlpha + ";" + SwapImage + ";" + InfoSize + ";" + Convert.ToString(InfoTop) + ";" + Convert.ToString(SetLogoStart) + ";";
                        //Einstellungen speichern
                        filestream = file.CreateFile("Settings/Settings.txt");
                        StreamWriter sw = new StreamWriter(filestream);
                        sw.WriteLine(Settings);
                        sw.Flush();
                        filestream.Close();
                    }
                    else
                    //Prüfen ob Dateien in Ordner
                    {
                        //Images.dat laden //Bilder Dateien
                        filestream = file.OpenFile("Thumbs/" + SetFolder + ".dat", FileMode.Open);
                        sr         = new StreamReader(filestream);
                        ImagesAll  = sr.ReadToEnd();
                        filestream.Close();
                        ImagesAll = ImagesAll.TrimEnd(new char[] { '\r', '\n' });

                        string[] tImages = Regex.Split(ImagesAll, "/");
                        if (tImages.Count() < 3)
                        {
                            //Settings neu erstellen
                            SetFolder = "*";
                            Settings  = Settings = SetFolder + ";" + SetBgColor + ";" + SetFrameColor + ";" + SetAlphaColor + ";" + SetFrameSize + ";" + SetInfoAlpha + ";" + SwapImage + ";" + InfoSize + ";" + Convert.ToString(InfoTop) + ";" + Convert.ToString(SetLogoStart) + ";";
                            //Einstellungen speichern
                            filestream = file.CreateFile("Settings/Settings.txt");
                            StreamWriter sw = new StreamWriter(filestream);
                            sw.WriteLine(Settings);
                            sw.Flush();
                            filestream.Close();
                        }
                        else
                        {
                            //LoadFolder erstellen
                            loadFolder = "Folders/" + SetFolder + "/";
                            //Images.dat laden //Bilder Dateien
                            filestream = file.OpenFile("Thumbs/" + SetFolder + ".dat", FileMode.Open);
                            sr         = new StreamReader(filestream);
                            ImagesAll  = sr.ReadToEnd();
                            filestream.Close();
                            ImagesAll = ImagesAll.TrimEnd(new char[] { '\r', '\n' });
                            noImage   = false;
                        }
                    }
                }


                //Wenn Loading Folder nicht besteht //Random
                if (loadFolder == "*")
                {
                    //Ordner Liste erstellen
                    string   tFolders = "";
                    string[] tf       = Regex.Split(FoldersAll, "/");
                    string[] lFolders = new string[(tf.Count() - 2)];
                    for (int i21 = 1; i21 < tf.Count() - 1; i21++)
                    {
                        lFolders[(i21 - 1)] = tf[i21];
                    }

                    //Ordner Anzahl erstellen
                    int cFolders = lFolders.Count();

                    //Ordner durchlaufen und prüfen ob Bilder vorhanden
                    for (int i2 = 0; i2 < cFolders; i2++)
                    {
                        //Images.dat laden //Bilder Dateien
                        filestream = file.OpenFile("/Thumbs/" + lFolders[i2] + ".dat", FileMode.Open);
                        sr         = new StreamReader(filestream);
                        ImagesAll  = sr.ReadToEnd();
                        filestream.Close();
                        ImagesAll = ImagesAll.TrimEnd(new char[] { '\r', '\n' });

                        //Bilder aufsplitten
                        string[] tImages = Regex.Split(ImagesAll, "/");
                        if (tImages.Count() > 2)
                        {
                            tFolders += i2 + ";";
                        }
                    }

                    if (tFolders.Length > 0)
                    {
                        string[] tlFolders  = Regex.Split(tFolders, ";");
                        int      ctlFolders = tlFolders.Count() - 1;
                        int      iFolder    = rand.Next(1, tlFolders.Count());

                        int temp22 = Convert.ToInt32(tlFolders[iFolder - 1]);
                        //loadFolder erstellen
                        loadFolder = "Folders/" + lFolders[temp22] + "/";
                        datFile    = "Thumbs/" + lFolders[temp22] + ".dat";
                        //Images.dat laden //Bilder Dateien
                        filestream = file.OpenFile(datFile, FileMode.Open);
                        sr         = new StreamReader(filestream);
                        ImagesAll  = sr.ReadToEnd();
                        filestream.Close();
                        ImagesAll = ImagesAll.TrimEnd(new char[] { '\r', '\n' });
                        noImage   = false;
                    }
                }

                //Wenn Bilder existieren
                if (noImage == false & Run == true)
                {
                    //Alle Bilder aus Ordner laden
                    string[] tI      = Regex.Split(ImagesAll, "/");
                    string[] tImages = new string[(tI.Count() - 2)];
                    for (int i27 = 1; i27 < (tI.Count() - 1); i27++)
                    {
                        tImages[(i27 - 1)] = tI[i27];
                    }
                    int      ctImages = tImages.Count();
                    string[] sImages  = new string[ctImages];
                    for (int i = 0; i < ctImages; i++)
                    {
                        sImages[i] = tImages[i];
                    }
                    //Bilder aus Bilderliste wählen und Bilder liste dabei verkleinern
                    for (int i = 0; i < cImages; i++)
                    {
                        //Bild auswählen
                        int csImages = sImages.Count();
                        int c        = rand.Next(1, (csImages + 1));
                        if (c == (csImages + 1))
                        {
                            c--;
                        }
                        c--;

                        lImages[i] = loadFolder + sImages[c];
                        //Bilderliste neu erstellen
                        if (sImages.Count() == 1)
                        {
                            sImages = new string[ctImages];
                            for (int i2 = 0; i2 < ctImages; i2++)
                            {
                                sImages[i2] = tImages[i2];
                            }
                        }
                        else
                        {
                            int      cs       = sImages.Count();
                            int      x        = 0;
                            string[] nsImages = new string[(cs - 1)];
                            for (int i3 = 0; i3 < cs; i3++)
                            {
                                if (i3 != c)
                                {
                                    nsImages[x] = sImages[i3];
                                    x++;
                                }
                            }
                            sImages = new string[(cs - 1)];
                            for (int i3 = 0; i3 < sImages.Count(); i3++)
                            {
                                sImages[i3] = nsImages[i3];
                            }
                        }
                    }
                }


                //Wenn keine Bilder existieren
                else
                {
                    //Immer no Image laden
                    for (int i = 0; i < cImages; i++)
                    {
                        lImages[i] = "NoImage.jpg";
                    }
                }
            }
            //-----------------------------------------------------------------------------------------------------------------



            //Bild erstellen
            //-----------------------------------------------------------------------------------------------------------------
            Deployment.Current.Dispatcher.BeginInvoke(delegate
            {
                //Bild erstellen
                var Background = new WriteableBitmap(480, 800);

                //Hintergrundfarbe erstellen
                Color backgroundColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                if (SetBgColor != "NO")
                {
                    if (SetBgColor == "AC")
                    {
                        backgroundColor = (Color)Application.Current.Resources["PhoneAccentColor"];
                    }
                    else if (SetBgColor == "BC")
                    {
                        backgroundColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                    }
                    else
                    {
                        if (SetBgColor.Length == 9)
                        {
                            byte A             = Convert.ToByte(SetBgColor.Substring(1, 2), 16);
                            byte R             = Convert.ToByte(SetBgColor.Substring(3, 2), 16);
                            byte G             = Convert.ToByte(SetBgColor.Substring(5, 2), 16);
                            byte B             = Convert.ToByte(SetBgColor.Substring(7, 2), 16);
                            SolidColorBrush sb = new SolidColorBrush(Color.FromArgb(A, R, G, B));
                            backgroundColor    = sb.Color;
                        }
                    }
                }
                Background.Clear(backgroundColor);

                //Rahmenfarbe erstellen
                Color frameColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                if (SetFrameColor != "NO")
                {
                    if (SetFrameColor == "AC")
                    {
                        frameColor = (Color)Application.Current.Resources["PhoneAccentColor"];
                    }
                    else if (SetFrameColor == "BC")
                    {
                        frameColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                    }
                    else
                    {
                        if (SetFrameColor.Length == 9)
                        {
                            byte A             = Convert.ToByte(SetFrameColor.Substring(1, 2), 16);
                            byte R             = Convert.ToByte(SetFrameColor.Substring(3, 2), 16);
                            byte G             = Convert.ToByte(SetFrameColor.Substring(5, 2), 16);
                            byte B             = Convert.ToByte(SetFrameColor.Substring(7, 2), 16);
                            SolidColorBrush sb = new SolidColorBrush(Color.FromArgb(A, R, G, B));
                            frameColor         = sb.Color;
                        }
                    }
                }

                //Tiles durchlaufen und erstellen
                for (int i = 0; i < lImages.Count(); i++)
                {
                    //Daten aus Style verarbeiten
                    string[] splitImage = Regex.Split(images[i], ",");
                    int x1   = Convert.ToInt32(splitImage[0]);
                    int y1   = Convert.ToInt32(splitImage[1]);
                    int x2   = Convert.ToInt32(splitImage[2]);
                    int y2   = Convert.ToInt32(splitImage[3]);
                    int size = x2 - x1;

                    //Spiegelung errechnen
                    if (MH == 2)
                    {
                        x1 = 480 - x1 - size;
                        x2 = x1 + size;
                    }
                    if (MV == 2)
                    {
                        y1 = 800 - y1 - size;
                        y2 = y1 + size;
                    }

                    //Prüfen welches File geladen wird
                    string LoadFile = lImages[i];
                    if (size == 100)
                    {
                        LoadFile = Regex.Replace("/" + LoadFile, "/Folders/", "/Thumbs/");
                    }

                    //Tile erstellen
                    byte[] tempData;
                    MemoryStream tempMs;
                    var tile = new WriteableBitmap(0, 0);
                    using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
                    {
                        using (IsolatedStorageFileStream isfs = isf.OpenFile(LoadFile, FileMode.Open, FileAccess.Read))
                        {
                            tempData = new byte[isfs.Length];
                            isfs.Read(tempData, 0, tempData.Length);
                            isfs.Close();
                        }
                    }
                    tempMs = new MemoryStream(tempData);
                    tile   = new WriteableBitmap(0, 0);
                    tile.SetSource(tempMs);

                    if (size != 320)
                    {
                        tile = tile.Resize(size, size, WriteableBitmapExtensions.Interpolation.Bilinear);
                    }

                    //Tile in Bild schneiden
                    Background.Blit(new Rect(x1, y1, size, size), tile, new Rect(0, 0, size, size));

                    //Tempomäre Bilder löschen
                    tempData = null;
                    tempMs   = null;
                    tile     = null;

                    //Rahmen erstellen, wenn eingestellt
                    if (SetFrameColor != "NO" & SetFrameSize != 0)
                    {
                        for (int i5 = 0; i5 < SetFrameSize; i5++)
                        {
                            Background.DrawRectangle((x1 + i5), (y1 + i5), (x2 - i5), (y2 - i5), frameColor);
                        }
                    }
                }

                //Infofarbe erstellen
                Color alphaColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                if (SetAlphaColor != "NO")
                {
                    if (SetAlphaColor == "AC")
                    {
                        alphaColor = (Color)Application.Current.Resources["PhoneAccentColor"];
                    }
                    else if (SetAlphaColor == "BC")
                    {
                        alphaColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];
                    }
                    else
                    {
                        if (SetAlphaColor.Length == 9)
                        {
                            byte A             = Convert.ToByte(SetAlphaColor.Substring(1, 2), 16);
                            byte R             = Convert.ToByte(SetAlphaColor.Substring(3, 2), 16);
                            byte G             = Convert.ToByte(SetAlphaColor.Substring(5, 2), 16);
                            byte B             = Convert.ToByte(SetAlphaColor.Substring(7, 2), 16);
                            SolidColorBrush sb = new SolidColorBrush(Color.FromArgb(A, R, G, B));
                            alphaColor         = sb.Color;
                        }
                    }
                }
                //Farbe mit Alpha erstellen
                byte a = Convert.ToByte(0);
                if (SetInfoAlpha != 9)
                {
                    a = Convert.ToByte(255 - (28 * SetInfoAlpha));
                }
                byte r = alphaColor.R;
                byte g = alphaColor.G;
                byte b = alphaColor.B;
                SolidColorBrush sb2 = new SolidColorBrush(Color.FromArgb(a, r, g, b));
                alphaColor          = sb2.Color;

                //Infofarbe in Bild schneiden
                if (SetAlphaColor != "NO" & InfoSize != "0")
                {
                    //Info Größe bestimmen
                    int tSize = 455;
                    if (InfoSize == "3")
                    {
                        tSize = 345;
                    }
                    else if (InfoSize == "2")
                    {
                        tSize = 235;
                    }
                    else if (InfoSize == "1")
                    {
                        tSize = 125;
                    }
                    var tile = new WriteableBitmap(480, tSize);
                    tile.Clear(alphaColor);
                    //Tile in Bild schneiden
                    Background.Blit(new Rect(0, (800 - tSize), 480, tSize), tile, new Rect(0, 0, 480, tSize));
                    tile = null;
                }

                //InfoTop erstellen
                if (InfoTop == true & SetAlphaColor != "NO")
                {
                    //Tile erstellen
                    var tile = new WriteableBitmap(480, 30);
                    tile.Clear(alphaColor);
                    //Tile in Bild schneiden
                    Background.Blit(new Rect(0, 0, 480, 30), tile, new Rect(0, 0, 480, 30));
                    tile = null;
                }

                //Prüfen ob Ordner schon vorhanden
                if (!file.DirectoryExists("Background"))
                {
                    file.CreateDirectory("Background");
                }
                //Prüfen ob Bild vorhanden
                string SaveFile;
                if (file.FileExists("Background/" + (SwapImage - 1) + ".jpg"))
                {
                    file.DeleteFile("Background/" + (SwapImage - 1) + ".jpg");
                }
                if (file.FileExists("Background/" + (SwapImage - 2) + ".jpg"))
                {
                    file.DeleteFile("Background/" + (SwapImage - 2) + ".jpg");
                }
                //Swap Image erhöhen
                SwapImage++;
                //SaveFile neu erstellen
                SaveFile = "Background/" + SwapImage + ".jpg";

                //Einstellungen neu erstellen
                Settings = SetFolder + ";" + SetBgColor + ";" + SetFrameColor + ";" + SetAlphaColor + ";" + SetFrameSize + ";" + SetInfoAlpha + ";" + SwapImage + ";" + InfoSize + ";" + Convert.ToString(InfoTop) + ";" + Convert.ToString(SetLogoStart) + ";";
                //Einstellungen speichern
                filestream       = file.CreateFile("Settings/Settings.txt");
                StreamWriter sw2 = new StreamWriter(filestream);
                sw2.WriteLine(Settings);
                sw2.Flush();
                filestream.Close();

                //Datei in Isolated Storage schreiben
                var isolatedStorageFileStream = file.CreateFile(SaveFile);
                Background.SaveJpeg(isolatedStorageFileStream, 480, 800, 0, 100);
                isolatedStorageFileStream.Close();
                Background = null;

                //Lockscreen erstellen
                string filePathOfTheImage = SaveFile;
                var schema = "ms-appdata:///Local/";
                var uri    = new Uri(schema + filePathOfTheImage, UriKind.RelativeOrAbsolute);
                //Wenn Lockscreen App, Lockscreen setzen
                if (IsLockscreenApp == true)
                {
                    Windows.Phone.System.UserProfile.LockScreen.SetImageUri(uri);
                }



                //Cycle Tyle updaten
                if (oTile != null && oTile.NavigationUri.ToString().Contains("flip"))
                {
                    //Cycle Bilder erstellen
                    List <Uri> list = new List <Uri>();
                    for (int i = 0; i < 9; i++)
                    {
                        if (lImages[i] != "false")
                        {
                            if (file.FileExists("Shared/ShellContent/myImage" + i + ".jpg"))
                            {
                                file.DeleteFile("Shared/ShellContent/myImage" + i + ".jpg");
                            }
                            file.CopyFile(lImages[i], "Shared/ShellContent/myImage" + i + ".jpg");
                            list.Add(new Uri("isostore:/Shared/ShellContent/myImage" + i + ".jpg", UriKind.Absolute));
                        }
                    }


                    //CycleTile erstellen
                    CycleTileData tileData = new CycleTileData()
                    {
                        Title = "",
                        Count = null,
                        SmallBackgroundImage = new Uri("Icon.png", UriKind.RelativeOrAbsolute),
                        CycleImages          = list
                    };

                    oTile.Update(tileData);
                }
            });
            //-----------------------------------------------------------------------------------------------------------------
        }
 private void CreateCycleTile_Click(object sender, RoutedEventArgs e)
 {
     var cycleTile = new CycleTileData()
     {
         Title = "cycle tile",
         Count = 6,
         SmallBackgroundImage =
             new Uri("/Assets/Tiles/george-151.png", UriKind.Relative),
         CycleImages = new Uri[]
                         {
                             new Uri("/Assets/Tiles/cycle01.jpg",
                                     UriKind.Relative),
                             new Uri("/Assets/Tiles/cycle02.jpg",
                                     UriKind.Relative),
                             new Uri("/Assets/Tiles/cycle03.jpg",
                                     UriKind.Relative),
                             new Uri("/Assets/Tiles/cycle04.jpg",
                                     UriKind.Relative),
                         }
     };
     ShellTile.Create(new Uri("/MainPage.xaml?tile=cycle", UriKind.Relative), cycleTile, true);
 }
예제 #44
0
        private static async Task SetLockScreen(string fileName)
        {
            // This article describes how to programmatically
            // take control of the lockscreen background:
            // http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206968(v=vs.105).aspx

            // Right-click WMAppManifest.xml, select Open With ...
            // Choose 'XML (Text) Editor with Encoding'
            // Choose AutoDetect when asked about which Encoding

            // IMPORTANT: Add this under </Tokens> section:
            //

            /*
             *  <Extensions>
             *          <Extension ExtensionName="LockScreen_Background"
             *       ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}"
             *       TaskID="_default" />
             *  </Extensions>
             */
            // That will make our app a Lock Screen Background "provider".

            // Lockscreen Design Guidelines
            // http://msdn.microsoft.com/en-us/library/windowsphone/design/jj662927(v=vs.105).aspx

            bool hasAccessForLockScreen
                = LockScreenManager.IsProvidedByCurrentApplication;

            if (!hasAccessForLockScreen)
            {
                // If you're not the provider, this call will prompt the user for permission.
                // Calling RequestAccessAsync from a background agent is not allowed.
                var accessRequested = await LockScreenManager.RequestAccessAsync();

                // Only do further work if the access was granted.
                hasAccessForLockScreen = (accessRequested == LockScreenRequestResult.Granted);
            }

            if (hasAccessForLockScreen)
            {
                Uri imgUri = new Uri(
                    "ms-appdata:///local/" + BackgroundRoot + fileName,
                    UriKind.Absolute);
                LockScreen.SetImageUri(imgUri);
            }

            var mainTile = ShellTile.ActiveTiles.FirstOrDefault();

            if (null != mainTile)
            {
                Uri iconUri = new Uri("isostore:///" + IconRoot + fileName, UriKind.Absolute);
                var imgs    = new List <Uri>();
                imgs.Add(iconUri);

                CycleTileData tileData = new CycleTileData();
                tileData.CycleImages = imgs;
                //tileData.IconImage = imgUri;

                mainTile.Update(tileData);
            }
        }
        private static async Task SetLockScreen(string fileName)
        {
            // This article describes how to programmatically 
            // take control of the lockscreen background:
            // http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206968(v=vs.105).aspx

            // Right-click WMAppManifest.xml, select Open With ...
            // Choose 'XML (Text) Editor with Encoding'
            // Choose AutoDetect when asked about which Encoding

            // IMPORTANT: Add this under </Tokens> section:
            //
            /*
                <Extensions>
            		<Extension ExtensionName="LockScreen_Background" 
                     ConsumerID="{111DFF24-AA15-4A96-8006-2BFF8122084F}" 
                     TaskID="_default" />
            	</Extensions>
            */
            // That will make our app a Lock Screen Background "provider".

            // Lockscreen Design Guidelines
            // http://msdn.microsoft.com/en-us/library/windowsphone/design/jj662927(v=vs.105).aspx

            bool hasAccessForLockScreen
                = LockScreenManager.IsProvidedByCurrentApplication;

            if (!hasAccessForLockScreen)
            {
                // If you're not the provider, this call will prompt the user for permission.
                // Calling RequestAccessAsync from a background agent is not allowed.                    
                var accessRequested = await LockScreenManager.RequestAccessAsync();

                // Only do further work if the access was granted.
                hasAccessForLockScreen = (accessRequested == LockScreenRequestResult.Granted);
            }

            if (hasAccessForLockScreen)
            {
                Uri imgUri = new Uri(
                    "ms-appdata:///local/" + BackgroundRoot + fileName,
                    UriKind.Absolute);
                LockScreen.SetImageUri(imgUri);
            }

            var mainTile = ShellTile.ActiveTiles.FirstOrDefault();

            if (null != mainTile)
            {
                Uri iconUri = new Uri("isostore:///" + IconRoot + fileName, UriKind.Absolute);
                var imgs = new List<Uri>();
                imgs.Add(iconUri);

                CycleTileData tileData = new CycleTileData();
                tileData.CycleImages = imgs;
                //tileData.IconImage = imgUri;

                mainTile.Update(tileData);
            }
        }
            public static void SetGroupTile(RecipeDataGroup group, string NavSource)
            {
                List<Uri> list = new List<Uri>();
                foreach (var recipe in group.Items)
                    list.Add(new Uri(recipe.ImagePath.LocalPath, UriKind.Relative));

                CycleTileData tileData = new CycleTileData()
                {
                    Title = group.Title,
                    SmallBackgroundImage = new Uri(group.GetImageUri(), UriKind.RelativeOrAbsolute),
                    CycleImages = list
                };

                ShellTile.Create(new Uri(NavSource, UriKind.Relative), tileData, true);
            }
예제 #47
0
 public void UpdateCycleTile(string title, int count, Uri tileId, Uri smallBackgroundImage, List<Uri> CycleImages)
 {
     var mytile = new CycleTileData
     {
         Title = title,
         Count = count,
         SmallBackgroundImage = smallBackgroundImage,
         CycleImages = CycleImages
     };
     try
     {
         ShellTile.Create(tileId, mytile, true);
     }
     catch { }
 }
        /// <summary>
        /// Update the app tile
        /// </summary>
        /// <param name="notificationCount">Count of notifications to show</param>
        /// <param name="friendList"></param>
        private void UpdateTile(int notificationCount, IEnumerable<FriendEntity> friendList)
        {
            if (friendList == null) return;

            var tile = ShellTile.ActiveTiles.First();

            if (tile == null) return;

            //create live tile
            var tileData = new CycleTileData
            {
                Title = Resources.BdayTileLabel,
                CycleImages = friendList.Where
                    (
                        (t, i) => i < 9
                    )
                    .Select
                    (
                        t =>
                            new Uri(@"isostore:/" + FileSystem.ProfilePictureDirectory + t.UniqueId + ".jpg",
                                UriKind.Absolute)
                    ).ToArray()
            };

            //build colelction of image urls

            //update notification count
            if (notificationCount != 0)
            {
                tileData.Count = notificationCount;
            }

            //update tile
            tile.Update(tileData);
        }
        private void CreateCycleTile(object sender, System.Windows.RoutedEventArgs e)
        {
            CycleTileData ctd = new CycleTileData();

            // Set up text data
            ctd.Title = cycleTileText.Text;

            // Set up image data
            ctd.SmallBackgroundImage = new Uri("Assets/Tiles/Medium_Image_1.jpg", UriKind.Relative);
            List<Uri> cycleImages = new List<Uri>();

            if (cycle_tile_1.IsChecked == true)
                cycleImages.Add(new Uri("Assets/Tiles/Wide_Image_1.jpg", UriKind.Relative));
            if (cycle_tile_2.IsChecked == true)
                cycleImages.Add(new Uri("Assets/Tiles/Wide_Image_2.jpg", UriKind.Relative));
            if (cycle_tile_3.IsChecked == true)
                cycleImages.Add(new Uri("Assets/Tiles/Wide_Image_3.jpg", UriKind.Relative));
            if (cycle_tile_4.IsChecked == true)
                cycleImages.Add(new Uri("Assets/Tiles/Wide_Image_4.jpg", UriKind.Relative));
            if (cycle_tile_5.IsChecked == true)
                cycleImages.Add(new Uri("Assets/Tiles/Wide_Image_5.jpg", UriKind.Relative));
            if (cycle_tile_6.IsChecked == true)
                cycleImages.Add(new Uri("Assets/Tiles/Wide_Image_6.jpg", UriKind.Relative));

            ctd.CycleImages = cycleImages;
            // Create Tile
            string uniqueParameter = (Guid.NewGuid()).ToString();
            ShellTile.Create(new Uri("/MainPage.xaml?customParameter=" + uniqueParameter, UriKind.Relative), ctd, true);
        }
예제 #50
0
        /// <summary>
        /// Set the live tiles. Live tiles must be saved in isostore:Shared\ShellContent\
        /// </summary>
        /// <param name="saveImage">True if you would like to save the current screen. It would be false if you were calling it from main for example</param>
        private void CreateLiveTiles(bool saveImage)
        {
            var myStore   = IsolatedStorageFile.GetUserStoreForApplication();
            int tileCount = 0;

            //count how many tiles currently exist
            string[] s = myStore.GetFileNames("Shared\\ShellContent\\tile*.jpg");
            tileCount = s.Length;

            if (saveImage)
            {
                int tileNum = -1;
                //find out which number to save the new tile as (highest number available)
                if (tileCount < 9)
                {
                    tileNum = tileCount + 1;
                }
                else
                {//if there are already 9 tiles, remove the oldest one, and add the new one
                    for (int i = 2; i <= 9; i++)
                    {
                        myStore.CopyFile("Shared\\ShellContent\\tile" + i.ToString() + ".jpg", "Shared\\ShellContent\\tile" + (i - 1).ToString() + ".jpg");
                        tileNum = 9;
                    }
                }
                //save the tile to the storage. Call the normal saveImage method with an extra tile number parameter to indicate we want to save it as a tile, NOT to saved pics
                Renderer.SaveImage("TileImg.jpg", false, tileNum);
                tileCount = (tileCount + 1) % 9 + 1;
            }

            //if a tile was successfully saved, update the live tiles (or create them)
            if (tileCount > 0)
            {
                CycleTileData tileData = new CycleTileData()
                {
                    Title = "GPU-SDX",
                    Count = null,
                    SmallBackgroundImage =
                        new Uri("comicfx-icon159x159.png", UriKind.RelativeOrAbsolute),
                    CycleImages =

                        new Uri[] {
                        new Uri("isostore:/Shared/ShellContent/tile1.jpg", UriKind.Absolute),
                        new Uri("isostore:/Shared/ShellContent/tile2.jpg", UriKind.Absolute),
                        new Uri("isostore:/Shared/ShellContent/tile3.jpg", UriKind.Absolute),
                        new Uri("isostore:/Shared/ShellContent/tile4.jpg", UriKind.Absolute),
                        new Uri("isostore:/Shared/ShellContent/tile5.jpg", UriKind.Absolute),
                        new Uri("isostore:/Shared/ShellContent/tile6.jpg", UriKind.Absolute),
                        new Uri("isostore:/Shared/ShellContent/tile7.jpg", UriKind.Absolute),
                        new Uri("isostore:/Shared/ShellContent/tile8.jpg", UriKind.Absolute),
                    }
                };

                //turn the tiles on!
                var mainTile = ShellTile.ActiveTiles.FirstOrDefault();
                if (null != mainTile)
                {
                    mainTile.Update(tileData);
                }

                MessageBox.Show("Image Added to Live Tiles.");
            }
        }
예제 #51
0
        private void CycleTyleCreate()
        {
            try
            {
                CycleTileData cycleTileData = new CycleTileData();
                cycleTileData.Title = "Photo Display ";
                cycleTileData.Count = ImagesDetails.Count;
                cycleTileData.SmallBackgroundImage = new Uri("/Assets/Tiles/FlipCycleTileSmall.png", UriKind.RelativeOrAbsolute);
                    List<Uri> images = new List<Uri>();
                    IsolatedStorageFile isoStorageFile = IsolatedStorageFile.GetUserStoreForApplication();
                    for (int i = 1; i <= ImagesDetails.Count ; i++)
                    {

                        var destPath = string.Format("isostore:/Shared/ShellContent/Img{0}.jpg", i);
                        images.Add(new Uri(destPath, UriKind.RelativeOrAbsolute));
                    }
                    cycleTileData.CycleImages = images;
                    ShellTile TileToFind = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString().Contains("Imagenes"));

                    if (TileToFind != null)
                    {
                        TileToFind.Update(cycleTileData);
                    }

                    else
                    {
                        ShellTile.Create(new Uri("/Views/MainPage.xaml", UriKind.Relative), cycleTileData, true);

                        Uri tileUri = new Uri(string.Concat("/MainPage.xaml?", "tile=cycle"), UriKind.Relative);
                        ShellTileData tileData = this.CreateCycleTileData();
                        ShellTile.Create(tileUri, tileData, false);
                    }
            }

            catch { 
            }
        }