Example #1
0
 public static void SetReminder(RecipeDataItem item)
 {
     if (!IsScheduled(item.UniqueId))
     {
         Microsoft.Phone.Scheduler.Reminder reminder = new Microsoft.Phone.Scheduler.Reminder(item.UniqueId);
         reminder.Title   = item.Title;
         reminder.Content = "Have you finished cooking?";
         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);
     }
     else
     {
         var schedule = ScheduledActionService.Find(item.UniqueId);
         ScheduledActionService.Remove(schedule.Name);
     }
 }
Example #2
0
 private void NavigateToRecipe(string UniqueId)
 {
     item = App.Recipes.FindRecipe(UniqueId);
     pivot.DataContext = item;
     SetScheduleBar(item.UniqueId);
     SetPinBar();
 }
Example #3
0
        public void SetReminder(RecipeDataItem item)
        {
            if (!IsScheduled(item.UniqueId))
            {
                ScheduledAction schedule = ScheduledActionService.Find(item.UniqueId);
                if (null != schedule)
                    ScheduledActionService.Remove(schedule.Name);

                var reminder = new Microsoft.Phone.Scheduler.Reminder(item.UniqueId)
                {
                    Title = item.Title,
                    Content = "Has terminado de cocinar?",
                    BeginTime =
                        Debugger.IsAttached
                            ? DateTime.Now.AddSeconds(30)
                            : DateTime.Now.Add(TimeSpan.FromMinutes(Convert.ToDouble(item.PrepTime)))
                };

                reminder.ExpirationTime = reminder.BeginTime.AddSeconds(30);
                reminder.RecurrenceType = RecurrenceInterval.None;
                reminder.NavigationUri =
                    new Uri("../View/RecipeDetailPage.xaml?ID=" + item.UniqueId + "&GID=" + item.Group.UniqueId,
                        UriKind.Relative);

                ScheduledActionService.Add(reminder);
            }
            else
            {
                ScheduledAction schedule = ScheduledActionService.Find(item.UniqueId);
                ScheduledActionService.Remove(schedule.Name);
            }
        }
 public void NavigateToRecipeDetailPage(RecipeDataItem recipeDataItem)
 {
     _selectedRecipeDataItem = recipeDataItem;
     var phoneApplicationFrame = Application.Current.RootVisual as PhoneApplicationFrame;
     if (phoneApplicationFrame != null)
         phoneApplicationFrame.Navigated += NavigateToRecipeDetailPageNavigated;
     App.RootFrame.Navigate(new Uri("/View/RecipeDetailPage.xaml", UriKind.Relative));
 }
 public void AssignedUserImages(RecipeDataItem recipe)
 {
     if (UserImages != null && UserImages.Any(item => item.UniqueId.Equals(recipe.UniqueId)))
     {
         UserRecipeImages userImages = UserImages.Single(a => a.UniqueId.Equals(recipe.UniqueId));
         recipe.UserImages = userImages.Images;
     }
 }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            item = await RecipeDataSource.GetItemAsync((String)e.NavigationParameter);

            this.DefaultViewModel["Group"] = item.Group;
            this.DefaultViewModel["Item"]  = item;

            // Is recipe already pinned?
            if (SecondaryTile.Exists(item.UniqueId))
            {
                btnPinToStart.Icon = new SymbolIcon(Symbol.UnPin);
            }

            DataTransferManager.GetForCurrentView().DataRequested += OnShareDataRequested;
        }
Example #7
0
        public static void ShareRecipe(DataRequest request, RecipeDataItem item)
        {
            request.Data.Properties.Title       = item.Title;
            request.Data.Properties.Description = "Recipe ingredients and directions";

            // Share recipe text
            var recipe = "\r\nINGREDIENTS\r\n";

            recipe += String.Join("\r\n", item.Ingredients);
            recipe += ("\r\n\r\nDIRECTIONS\r\n" + item.Directions);
            request.Data.SetText(recipe);

            // Share recipe image
            var reference = RandomAccessStreamReference.CreateFromUri(new Uri(item.ImagePath));

            request.Data.Properties.Thumbnail = reference;
            request.Data.SetBitmap(reference);
        }
Example #8
0
            public static void SetTile(RecipeDataItem item, string navDataSource)
            {
                FlipTileData tileData = new FlipTileData()
                {
                    //Front square data
                    Title                = item.Title,
                    BackgroundImage      = new Uri(item.GetImageUri(), UriKind.Relative),
                    SmallBackgroundImage = 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(navDataSource, UriKind.Relative), tileData, true);
            }
Example #9
0
 public void NavigateToRecipeDetailPage(RecipeDataItem recipeDataItem)
 {
     _selectedRecipeDataItem = recipeDataItem;
     (App.Current.RootVisual as PhoneApplicationFrame).Navigated += NavigateToRecipeDetailPageNavigated;
     App.RootFrame.Navigate(new Uri("/View/RecipeDetailPage.xaml", UriKind.Relative));
 }
Example #10
0
        public async Task<IEnumerable<RecipeDataItem>> Load(string filePath)
        {
            var file = await Package.Current.InstalledLocation.GetFileAsync(filePath);
            var result = await FileIO.ReadTextAsync(file);

            // Parse JSON 
            var data = JsonArray.Parse(result);

            var recipes = new List<RecipeDataItem>();
            foreach (var item in data)
            {
                var obj = item.GetObject();
                RecipeDataItem recipe = new RecipeDataItem();

                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 "group":
                            var recipeGroup = val.GetObject();

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

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

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

                            recipe.Group = group;
                            break;
                    }
                }

                recipes.Add(recipe);
            }

            return recipes;
        }
Example #11
0
        public async Task <IEnumerable <RecipeDataItem> > Load(string filePath)
        {
            var file = await Package.Current.InstalledLocation.GetFileAsync(filePath);

            var result = await FileIO.ReadTextAsync(file);

            // Parse JSON
            var data = JsonArray.Parse(result);

            var recipes = new List <RecipeDataItem>();

            foreach (var item in data)
            {
                var            obj    = item.GetObject();
                RecipeDataItem recipe = new RecipeDataItem();

                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 "group":
                        var recipeGroup = val.GetObject();

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

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

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

                        recipe.Group = group;
                        break;
                    }
                }

                recipes.Add(recipe);
            }

            return(recipes);
        }
        public override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            RecipeItem = e.Parameter as RecipeDataItem;
        }