/// <summary>
 /// Initializes a new instance of the <see cref="PlanningReceipe"/> class.
 /// </summary>
 public PlanningReceipe()
 {
     this.InitializeComponent();
     this.navigationHelper            = new NavigationHelper(this);
     this.navigationHelper.LoadState += navigationHelper_LoadState;
     this.checkBoxs = new Dictionary <string, CheckBox>();
     this.receipeListSelectedModel = new ReceipeListSelected();
     this.listReceipeListSelected  = new List <ItemReceipeListSelected>();
     this.receipeListSelectedModel.AddView(this);
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ModifyReceipeListPrint"/> class.
 /// </summary>
 /// <param name="model">The model.</param>
 public ModifyReceipeListPrint(ReceipeListSelected model) : base(model)
 {
 }
        /// <summary>
        /// Refresh the page according to the event given
        /// </summary>
        /// <param name="e">The e.</param>
        public void Refresh(Event e)
        {
            if (e is ModifyReceipeListPrint)
            {
                ModifyReceipeListPrint srcEvnt   = (ModifyReceipeListPrint)e;
                ReceipeListSelected    modelEvnt = (ReceipeListSelected)srcEvnt.Model;
                this.listReceipeListSelected.Clear();
                this.listReceipeListSelected = new List <ItemReceipeListSelected>();

                foreach (SampleDataGroup ing in modelEvnt.GetReceipeListSelected())
                {
                    List <string> imgs       = new List <string>();
                    int           nbImgFound = 0;
                    int           i          = 0;
                    int           j          = 0;
                    while (i < ing.Items.Count && nbImgFound < 4)
                    {
                        j = 0;
                        while (nbImgFound < 4 && j < ing.Items[i].ImagePaths.Count)
                        {
                            imgs.Add(ing.Items[i].ImagePaths[j]);
                            nbImgFound++;
                            j++;
                        }
                        i++;
                    }
                    listReceipeListSelected.Add(new ItemReceipeListSelected(ing.Title, imgs));
                }

                this.receipeListViewSource.Source = listReceipeListSelected;
            }
            else if (e is RemovedReceipeDateEvent)
            {
                RemovedReceipeDateEvent srcEvnt = (RemovedReceipeDateEvent)e;
                AppModel modelEvnt = (AppModel)srcEvnt.Model;
                List <SampleDataGroup> sampleDataGroups = new List <SampleDataGroup>();

                foreach (ReceipeDate receipeDate in modelEvnt.ReceipeList.Values)
                {
                    SampleDataGroup sampleDataGroup = new SampleDataGroup(receipeDate.Time.Date);

                    foreach (ReceipeTimeOfDay receipeTimeOfDay in receipeDate.ReceipeTimeOfDay.Values)
                    {
                        List <string> imgs = new List <string>();

                        foreach (Receipe receipe in receipeTimeOfDay.Receipes.Values)
                        {
                            imgs.Add(receipe.Image);
                        }

                        sampleDataGroup.Items.Add(new ItemReceipeTimeOfDay(receipeDate.Time.Date, imgs, receipeTimeOfDay.Time.TimeOfDay));
                    }

                    sampleDataGroups.Add(sampleDataGroup);
                }

                foreach (CheckBox cb in checkBoxs.Values)
                {
                    cb.Visibility = Visibility.Visible;
                }

                BubbleSort(sampleDataGroups);
                this.DefaultViewModel["Groups"] = sampleDataGroups;
            }
        }