예제 #1
0
        private void InitFields()
        {
            var model = mWashingDayEditorController.GetModel();

            //Title
            this.WashDayNameEntry.Placeholder = "Title";
            this.WashDayNameEntry.Text        = mWashingDayEditorController.GetModel().Name;

            //Color
            colorButton.BackgroundColor = mWashingDayEditorController.GetModel().ItemColor;

            //Description
            this.Description.Placeholder = "Description";
            this.AddDescription.Clicked += AddDescription_Clicked;
            if (!String.IsNullOrWhiteSpace(model.Description))
            {
                AddDescription.IsVisible = false;
                Description.IsVisible    = true;
                Description.Text         = model.Description;
            }

            //Schedule
            var typeList = ScheduleController.CreateScheduleTypeList();

            OpenTypeButton.Source   = "combo.png";
            OpenTypeButton.Clicked += OpenTypeButton_Clicked;

            TypeSelection.ItemsSource        = typeList;
            TypeSelection.ItemDisplayBinding = new Binding("Name");

            SelectScheduleTypeView(model.Scheduled.Type);

            var i = from s in typeList where s.Type == model.Scheduled.Type select s;

            TypeSelection.SelectedItem = i.First();

            TypeSelection.SelectedIndexChanged += TypeSelection_SelectedIndexChanged;


            var schedule = model.Scheduled;

            this.StartDatePicker.MinimumDate = schedule.StartDate;
            this.StartDatePicker.Date        = schedule.StartDate;

            //Dayly
            mEntryDaylyPeriod.Text = schedule.DaylyPeriod.Period.ToString();

            //Weekly
            foreach (var d in schedule.WeeklyPeriod.WeekDays)
            {
                setWeekDay(d);
            }

            if (!schedule.WeeklyPeriod.WeekDays.Any())
            {
                setWeekDay(DayOfWeek.Monday);
            }

            mEntryWeeklyPeriod.Items.Add("1");
            mEntryWeeklyPeriod.Items.Add("2");
            mEntryWeeklyPeriod.Items.Add("3");
            mEntryWeeklyPeriod.Items.Add("4");
            mEntryWeeklyPeriod.Items.Add("5");

            mEntryWeeklyPeriod.SelectedIndex = schedule.WeeklyPeriod.Period - 1;

            //Monthly
            mEntryMonthPeriod_1.Text = schedule.MonthlyPeriod.Period.ToString();
            var occurenceList = ScheduleController.CreateMonthOccurenceTypeList();

            mPickerOcurenceInMonth.ItemsSource        = occurenceList;
            mPickerOcurenceInMonth.ItemDisplayBinding = new Binding("Name");

            var occurenceItem = from s in occurenceList where s.Type == schedule.MonthlyPeriod.Type select s;

            mPickerOcurenceInMonth.SelectedItem = occurenceItem.First();

            var weekDayList = ScheduleController.CreateDayOfWeekList();

            mPickerDayInWeek.ItemsSource        = weekDayList;
            mPickerDayInWeek.ItemDisplayBinding = new Binding("Name");

            var weekDayItem = from s in weekDayList where s.Type == schedule.MonthlyPeriod.WeekDay select s;

            mPickerDayInWeek.SelectedItem = weekDayItem.First();
        }