public static void SetRemider(RecipeDataItem item)
            {
                if (!IsScheduled(item.UniqueId))
                {
                    //TODO-EX-4
                    Microsoft.Phone.Scheduler.Reminder reminder = new Microsoft.Phone.Scheduler.Reminder(item.UniqueId);
                    reminder.Title = item.Title;
                    reminder.Content = "Did you finished?";
                    if (System.Diagnostics.Debugger.IsAttached)
                        reminder.BeginTime = DateTime.Now.AddMinutes(1);
                    else
                        reminder.BeginTime = DateTime.Now.Add(TimeSpan.FromMinutes(Convert.ToDouble(item.PrepTime)));
                    reminder.ExpirationTime = reminder.BeginTime.AddMinutes(5);
                    reminder.RecurrenceType = RecurrenceInterval.None;
                    reminder.NavigationUri = new Uri("/RecipeDetailPage.xaml?ID=" + item.UniqueId + "&GID=" + item.Group.UniqueId, UriKind.Relative);
                    ScheduledActionService.Add(reminder);

                    //TODO-EX-5
                }
                else
                {
                    var schedule = ScheduledActionService.Find(item.UniqueId);
                    ScheduledActionService.Remove(schedule.Name);

                    //TODO-EX-6
                }
            }
Пример #2
0
         public static void SetReminder(RecipeDataItem item)
         {


                var toastNotifier = Windows.UI.Notifications.ToastNotificationManager.CreateToastNotifier();

                
                if (!IsScheduled(item.UniqueId))
                {
                    Windows.Data.Xml.Dom.XmlDocument doc = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
                    var textLines = doc.GetElementsByTagName("text");
                    textLines[0].InnerText = item.Title;
                    textLines[1].InnerText = "Have you finished cooking?";
                    ScheduledToastNotification reminder = new ScheduledToastNotification(doc, DateTime.Now.AddSeconds(10));
                    reminder.Id = item.UniqueId;
                    toastNotifier.AddToSchedule(reminder);
                }
                else
                {

                    var schedule = toastNotifier.GetScheduledToastNotifications().FirstOrDefault(x => x.Id == item.UniqueId);
                    if (schedule != null)
                        toastNotifier.RemoveFromSchedule(schedule);
                }

                
            }
Пример #3
0
 private void AssignedUserImages(RecipeDataItem recipe)
 {
     if (UserImages != null && UserImages.Any(item => item.UniqueId.Equals(recipe.UniqueId)))
     {
         var userImages = UserImages.Single(a => a.UniqueId.Equals(recipe.UniqueId));
         recipe.UserImages = userImages.Images;
     }
 }
 public static void SetTile(RecipeDataItem item, string NavSource)
 {
     StandardTileData tileData = new StandardTileData
     {
         Title = "Contoso Cookbook",
         BackTitle = item.Group.Title,
         BackContent = item.Title,
         BackBackgroundImage = new Uri(item.Group.GetImageUri(), UriKind.Relative),
         BackgroundImage = new Uri(item.GetImageUri(), UriKind.Relative)
     };
     ShellTile.Create(new Uri(NavSource, UriKind.Relative), tileData);
 }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (!App.Recipes.IsLoaded)
            {
                await App.Recipes.LoadLocalDataAsync();
            }

            string UniqueId = NavigationContext.QueryString["ID"];

            if (!App.Recipes.IsLoaded)
                await App.Recipes.LoadLocalDataAsync();

            item = App.Recipes.FindRecipe(UniqueId);
            pivot.DataContext = item;

            PositionForOrientation();

            base.OnNavigatedTo(e);
        }
            public static void SetTile(RecipeDataItem item, string NavSource)
            {
                FlipTileData tileData = new FlipTileData()
                {
                    //Front square data
                    Title = item.Title,
                    BackgroundImage = new Uri(item.GetImageUri(), UriKind.Relative),

                    //Back square data
                    BackTitle = item.Title,
                    BackContent = makeString(item.Ingredients),
                    BackBackgroundImage = new Uri(item.Group.GetImageUri(), UriKind.Relative),

                    //Wide tile data
                    WideBackgroundImage = new Uri(item.GetImageUri(), UriKind.Relative),
                    WideBackBackgroundImage = new Uri(item.Group.GetImageUri(), UriKind.Relative),
                    WideBackContent = item.Directions
                };

                ShellTile.Create(new Uri(NavSource, UriKind.Relative), tileData, true);
            }
        private static void CreateRecipesAndRecipeGroups(JsonArray array)
        {
            foreach (var item in array)
            {
                var obj = item.GetObject();
                RecipeDataItem recipe = new RecipeDataItem();
                RecipeDataGroup group = null;

                foreach (var key in obj.Keys)
                {
                    IJsonValue val;
                    if (!obj.TryGetValue(key, out val))
                        continue;

                    switch (key)
                    {
                        case "key":
                            recipe.UniqueId = val.GetNumber().ToString();
                            break;
                        case "title":
                            recipe.Title = val.GetString();
                            break;
                        case "shortTitle":
                            recipe.ShortTitle = val.GetString();
                            break;
                        case "preptime":
                            recipe.PrepTime = (int)val.GetNumber();
                            break;
                        case "directions":
                            recipe.Directions = val.GetString();
                            break;
                        case "ingredients":
                            var ingredients = val.GetArray();
                            var list = (from i in ingredients select i.GetString()).ToList();
                            recipe.Ingredients = new ObservableCollection<string>(list);
                            break;
                        case "backgroundImage":
                            recipe.SetImage(val.GetString());
                            break;
                        case "tileImage":
                            recipe.SetTileImage(val.GetString());
                            break;
                        case "group":
                            var recipeGroup = val.GetObject();

                            IJsonValue groupKey;
                            if (!recipeGroup.TryGetValue("key", out groupKey))
                                continue;

                            group = _recipeDataSource.AllGroups.FirstOrDefault(c => c.UniqueId.Equals(groupKey.GetString()));

                            if (group == null)
                                group = CreateRecipeGroup(recipeGroup);

                            recipe.Group = group;
                            break;
                    }
                }

                if (group != null)
                    group.Items.Add(recipe);
            }
        }
 private void NavigateToRecipe(string UniqueId)
 {
     item = App.Recipes.FindRecipe(UniqueId);
     pivot.DataContext = item;
     SetScheduleBar(item.UniqueId);
     SetPinBar();
 }
 private void AssignedUserImages(RecipeDataItem recipe)
 {
     if (UserImages != null && UserImages.Any(item => item.UniqueId.Equals(recipe.UniqueId)))
     {
         var userImages = UserImages.Single(a => a.UniqueId.Equals(recipe.UniqueId));
         recipe.UserImages = userImages.Images;
     }
 }
