Пример #1
0
        /// <summary>
        /// Fills the page with the previous elements while the navigation. Any state loaded is given when the page
        /// is recreated from a previous session.
        /// </summary>
        /// <param name="sender">The event source ; generaly <see cref="NavigationHelper" /></param>
        /// <param name="e">Event data that give the parameter of the navigation transmitted
        /// <see cref="Frame.Navigate(Type, Object)" /> during the initial request of this page and
        /// a state dictionnary preserved by this page during a previous session
        /// The state will not take the value Null when the first visit of this page.</param>
        private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            GoToReceipeListEvent evnt = e.NavigationParameter as GoToReceipeListEvent;

            this.Model = evnt.AppModel;
            this.time  = evnt.Time;
            List <ItemReceipe> receipes = new List <ItemReceipe>();

            if (evnt.ReceipeTime is ReceipeTimeOfDay)
            {
                ReceipeTimeOfDay receipeTimeOfDay = (ReceipeTimeOfDay)evnt.ReceipeTime;
                foreach (Receipe receipe in receipeTimeOfDay.Receipes.Values)
                {
                    receipes.Add(ToolItem.CreateItemReceipe(receipe));
                }

                HandleTitle(receipeTimeOfDay);
            }
            else if (evnt.ReceipeTime is ReceipeDate)
            {
                ReceipeDate receipeDate = (ReceipeDate)evnt.ReceipeTime;
                foreach (ReceipeTimeOfDay receipeTimeOfDay in receipeDate.ReceipeTimeOfDay.Values)
                {
                    foreach (Receipe receipe in receipeTimeOfDay.Receipes.Values)
                    {
                        receipes.Add(ToolItem.CreateItemReceipe(receipe));
                    }
                }
                HandleTitle(receipeDate);
            }

            listReceipeViewSource.Source = receipes;
        }
Пример #2
0
        /// <summary>
        /// Refreshes the specified e.
        /// </summary>
        /// <param name="e">The e.</param>
        public void Refresh(Event e)
        {
            if (e is ReceipeEvent)
            {
                ReceipeEvent receipeE = (ReceipeEvent)e;
                Receipe      receipe  = receipeE.Receipe;

                if (receipeE is AddedReceipeEvent)
                {
                    this.ItemsReceipe.Add(ToolItem.CreateItemReceipe(receipe));
                }
                else if (receipeE is RemovedReceipeEvent)
                {
                    foreach (ItemReceipe item in this.ItemsReceipe)
                    {
                        if (item.Receipe == receipe)
                        {
                            this.ItemsReceipe.Remove(item);
                        }
                    }
                }
                else if (receipeE is ClearedReceipeEvent)
                {
                    this.ItemsReceipe = new List <ItemReceipe>();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Refreshes the page.
        /// </summary>
        /// <param name="e">The event.</param>
        public void Refresh(Event e)
        {
            if (e is RemovedReceipeListEvent)
            {
                RemovedReceipeListEvent srcEvnt = (RemovedReceipeListEvent)e;
                Time time = srcEvnt.Time;
                List <ItemReceipe> newList = new List <ItemReceipe>();

                if (this.Model.ReceipeList.ContainsKey(time.Date))
                {
                    Dictionary <string, Receipe> previousList = this.Model.ReceipeList[time.Date].ReceipeTimeOfDay[time.TimeOfDay].Receipes;
                    foreach (Receipe receipe in previousList.Values)
                    {
                        newList.Add(ToolItem.CreateItemReceipe(receipe));
                    }
                }

                if (time.TimeOfDay.Equals("Matin"))
                {
                    morningReceipeViewSource.Source = newList;
                }

                else if (time.TimeOfDay.Equals("Midi"))
                {
                    noonReceipeViewSource.Source = newList;
                }
                else if (time.TimeOfDay.Equals("Soir"))
                {
                    evenningReceipeViewSource.Source = newList;
                }
            }
        }
Пример #4
0
        /// <summary>
        /// Fills the page with the previous elements while the navigation. Any state loaded is given when the page
        /// is recreated from a previous session.
        /// </summary>
        /// <param name="sender">
        /// The event source ; generaly <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e"> Event data that give the parameter of the navigation transmitted
        /// <see cref="Frame.Navigate(Type, Object)"/> during the initial request of this page and
        /// a state dictionnary preserved by this page during a previous session
        /// The state will not take the value Null when the first visit of this page.</param>
        private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            GoToModifyReceipeListEvent evnt = e.NavigationParameter as GoToModifyReceipeListEvent;

            if (evnt != null)
            {
                this.Model = evnt.AppModel;
                if (this.addedView == false)
                {
                    this.Model.AddView(this);
                    this.addedView = true;
                }
                Time time = evnt.Time;

                this.pageTitle.Text = "Liste de recette du " + time.Date;

                if (this.Model.ReceipeList.ContainsKey(time.Date))
                {
                    ReceipeDate receipeDate = this.Model.ReceipeList[time.Date];
                    this.date = receipeDate.Time.Date;

                    List <ItemReceipe> itemsMorning = new List <ItemReceipe>();
                    foreach (Receipe receipe in receipeDate.ReceipeTimeOfDay["Matin"].Receipes.Values)
                    {
                        itemsMorning.Add(ToolItem.CreateItemReceipe(receipe));
                    }
                    morningReceipeViewSource.Source = itemsMorning;

                    List <ItemReceipe> itemsNoon = new List <ItemReceipe>();
                    foreach (Receipe receipe in receipeDate.ReceipeTimeOfDay["Midi"].Receipes.Values)
                    {
                        itemsNoon.Add(ToolItem.CreateItemReceipe(receipe));
                    }
                    noonReceipeViewSource.Source = itemsNoon;

                    List <ItemReceipe> itemsEvenning = new List <ItemReceipe>();
                    foreach (Receipe receipe in receipeDate.ReceipeTimeOfDay["Soir"].Receipes.Values)
                    {
                        itemsEvenning.Add(ToolItem.CreateItemReceipe(receipe));
                    }
                    evenningReceipeViewSource.Source = itemsEvenning;
                }
            }
        }