Ejemplo n.º 1
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected async override void OnInvoke(ScheduledTask task)
        {
            string message = "Time to Sunlight!";

            await System.Threading.Tasks.Task.Delay(1);


            count += 1;
            Microsoft.Phone.Shell.ShellToast toast = new Microsoft.Phone.Shell.ShellToast();
            toast.Content = message + count.ToString();
            toast.Title   = "vitaminD";
            //toast.NavigationUri = new System.Uri("/Views/SourceView.xaml?name=sun&home=Main", System.UriKind.Relative);
            toast.Show();

            ////option tile lockscreen
            Microsoft.Phone.Shell.ShellTile tile = Microsoft.Phone.Shell.ShellTile.ActiveTiles.FirstOrDefault();
            var data = new Microsoft.Phone.Shell.StandardTileData();

            data.Count       = count;
            data.BackContent = string.Format("TIME'S UP! Go out there and take a bit of sunlight");
            tile.Update(data);


#if (DEBUG_AGENT)
            ScheduledActionService.LaunchForTest(task.Name, System.TimeSpan.FromSeconds(10));
#endif
            NotifyComplete();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            Assembly   a             = Assembly.Load("Microsoft.Phone.InteropServices, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e");
            Type       comBridgeType = a.GetType("Microsoft.Phone.InteropServices.ComBridge");
            MethodInfo dynMethod     = comBridgeType.GetMethod("RegisterComDll", BindingFlags.Public | BindingFlags.Static);
            object     retValue      = dynMethod.Invoke(null, new object[] { "liblw.dll", new Guid("E79018CB-46A6-432D-8077-8C0863533001") });
            //uint retval = Microsoft.Phone.InteropServices.ComBridge.RegisterComDll("libwph.dll", new Guid("56624E8C-CF91-41DF-9C31-E25A98FAF464"));
            Imangodll instance = (Imangodll) new Cmangodll();

            //Update messaging tiles
            int unread = 0;

            instance.getUnreadSMSCount(out unread);

            Microsoft.Phone.Shell.StandardTileData data = new Microsoft.Phone.Shell.StandardTileData();
            data.Count = unread;

            foreach (var t in Microsoft.Phone.Shell.ShellTile.ActiveTiles.Where(t => t.NavigationUri.ToString().Contains("5B04B775-356B-4AA0-AAF8-6491FFEA5610")))
            {
                t.Update(data);
            }

            //Update phone tile


            ScheduledActionService.LaunchForTest("ScheduledAgent", TimeSpan.FromMilliseconds(2200));

            NotifyComplete();
        }
Ejemplo n.º 3
0
        private static string ConstructTokenXmlString(Microsoft.Phone.Shell.StandardTileData tile, string TokenId)
        {
            StringBuilder builder = new StringBuilder();

            builder.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
            builder.AppendLine("<PushNotification>");
            if (TokenId != null)
            {
                builder.AppendLine(string.Format("<Token TokenID=\"{0}\">", TokenId));
            }
            else
            {
                builder.AppendLine("<Token xmlns=\"\" TokenID=\"\">");
            }
            builder.AppendLine("<TemplateType5>");
            if (tile.Count.HasValue)
            {
                builder.AppendLine(string.Format("<Count>{0}</Count>\r\n", tile.Count));
            }
            if (tile.Title != null)
            {
                builder.AppendLine(string.Format("<Title>{0}</Title>\r\n", tile.Title));
            }
            if (tile.BackgroundImage != null)
            {
                if (IsRemoteUri(tile.BackgroundImage))
                {
                    builder.AppendLine("<BackgroundImageURI IsRelative=\"false\" IsResource=\"false\">DummyURI</BackgroundImageURI>\r\n");
                }
                else
                {
                    builder.AppendLine(string.Format("<BackgroundImageURI IsRelative=\"{0}\" IsResource=\"{1}\">{2}</BackgroundImageURI>\r\n", IsRelativeUri(tile.BackgroundImage), IsResourceUri(tile.BackgroundImage), GetLocalFilePath(tile.BackgroundImage)));
                }
            }
            if (tile.BackContent != null)
            {
                builder.AppendLine(string.Format("<BackContent>{0}</BackContent>\r\n", tile.BackContent));
            }
            if (tile.BackTitle != null)
            {
                builder.AppendLine(string.Format("<BackTitle>{0}</BackTitle>\r\n", tile.BackTitle));
            }
            if (tile.BackBackgroundImage != null)
            {
                if (IsRemoteUri(tile.BackBackgroundImage))
                {
                    builder.AppendLine("<BackBackgroundImageURI IsRelative=\"false\" IsResource=\"false\">DummyURI</BackBackgroundImageURI>\r\n");
                }
                else
                {
                    builder.AppendLine(string.Format("<BackBackgroundImageURI IsRelative=\"{0}\" IsResource=\"{1}\">{2}</BackBackgroundImageURI>\r\n", IsRelativeUri(tile.BackBackgroundImage), IsResourceUri(tile.BackBackgroundImage), GetLocalFilePath(tile.BackBackgroundImage)));
                }
            }
            builder.AppendLine("</TemplateType5>");
            builder.AppendLine("</Token>");
            builder.AppendLine("</PushNotification>");
            return(builder.ToString());
        }