Пример #10
0
 public static async System.Threading.Tasks.Task SetTile(RecipeDataItem item, string NavSource)
 {
    WindowsPhoneUWP.UpgradeHelpers.StandardTileData tileData = new StandardTileData
       {
          Title = "Contoso Cookbook", BackTitle = item.Group.Title, BackContent = item.Title, BackBackgroundImage = new Uri(new Uri("ms-appx://"), item.Group.GetImageUri()), BackgroundImage = new Uri(new Uri("ms-appx://"), item.GetImageUri())
       };
    await WindowsPhoneUWP.UpgradeHelpers.TilesHelper.CreateHelper(new Uri(new Uri("ms-appx://"), NavSource), tileData);
 }
Пример #11
0
 private async System.Threading.Tasks.Task NavigateToRecipe(string UniqueId)
 {
    item = App.Recipes.FindRecipe(UniqueId);
    pivot.DataContext = item;
    SetScheduleBar(item.UniqueId);
    await SetPinBar();
 }
 private void NavigateToRecipe(string UniqueId)
 {
     item = App.Recipes.FindRecipe(UniqueId);
     pivot.DataContext = item;          
 }
Пример #13
0
        private static void CreateRecipesAndRecipeGroups(JsonArray array)
        {
            foreach (var item in array)
            {
                var             obj    = item.GetObject();
                RecipeDataItem  recipe = new RecipeDataItem();
                RecipeDataGroup group  = null;

                foreach (var key in obj.Keys)
                {
                    IJsonValue val;
                    if (!obj.TryGetValue(key, out val))
                    {
                        continue;
                    }

                    switch (key)
                    {
                    case "key":
                        recipe.UniqueId = val.GetNumber().ToString();
                        break;

                    case "title":
                        recipe.Title = val.GetString();
                        break;

                    case "shortTitle":
                        recipe.ShortTitle = val.GetString();
                        break;

                    case "preptime":
                        recipe.PrepTime = (int)val.GetNumber();
                        break;

                    case "directions":
                        recipe.Directions = val.GetString();
                        break;

                    case "ingredients":
                        var ingredients = val.GetArray();
                        var list        = (from i in ingredients select i.GetString()).ToList();
                        recipe.Ingredients = new ObservableCollection <string>(list);
                        break;

                    case "backgroundImage":
                        recipe.SetImage(val.GetString());
                        break;

                    case "tileImage":
                        recipe.SetTileImage(val.GetString());
                        break;

                    case "group":
                        var recipeGroup = val.GetObject();

                        IJsonValue groupKey;
                        if (!recipeGroup.TryGetValue("key", out groupKey))
                        {
                            continue;
                        }

                        group = _recipeDataSource.AllGroups.FirstOrDefault(c => c.UniqueId.Equals(groupKey.GetString()));

                        if (group == null)
                        {
                            group = CreateRecipeGroup(recipeGroup);
                        }

                        recipe.Group = group;
                        break;
                    }
                }

                if (group != null)
                {
                    group.Items.Add(recipe);
                }
            }
        }
        private static async System.Threading.Tasks.Task CreateRecipesAndRecipeGroups(JsonArray array)
        {
            try
            {
                foreach (var item in array)
                {
                    var obj = item.GetObject();
                    RecipeDataItem Recipe = new RecipeDataItem();
                    RecipeDataGroup group = null;

                    foreach (var key in obj.Keys)
                    {
                        IJsonValue val;
                        if (!obj.TryGetValue(key, out val))
                            continue;

                        switch (key)
                        {
                            case "identifier":
                                Recipe.UniqueId = val.GetString();
                                var client = new HttpClient();
                                client.MaxResponseContentBufferSize = 1024 * 1024; // Read up to 1 MB of data
                                var response = await client.GetAsync(new Uri("http://me2day.net/api/get_content.json?domain=" + Recipe.Group.Title + "&identifier=" + Convert.ToInt32(val.GetString()) + "&akey=3345257cb3f6681909994ea2c0566e80&asig=MTMzOTE2NDY1MiQkYnlidWFtLnEkJDYzZTVlM2EwOWUyYmI5M2Q0OGU4ZjlmNzA4ZjUzYjMz&locale=ko-KR"));
                                var result = await response.Content.ReadAsStringAsync();

                                // Parse the JSON Recipe data
                                var Recipes = JsonObject.Parse(result/*.Substring(12, result.Length - 13)*/);
                                foreach (var item1 in Recipes)
                                {
                                    if (item1.Key == "detail")
                                    {

                                        //var obj1 = item1.GetObject();
                                        var obj1 = item1.Value.GetObject();
                                        foreach (var key1 in obj1)
                                        {

                                            IJsonValue val1;
                                            /*
                                               if (!obj1.TryGetValue(key1, out val1))
                                                       continue;
                                            */
                                            val1 = key1.Value;
                                            switch (key1.Key)
                                            {
                                                case "title":
                                                    Recipe.Title = val1.GetString();
                                                    break;
                                                case "artist":
                                                    Recipe.ShortTitle = val1.GetString();
                                                    break;
                                                case "cast":
                                                    Recipe.ShortTitle = val1.GetString();
                                                    break;
                                                case "author":
                                                    Recipe.ShortTitle = val1.GetString();
                                                    break;
                                                //  case "rate":
                                                //     Recipe.PrepTime = Convert.ToInt32(val1.GetString());
                                                //    break;
                                                case "description":
                                                    Recipe.Directions = val1.GetString();
                                                    Recipe.Directions = Recipe.Directions.Replace("&amp;", "&");

                                                    Recipe.Directions = Recipe.Directions.Replace("&gt;", ">");
                                                    Recipe.Directions = Recipe.Directions.Replace("&lt;", "<");

                                                    break;

                                                case "image_url":
                                                    Recipe.SetImage(val1.GetString());
                                                    break;
                                            }
                                        }
                                    }
                                }
                                break;
                            case "domain":
                                string groupKey = val.GetString();


                                group = _recipeDataSource.AllGroups.FirstOrDefault(c => c.Title.Equals(groupKey));

                                if (group == null)
                                    group = CreateRecipeGroup(groupKey);

                                Recipe.Group = group;
                                break;
                        }
                    }

                    if (group != null)
                    {
                        Recipe.Ingredients = "";
                        group.Items.Add(Recipe);

                    }
                }
                _recipeDataSource.AllGroups.FirstOrDefault(c => c.Title.Equals("movie")).Title = "영화";
                _recipeDataSource.AllGroups.FirstOrDefault(c => c.Title.Equals("music_album")).Title = "음반";
                _recipeDataSource.AllGroups.FirstOrDefault(c => c.Title.Equals("book")).Title = "책";
            }
            catch (Exception ex)
            {
                _recipeDataSource = null;
            }
        }