public override void ViewDidLoad () { base.ViewDidLoad (); MainBackButtonTmp.BackButtonClick = true; _tabController = this; _localizer = new Localizer (); CustomUIViewController tabVAC, tabILL, tabOVT, tabPOV, tabEXV; tabVAC = CreateTabViewController ("VAC", 0); tabILL = CreateTabViewController ("ILL", 1); tabOVT = CreateTabViewController ("OVT", 2); tabPOV = CreateTabViewController ("POV", 3); tabEXV = CreateTabViewController ("EXV", 4); var tabs = new CustomUIViewController[] { tabVAC, tabILL, tabOVT, tabPOV, tabEXV }; ViewControllers = tabs; SelectedViewController = tabVAC; _swipeRecognizerRight = new UISwipeGestureRecognizer (OnSwipeRight){ Direction = UISwipeGestureRecognizerDirection.Right }; _swipeRecognizerLeft = new UISwipeGestureRecognizer (OnSwipeLeft){ Direction = UISwipeGestureRecognizerDirection.Left }; View.AddGestureRecognizer (_swipeRecognizerRight); View.AddGestureRecognizer (_swipeRecognizerLeft); }
private CustomUIViewController CreateTabViewController(string title, int tag){ var TabViewController = new CustomUIViewController(); TabViewController.TabBarItem = new UITabBarItem (title, UIImage.FromFile("Images/ill_"+tag+".png"), tag); TabViewController.View.BackgroundColor = UIColor.White; TabViewController.DidRotateEvent += Rotate; CreateView ( title, tag, TabViewController); return TabViewController; }
private void CreateView(string title, int tag, CustomUIViewController TabViewController){ TabViewController.View = new UIView (); TabViewController.View.BackgroundColor = UIColor.White; var vacationType = new UILabel (); vacationType.Text = title; TabViewController.View.Add (vacationType); var vacationStartDate = new UILabel (); vacationStartDate.Text = _localizer.Localize("startDate"); TabViewController.View.Add (vacationStartDate); var vacationStartDateBtn = new UIButton (); vacationStartDateBtn.SetTitle(DateTime.Now.ToString("d"), UIControlState.Normal); vacationStartDateBtn.SetTitleColor(UIColor.Blue, UIControlState.Normal); vacationStartDateBtn.Tag = STARTDATE_TAG + tag; TabViewController.View.Add (vacationStartDateBtn); var vacationEndDate = new UILabel (); vacationEndDate.Text = _localizer.Localize("endDate"); TabViewController.View.Add (vacationEndDate); var vacationEndDateBtn = new UIButton (); vacationEndDateBtn.SetTitle(DateTime.Now.ToString("d"), UIControlState.Normal); vacationEndDateBtn.SetTitleColor(UIColor.Blue, UIControlState.Normal); vacationEndDateBtn.Tag = ENDDATE_TAG + tag; TabViewController.View.Add (vacationEndDateBtn); var vacationError = new UILabel (); vacationError.Text = ""; vacationError.TextColor = UIColor.Red; vacationError.Lines = 0; vacationError.LineBreakMode = UILineBreakMode.WordWrap; vacationError.Tag = ERROR_TAG + tag; TabViewController.View.Add (vacationError); var vacationPickImageFromGallery = new UIButton (); vacationPickImageFromGallery.SetTitle(_localizer.Localize("pickImgFromGallery"), UIControlState.Normal); vacationPickImageFromGallery.SetTitleColor(UIColor.Blue, UIControlState.Normal); vacationPickImageFromGallery.Tag = PICKIMAGE_TAG + tag; TabViewController.View.Add (vacationPickImageFromGallery); var vacationImageView = new UIImageView (); vacationImageView.Tag = IMAGE_TAG + tag; TabViewController.View.Add (vacationImageView); var vacationCreateBtn = new UIButton (); vacationCreateBtn.SetTitle(_localizer.Localize("create"), UIControlState.Normal); vacationCreateBtn.SetTitleColor(UIColor.Blue, UIControlState.Normal); vacationCreateBtn.Tag = CREATE_TAG + tag; TabViewController.View.Add (vacationCreateBtn); TabViewController.View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints (); var screen = UIScreen.MainScreen.Bounds; var screenWidth = (float)screen.Width; var screenHeight = (float)screen.Height; if (InterfaceOrientation == UIInterfaceOrientation.Portrait) { TabViewController.View.AddConstraints ( vacationType.Top().EqualTo().TopOf(TabViewController.View).Plus(screenWidth/2), vacationType.CenterX().EqualTo().CenterXOf(TabViewController.View) ); } else { TabViewController.View.AddConstraints ( vacationType.Top().EqualTo().TopOf(TabViewController.View).Plus(50), vacationType.CenterX().EqualTo().CenterXOf(TabViewController.View) ); } TabViewController.View.AddConstraints ( vacationStartDate.Top().EqualTo().BottomOf(vacationType).Plus(10), vacationStartDate.CenterX().EqualTo().CenterXOf(TabViewController.View).Minus(70), vacationStartDate.Left().EqualTo().LeftOf(TabViewController.View).Plus(5), vacationStartDateBtn.Top().EqualTo().BottomOf(vacationType).Plus(3), vacationStartDateBtn.Right().EqualTo().RightOf(TabViewController.View).Minus(5), vacationEndDate.Top().EqualTo().BottomOf(vacationStartDateBtn).Plus(3), vacationEndDate.CenterX().EqualTo().CenterXOf(TabViewController.View).Minus(70), vacationEndDate.Left().EqualTo().LeftOf(TabViewController.View).Plus(5), vacationEndDateBtn.Top().EqualTo().BottomOf(vacationStartDateBtn).Minus(5), vacationEndDateBtn.Right().EqualTo().RightOf(TabViewController.View).Minus(5), vacationCreateBtn.Top().EqualTo().BottomOf(vacationEndDate).Plus(5), vacationCreateBtn.CenterX().EqualTo().CenterXOf(TabViewController.View), vacationError.Top().EqualTo().BottomOf(vacationCreateBtn), vacationError.CenterX().EqualTo().CenterXOf(TabViewController.View), vacationError.Width().LessThanOrEqualTo(screenWidth), vacationPickImageFromGallery.Top().EqualTo().BottomOf(vacationError).Minus(10), vacationPickImageFromGallery.CenterX().EqualTo().CenterXOf(TabViewController.View), vacationImageView.Top().EqualTo().TopOf(vacationPickImageFromGallery).Plus(30), vacationImageView.CenterX().EqualTo().CenterXOf(TabViewController.View) ); if (InterfaceOrientation == UIInterfaceOrientation.Portrait) { TabViewController.View.AddConstraints ( vacationImageView.Width ().LessThanOrEqualTo (screenWidth).Minus(10), vacationImageView.Height ().LessThanOrEqualTo (screenHeight / 4) ); } else { TabViewController.View.AddConstraints ( vacationImageView.Width().LessThanOrEqualTo(75), vacationImageView.Height().LessThanOrEqualTo(75) ); } }