Ejemplo n.º 4
0
        private static bool IsTileContainsAnyRemoteURL(Microsoft.Phone.Shell.StandardTileData data)
        {
            bool flag = false;

            if (((data.BackgroundImage != null) && data.BackgroundImage.IsAbsoluteUri) && (data.BackgroundImage.Scheme == "http"))
            {
                flag = true;
            }
            if ((!flag && (data.BackBackgroundImage != null)) && (data.BackBackgroundImage.IsAbsoluteUri && (data.BackBackgroundImage.Scheme == "http")))
            {
                flag = true;
            }
            return(flag);
        }
        void addTile()
        {
            try
            {
                Microsoft.Phone.Shell.StandardTileData data = new Microsoft.Phone.Shell.StandardTileData
                {
                    Title = "Orientation Lock"
                };

                Microsoft.Phone.Shell.ShellTile.Create(new Uri("/Toggle.xaml", UriKind.Relative), data);
            }
            catch
            {
            }
        }
        private void image1_Tap(object sender, GestureEventArgs e)
        {
            try
            {
                Microsoft.Phone.Shell.StandardTileData data = new Microsoft.Phone.Shell.StandardTileData
                {
                    Title           = "",
                    BackgroundImage = new Uri("/runeco.png", UriKind.Relative)
                };

                Microsoft.Phone.Shell.ShellTile.Create(new Uri("/run.xaml", UriKind.Relative), data);
            }
            catch
            {
            }
        }
Ejemplo n.º 7
0
 public static void updateTile(bool status)
 {
     var tile = Microsoft.Phone.Shell.ShellTile.ActiveTiles.Where(x => x.NavigationUri.ToString().Contains("Toggle")).FirstOrDefault();
     if (tile != null)
     {
         Microsoft.Phone.Shell.StandardTileData data = new Microsoft.Phone.Shell.StandardTileData
         {
             Title = "Orientation Lock",
         };
         if (status)
         {
             data.BackgroundImage = new Uri("locked.png", UriKind.Relative);
         }
         else
         {
             data.BackgroundImage = new Uri("unlocked.png", UriKind.Relative);
         }
         System.Diagnostics.Debug.WriteLine(data.BackgroundImage.ToString());
         tile.Update(data);
     }
 }
        public static void updateTile(bool status)
        {
            var tile = Microsoft.Phone.Shell.ShellTile.ActiveTiles.Where(x => x.NavigationUri.ToString().Contains("Toggle")).FirstOrDefault();

            if (tile != null)
            {
                Microsoft.Phone.Shell.StandardTileData data = new Microsoft.Phone.Shell.StandardTileData
                {
                    Title = "Orientation Lock",
                };
                if (status)
                {
                    data.BackgroundImage = new Uri("locked.png", UriKind.Relative);
                }
                else
                {
                    data.BackgroundImage = new Uri("unlocked.png", UriKind.Relative);
                }
                System.Diagnostics.Debug.WriteLine(data.BackgroundImage.ToString());
                tile.Update(data);
            }
        }
Ejemplo n.º 9
0
 internal static void SerializeToToken(Microsoft.Phone.Shell.StandardTileData data /*Due static extracted this is here*/, IToken token)
 {
     foreach (System.Reflection.PropertyInfo info in data.GetType().GetProperties())
     {
         foreach (Attribute attribute in info.GetCustomAttributes(true))
         {
             TileAttribute attribute2 = attribute as TileAttribute;
             //if ((attribute2 != null) && data.TemplateTypeProperties.Contains<TOKEN_PROPERTY_TYPE>(attribute2.PropertyId))
             //{
             //    object obj2 = info.GetValue(data, null);
             //    string defaultValue = attribute2.DefaultValue;
             //    if (obj2 != null)
             //    {
             //        if (attribute2.ValueConverter == null)
             //        {
             //            defaultValue = string.Format("{0}", obj2);
             //        }
             //        else
             //        {
             //            var converter = (System.Windows.Data.IValueConverter)Activator.CreateInstance(Type.GetType(attribute2.ValueConverter));
             //            defaultValue = (string)converter.Convert(obj2, typeof(string), null, CultureInfo.InvariantCulture);
             //        }
             //    }
             //    if (defaultValue != null)
             //    {
             //        uint num = (uint)(5 /*5 = default*//*data.TemplateType*/ << 0x10);
             //        uint propertyId = (uint)(((TOKEN_PROPERTY_TYPE)num) | attribute2.PropertyId);
             //        if (defaultValue.Length > 0x200)
             //        {
             //            throw new ArgumentException("The serialized property " + info.Name + " is too long");
             //        }
             //        token.set_Property(propertyId, defaultValue);
             //    }
             //}
         }
     }
 }
Ejemplo n.º 10
0
        private void image1_Tap(object sender, GestureEventArgs e)
        {
            try
            {
                Microsoft.Phone.Shell.StandardTileData data = new Microsoft.Phone.Shell.StandardTileData
                {
                    Title = "",
                    BackgroundImage = new Uri("/runeco.png", UriKind.Relative)
                };

                Microsoft.Phone.Shell.ShellTile.Create(new Uri("/run.xaml", UriKind.Relative), data);
            }
            catch
            {
            }
        }
Ejemplo n.º 11
0
        void addTile()
        {
            try
            {
                Microsoft.Phone.Shell.StandardTileData data = new Microsoft.Phone.Shell.StandardTileData
                {
                    Title = "Orientation Lock"
                };

                Microsoft.Phone.Shell.ShellTile.Create(new Uri("/Toggle.xaml", UriKind.Relative), data);
            }
            catch
            {
            }
        }