コード例 #1
0
        public vmSettingsPage()
        {
            this.Giorni = new List <WorkingDays>();
            Giorni.Add(new WorkingDays {
                number = "1"
            });
            Giorni.Add(new WorkingDays {
                number = "2"
            });
            Giorni.Add(new WorkingDays {
                number = "3"
            });
            Giorni.Add(new WorkingDays {
                number = "4"
            });
            Giorni.Add(new WorkingDays {
                number = "5"
            });
            Giorni.Add(new WorkingDays {
                number = "6"
            });
            Giorni.Add(new WorkingDays {
                number = "7"
            });

            this.oreSettimana = new List <HoursWeek>();
            for (int i = 1; i < 101; i++)
            {
                oreSettimana.Add(new HoursWeek {
                    number = "" + i
                });
            }

            this.minHBreak = new List <MinBreakHour>();
            for (int i = 0; i < 5; i++)
            {
                minHBreak.Add(new MinBreakHour {
                    number = "" + i
                });
            }

            this.minMBreak = new List <MinBreakMinute>();
            for (int i = 0; i < 61; i++)
            {
                minMBreak.Add(new MinBreakMinute {
                    number = "" + i
                });
            }

            this.Notify = new List <string>();
            Notify.Add("-");
            Notify.Add("1");
            Notify.Add("2");
            Notify.Add("3");
            Notify.Add("4");


            #region GetValue
            try
            {
                /*Breve spiegazione triste: i raccatta la mia impostazione corrente. con linq faccio una query sulla lista giorni dicendogli che
                 * l'attributo number dell'oggetto deve essere uguale al valore raccattato con getvalue*/

                var i = ManageData.getValue("WdSelected");
                WdSelected = Giorni.Where(x => x.number == i.SettingValue).FirstOrDefault();
            }
            catch (Exception e)
            {
                //opStatus = "Not set" + e;
            }

            try
            {
                var i = ManageData.getValue("OsSelected");
                OsSelected = oreSettimana.Where(x => x.number == i.SettingValue).FirstOrDefault();
            }
            catch (Exception e)
            {
                //opStatus = "Not set" + e;
            }

            try
            {
                var i = ManageData.getValue("BHSelected");
                BHSelected = minHBreak.Where(x => x.number == i.SettingValue).FirstOrDefault();
            }
            catch (Exception e)
            {
                //opStatus = "Not set" + e;
            }

            try
            {
                var i = ManageData.getValue("BMSelected");
                BMSelected = minMBreak.Where(x => x.number == i.SettingValue).FirstOrDefault();
            }
            catch (Exception e)
            {
                //opStatus = "Not set" + e;
            }
            try
            {
                var i = ManageData.getValue("PlaySound");
                if (i.SettingValue == "False")
                {
                    isSelected = false;
                }
            }
            catch (Exception e)
            {
                //opStatus = "Not set" + e;
            }
            try
            {
                var  i             = ManageData.getValue("NotifyMe");
                bool isConvertible = false;
                int  myIndex       = 0;

                isConvertible = int.TryParse(i.SettingValue, out myIndex);
                if (isConvertible)
                {
                    notifyIndex = myIndex;
                }
                else
                {
                    notifyIndex = 0;
                }
            }
            catch (Exception e)
            {
                //opStatus = "Not set" + e;
            }
            #endregion
        }