示例#1
0
        protected override void ApplyConstraints()
        {
            View.BackgroundColor = UIColor.FromRGB(230, 229, 228);
            View.AddConstraints(
                _labelEmployee.AtTopOf(View, topPading),
                _labelEmployee.AtLeftOf(View, UIScreen.MainScreen.Bounds.Width / 9),
                _labelEmployee.Width().EqualTo(buttonWidth),
                _labelEmployee.Height().EqualTo(buttonHight),

                _employee.AtTopOf(View, topPading),
                _employee.AtRightOf(View, UIScreen.MainScreen.Bounds.Width / 9),
                _employee.WithSameTop(_labelEmployee),
                _employee.Width().EqualTo(buttonWidth),
                _employee.Height().EqualTo(buttonHight),

                _labelVacationType.Below(_labelEmployee),
                _labelVacationType.WithSameLeft(_labelEmployee),
                _labelVacationType.WithSameWidth(_labelEmployee),
                _labelVacationType.WithSameHeight(_labelEmployee),

                _vacationType.Below(_employee),
                _vacationType.WithSameLeft(_employee),
                _vacationType.WithSameWidth(_employee),
                _vacationType.WithSameHeight(_employee),

                _labelApprover.Below(_labelVacationType),
                _labelApprover.WithSameLeft(_labelVacationType),
                _labelApprover.WithSameWidth(_labelVacationType),
                _labelApprover.WithSameHeight(_labelVacationType),

                _approver.Below(_vacationType),
                _approver.WithSameLeft(_vacationType),
                _approver.WithSameWidth(_vacationType),
                _approver.WithSameHeight(_vacationType),

                _vacationError.Below(_vacationType, spacing),
                _vacationError.AtLeftOf(View),
                _vacationError.Width().EqualTo(UIScreen.MainScreen.Bounds.Width),
                _vacationError.Height().EqualTo(buttonHight),

                _vacationStartDateBtn.Below(_vacationError),
                _vacationStartDateBtn.WithSameCenterX(View),
                _vacationStartDateBtn.Width().EqualTo(UIScreen.MainScreen.Bounds.Width).Minus((UIScreen.MainScreen.Bounds.Width / 9) * 2),
                _vacationStartDateBtn.Height().EqualTo(datepickerHeigh),

                _vacationEndDateBtn.Below(_vacationStartDateBtn),
                _vacationEndDateBtn.WithSameCenterX(View),
                _vacationEndDateBtn.Width().EqualTo(UIScreen.MainScreen.Bounds.Width).Minus((UIScreen.MainScreen.Bounds.Width / 9) * 2),
                _vacationEndDateBtn.Height().EqualTo(datepickerHeigh),

                _labelDuration.Below(_vacationEndDateBtn),
                _labelDuration.WithSameLeft(_labelVacationType),
                _labelDuration.WithSameWidth(_labelVacationType),
                _labelDuration.WithSameHeight(_labelVacationType),

                _duration.Below(_vacationEndDateBtn),
                _duration.WithSameLeft(_vacationType),
                _duration.WithSameWidth(_vacationType),
                _duration.WithSameHeight(_vacationType),

                _labelVacationStatus.Below(_labelDuration),
                _labelVacationStatus.WithSameLeft(_labelVacationType),
                _labelVacationStatus.WithSameWidth(_labelVacationType),
                _labelVacationStatus.WithSameHeight(_labelVacationType),

                _vacationStatus.Below(_duration),
                _vacationStatus.WithSameLeft(_vacationType),
                _vacationStatus.WithSameWidth(_vacationType),
                _vacationStatus.WithSameHeight(_vacationType),

                _labelAttachments.Below(_vacationStatus),
                _labelAttachments.AtLeftOf(View),
                _labelAttachments.Width().EqualTo(UIScreen.MainScreen.Bounds.Width),
                _labelAttachments.Height().EqualTo(buttonHight),

                _vacationPickImageFromGallery.Below(_labelAttachments),
                _vacationPickImageFromGallery.WithSameLeft(_labelVacationType),
                _vacationPickImageFromGallery.WithSameWidth(_labelVacationType),
                _vacationPickImageFromGallery.WithSameHeight(_labelVacationType),

                _vacationPickImageFromCamera.Below(_labelAttachments),
                _vacationPickImageFromCamera.WithSameLeft(_vacationType),
                _vacationPickImageFromCamera.WithSameWidth(_vacationType),
                _vacationPickImageFromCamera.WithSameHeight(_vacationType),

                _vacationImage.Below(_vacationPickImageFromGallery, spacing),
                _vacationImage.WithSameCenterX(_labelAttachments),
                _vacationImage.Width().EqualTo(imagesize),
                _vacationImage.Height().EqualTo(imagesize)
                );
        }
