コード例 #1
0
        private void CREATE_TEST_VIEWMODELS()
        {
            var viewModel1 = new ModuleEventViewModel
            {
                Uid            = Guid.NewGuid().ToString(),
                FirstClassDate = DateTime.ParseExact("11/09/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(13).AddMinutes(30),
                LastClassDate  = DateTime.ParseExact("05/12/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(13).AddMinutes(30),
                DtStart        = new CalDateTime(DateTime.ParseExact("11/09/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(13).AddMinutes(30)),
                DtEnd          = new CalDateTime(DateTime.ParseExact("11/09/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(14).AddMinutes(30)),
                ClassType      = "L",
                WeeksValid     = new List <int> {
                    1, 2, 4, 5, 7, 12
                },
                Location = "B3",
                Summary  = "CSCU9A1"
            };

            var viewModel2 = new ModuleEventViewModel
            {
                Uid            = Guid.NewGuid().ToString(),
                FirstClassDate = DateTime.ParseExact("12/09/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(13).AddMinutes(30),
                LastClassDate  = DateTime.ParseExact("04/12/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(13).AddMinutes(30),
                DtStart        = new CalDateTime(DateTime.ParseExact("12/09/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(13).AddMinutes(30)),
                DtEnd          = new CalDateTime(DateTime.ParseExact("12/09/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(14).AddMinutes(30)),
                ClassType      = "L",
                WeeksValid     = new List <int> {
                    1, 2, 3, 4, 5
                },
                Location = "B3",
                Summary  = "CSCU9A2"
            };

            var viewModel3 = new ModuleEventViewModel
            {
                Uid            = Guid.NewGuid().ToString(),
                FirstClassDate = DateTime.ParseExact("13/09/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(13).AddMinutes(30),
                LastClassDate  = DateTime.ParseExact("06/12/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(13).AddMinutes(30),
                DtStart        = new CalDateTime(DateTime.ParseExact("13/09/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(13).AddMinutes(30)),
                DtEnd          = new CalDateTime(DateTime.ParseExact("13/09/2018", "dd/MM/yyyy", CultureInfo.InvariantCulture).AddHours(14).AddMinutes(30)),
                ClassType      = "L",
                WeeksValid     = new List <int> {
                    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
                },
                Location = "B3",
                Summary  = "CSCU9A3"
            };

            MODULES.Add(viewModel1);
            MODULES.Add(viewModel2);
            MODULES.Add(viewModel3);
        }
コード例 #2
0
ファイル: AddModuleView.cs プロジェクト: TingAli/UniCalendar
        private void SetupView(bool isReset = false)
        {
            // Initialise Basics

            _moduleEventViewModel      = new ModuleEventViewModel();
            _moduleEventViewModel.Uid  = Guid.NewGuid().ToString();
            _moduleEventViewModel.Name = "University Calendar";

            _isSummaryValid   = false;
            _isLocationValid  = false;
            _isWeeksValid     = false;
            _isClassTypeValid = false;
            _isStartDateValid = false;
            _isEndDateValid   = false;
            _isStartTimeValid = false;
            _isEndTimeValid   = false;

            _isSettingStartDate = false;
            _isSettingEndDate   = false;
            _isSettingStartTime = false;
            _isSettingEndTime   = false;


            // Create Layout

            if (!isReset)
            {
                Title           = "Add Module";
                _addToolbarItem = new ToolbarItem
                {
                    Text = "Add"
                };
                _addToolbarItem.Clicked += _addToolbarItem_Clicked;;
                ToolbarItems.Add(_addToolbarItem);
            }

            _mainScrollViewLayout = new ScrollView();

            _mainStackLayout = new StackLayout
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand
            };

            // Create Controls

            _startTimeLabel = new Label
            {
                Text              = "Start Time",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };

            _startDateLabel = new Label
            {
                Text              = "Start Date",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };

            _startDateTimeButton = new Button
            {
                Text              = "Set Start Date and Time",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.End
            };
            _startDateTimeButton.Clicked += _startDateTimeButton_Clicked;

            _endTimeLabel = new Label
            {
                Text              = "End Time",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };

            _endDateLabel = new Label
            {
                Text              = "End Date",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };

            _endDateTimeButton = new Button
            {
                Text              = "Set End Date and Time",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.End
            };
            _endDateTimeButton.Clicked += _endDateTimeButton_Clicked;

            _summaryEntry = new Entry
            {
                Placeholder       = "Module Name...",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };
            _summaryEntry.TextChanged += _summaryEntry_TextChanged;

            _locationEntry = new Entry
            {
                Placeholder       = "Location of Class...",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };
            _locationEntry.TextChanged += _locationEntry_TextChanged;

            _weeksValidEntry = new Entry
            {
                Placeholder       = "Comma Separated Week Number...",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };
            _weeksValidEntry.TextChanged += _weeksValidEntry_TextChanged;

            _weeksValidAllWeeksButton = new Button
            {
                Text              = "All Weeks",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.End
            };
            _weeksValidAllWeeksButton.Clicked += _weeksValidAllWeeksButton_Clicked;

            _classTypePicker = new Picker
            {
                Title             = "Class Type",
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };
            _classTypes = Enum.GetNames(typeof(ClassTypesEnum)).ToList();
            foreach (var classType in _classTypes)
            {
                _classTypePicker.Items.Add(classType);
            }
            _classTypePicker.SelectedIndexChanged += _classTypePicker_SelectedIndexChanged;

            _timeEntry = new Entry
            {
                Placeholder       = "24h Time (HH:mm)",
                IsEnabled         = false,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Center
            };
            _timeEntry.TextChanged += _timeEntry_TextChanged;

            _dateSelectorCalendar = new XamForms.Controls.Calendar
            {
                BorderColor       = Color.LightGray,
                BorderWidth       = 2,
                BackgroundColor   = Color.White,
                StartDay          = DayOfWeek.Monday,
                StartDate         = DateTime.Now,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Center,
                DisableAllDates   = true
            };
            _dateSelectorCalendar.DateClicked += _dateSelectorCalendar_DateClicked;

            // Initialise Layout

            _mainStackLayout.Children.Add(_summaryEntry);
            _mainStackLayout.Children.Add(_classTypePicker);
            _mainStackLayout.Children.Add(_locationEntry);
            _mainStackLayout.Children.Add(_startTimeLabel);
            _mainStackLayout.Children.Add(_startDateLabel);
            _mainStackLayout.Children.Add(_startDateTimeButton);
            _mainStackLayout.Children.Add(_endTimeLabel);
            _mainStackLayout.Children.Add(_endDateLabel);
            _mainStackLayout.Children.Add(_endDateTimeButton);
            _mainStackLayout.Children.Add(_weeksValidEntry);
            _mainStackLayout.Children.Add(_weeksValidAllWeeksButton);
            _mainStackLayout.Children.Add(_timeEntry);
            _mainStackLayout.Children.Add(_dateSelectorCalendar);

            _mainScrollViewLayout.Content = _mainStackLayout;
            Content = _mainScrollViewLayout;

            Debug.WriteLine("DEBUG: SetupView() completed successfully.");
        }