示例#2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            View.BackgroundColor = UIColor.White;
            UILabel         label = new UILabel();
            UIBarButtonItem save  = new UIBarButtonItem(UIBarButtonSystemItem.Save, ButnSaveClicked);

            NavigationItem.RightBarButtonItem = save;


            if (Id == null)
            {
                _vacation                  = new Vacation();
                _vacation.Id               = new Guid();
                _vacation.Created          = DateTime.Now;
                _vacation.CreatedBy        = "Name";
                _vacation.Start            = _vacation.Created;
                _vacation.End              = _vacation.Created.AddDays(1);
                _vacation.VacationTypeId   = 1;
                _vacation.VacationStatusId = 3;
            }
            else
            {
                _vacation = _vacationViewModel.FindVacation(Id);
            }


            var controllers = new List <UIViewController>
            {
                new TypeVacViewController(View, 1),
                new TypeVacViewController(View, 2),
                new TypeVacViewController(View, 3),
                new TypeVacViewController(View, 4)
            };

            var _pageViewController = new UIPageViewController(UIPageViewControllerTransitionStyle.Scroll, UIPageViewControllerNavigationOrientation.Horizontal);
            var dataSource          = new ViewDataSource(controllers);

            _pageViewController.DataSource = dataSource;
            _pageViewController.SetViewControllers(new[] { controllers[0] }, UIPageViewControllerNavigationDirection.Forward, false, null);
            View.AddSubview(_pageViewController.View);



            UIDatePicker dateBtn = new UIDatePicker();

            dateBtn.Mode   = UIDatePickerMode.Date;
            dateBtn.Hidden = true;
            Add(dateBtn);



            UIButton uiStartButton = new UIButton();

            uiStartButton.BackgroundColor = UIColor.FromRGB(255, 255, 255);
            uiStartButton.SetTitle(_vacation.Start.ToString("d MMM yyyy"), UIControlState.Normal);
            uiStartButton.SetTitleColor(UIColor.FromRGB(160, 204, 75), UIControlState.Normal);
            Add(uiStartButton);

            UIButton uiEndButton = new UIButton();

            uiEndButton.BackgroundColor = UIColor.FromRGB(255, 255, 255);
            uiEndButton.SetTitle(_vacation.End.ToString("d MMM yyyy"), UIControlState.Normal);
            uiEndButton.SetTitleColor(UIColor.FromRGB(57, 197, 214), UIControlState.Normal);
            Add(uiEndButton);

            UISegmentedControl segmentControl = new UISegmentedControl
            {
                Frame = new CGRect(20, 20, 280, 40)
            };

            segmentControl.InsertSegment(_localizationService.Localize("Open"), 0, false);
            segmentControl.InsertSegment(_localizationService.Localize("Close"), 1, false);
            segmentControl.BackgroundColor = UIColor.FromRGB(255, 255, 255);
            segmentControl.TintColor       = UIColor.FromRGB(160, 204, 75);
            if (_vacation.VacationStatusId == 3)
            {
                segmentControl.SelectedSegment = 0;
            }
            else
            {
                segmentControl.SelectedSegment = 1;
            }

            segmentControl.ValueChanged += (sender, e) => {
                var selectedSegmentId =
                    (sender as UISegmentedControl).SelectedSegment;
                if (selectedSegmentId == 0)
                {
                    _vacation.VacationStatusId = 3;
                }
                else
                {
                    _vacation.VacationStatusId = 5;
                }
            };

            UISegmentedControl segmentControlImege = new UISegmentedControl
            {
                Frame = new CGRect(20, 20, 280, 40)
            };

            segmentControlImege.InsertSegment(UIImage.FromBundle("Icon_Request_Green"), 0, true);
            segmentControlImege.InsertSegment(UIImage.FromBundle("Icon_Request_Blue"), 1, true);
            segmentControlImege.InsertSegment(UIImage.FromBundle("Icon_Request_Gray"), 2, true);
            segmentControlImege.InsertSegment(UIImage.FromBundle("Icon_Request_Gray"), 3, true);
            segmentControlImege.InsertSegment(UIImage.FromBundle("Icon_Request_Gray"), 4, true);
            segmentControlImege.BackgroundColor = UIColor.Clear;
            segmentControlImege.TintColor       = UIColor.FromRGB(160, 204, 75);
            if (_vacation.VacationTypeId == 1)
            {
                segmentControlImege.SelectedSegment = 0;
            }
            else
            {
                segmentControlImege.SelectedSegment = 1;
            }

            segmentControlImege.ValueChanged += (sender, e) => {
                var selectedSegmentId =
                    (sender as UISegmentedControl).SelectedSegment;
                if (selectedSegmentId == 0)
                {
                    _vacation.VacationTypeId = 1;
                }
                if (selectedSegmentId == 1)
                {
                    _vacation.VacationTypeId = 2;
                }
                if (selectedSegmentId == 2)
                {
                    _vacation.VacationTypeId = 3;
                }
                if (selectedSegmentId == 4)
                {
                    _vacation.VacationTypeId = 5;
                }
                else
                {
                    _vacation.VacationTypeId = 1;
                }
            };

            Add(segmentControlImege);

            uiStartButton.TouchUpInside += (sender, arg) =>
            {
                dateBtn.Hidden        = false;
                dateBtn.ValueChanged += (s, e) =>
                {
                    DateTime reference = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(2001, 1, 1, 0, 0, 0));
                    _vacation.Start = reference.AddSeconds(dateBtn.Date.SecondsSinceReferenceDate);
                    uiStartButton.SetTitle(_vacation.Start.ToString("d MMM yyyy"), UIControlState.Normal);
                    dateBtn.Hidden = true;
                };
            };

            uiEndButton.TouchUpInside += (sender, arg) =>
            {
                dateBtn.Hidden        = false;
                dateBtn.ValueChanged += (s, e) =>
                {
                    DateTime reference = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(2001, 1, 1, 0, 0, 0));
                    _vacation.End = reference.AddSeconds(dateBtn.Date.SecondsSinceReferenceDate);
                    uiEndButton.SetTitle(_vacation.End.ToString("d MMM yyyy"), UIControlState.Normal);
                    dateBtn.Hidden = true;
                };
            };

            Add(label);
            Add(segmentControl);
            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            View.AddConstraints(

                uiStartButton.Left().EqualTo().LeftOf(View).Plus(20),
                uiStartButton.Right().EqualTo().RightOf(uiEndButton).Minus(10),
                uiStartButton.WithSameCenterY(View).Minus(150),
                uiStartButton.WithSameWidth(View).Minus(View.Center.X).Minus(30),
                uiStartButton.Height().EqualTo(40),

                uiEndButton.Left().EqualTo().RightOf(uiStartButton).Plus(10),
                uiEndButton.Right().EqualTo().RightOf(View).Minus(20),
                uiEndButton.WithSameCenterY(View).Minus(150),
                uiEndButton.WithSameWidth(View).Minus(View.Center.X).Minus(30),
                uiEndButton.Height().EqualTo(40),

                segmentControl.Below(uiStartButton, 20),
                segmentControl.WithSameCenterX(View),
                segmentControl.Width().EqualTo(180),
                segmentControl.Height().EqualTo(40),

                segmentControlImege.Below(segmentControl, 20),
                segmentControlImege.WithSameCenterX(View),
                segmentControlImege.Width().EqualTo(250),
                segmentControlImege.Height().EqualTo(40),

                dateBtn.AtBottomOf(View).Minus(80),
                dateBtn.WithSameCenterX(View),
                dateBtn.Width().EqualTo(UIScreen.MainScreen.Bounds.Width).Minus((UIScreen.MainScreen.Bounds.Width / 9) * 2),
                dateBtn.Height().EqualTo(120)
                );
        }