Example #1
0
 public override void ViewDidLoad()
 {
     base.ViewDidLoad();
     imageView.ContentMode = UIViewContentMode.ScaleAspectFit;
     scrollView.AddSubviews(imageView);
     View.AddSubviews(scrollView);
 }
 private void Constraint()
 {
     containerView.AddSubviews(content1, content2, content3);
     containerView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
     containerView.AddConstraints(
         content1.Width().EqualTo(300),
         content1.Height().EqualTo(300),
         content1.AtTopOf(containerView).Plus(20),
         content1.WithSameCenterX(containerView),
         content2.Width().EqualTo(300),
         content2.Height().EqualTo(300),
         content2.Below(content1).Plus(20),
         content2.WithSameCenterX(containerView),
         content3.Width().EqualTo(300),
         content3.Height().EqualTo(300),
         content3.Below(content2).Plus(20),
         content3.WithSameCenterX(containerView)
         );
     scrollView.AddSubviews(containerView);
     scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
     scrollView.AddConstraints(
         containerView.WithSameHeight(scrollView).Plus(300),
         containerView.WithSameWidth(scrollView)
         );
     View.AddSubviews(scrollView);
     View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
     View.AddConstraints(
         scrollView.WithSameWidth(View),
         scrollView.WithSameHeight(View).Plus(400)
         );
 }
Example #3
0
        /// <summary>
        /// Called after the controller’s <see cref="P:UIKit.UIViewController.View"/> is loaded into memory.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This method is called after <c>this</c> <see cref="T:UIKit.UIViewController"/>'s <see cref="P:UIKit.UIViewController.View"/> and its entire view hierarchy have been loaded into memory. This method is called whether the <see cref="T:UIKit.UIView"/> was loaded from a .xib file or programmatically.
        /// </para>
        /// </remarks>
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var centerButton = new UIButton(new CGRect(0, 100, 320, 40));

            centerButton.SetTitle("Master View Menu Item", UIControlState.Normal);
            centerButton.BackgroundColor = UIColor.White;
            centerButton.SetTitleColor(UIColor.Black, UIControlState.Normal);

            var exampleButton = new UIButton(new CGRect(0, 100, 320, 40));

            exampleButton.SetTitle("Example Menu Item", UIControlState.Normal);
            exampleButton.BackgroundColor = UIColor.White;
            exampleButton.SetTitleColor(UIColor.Black, UIControlState.Normal);


            var bindingSet = this.CreateBindingSet <LeftPanelView, LeftPanelViewModel>();

            bindingSet.Bind(exampleButton).To(vm => vm.ShowExampleMenuItemCommand);
            bindingSet.Bind(centerButton).To(vm => vm.ShowMasterViewCommand);
            bindingSet.Apply();

            var scrollView = new UIScrollView(View.Frame)
            {
                ShowsHorizontalScrollIndicator = false,
                AutoresizingMask = UIViewAutoresizing.FlexibleHeight
            };

            Add(scrollView);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                scrollView.AtLeftOf(View),
                scrollView.AtTopOf(View),
                scrollView.WithSameWidth(View),
                scrollView.WithSameHeight(View));

            scrollView.AddSubviews(centerButton, exampleButton);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            var constraints = scrollView.VerticalStackPanelConstraints(new Margins(20, 10, 20, 10, 5, 5), scrollView.Subviews);

            scrollView.AddConstraints(constraints);
        }
Example #4
0
        protected override void InitializeControls()
        {
            Title = "Оформление";

            _dataView = new UIScrollView(new CGRect(new CGPoint(0, 0), new CGSize(UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height - 64)));
            View.AddSubview(_dataView);

            var titleName = new UILabel(new CGRect(10f, 26f, UIScreen.MainScreen.Bounds.Width - 20f, 26f))
            {
                Text          = "Вы покупаете:",
                Font          = UIFont.SystemFontOfSize(20f),
                TextAlignment = UITextAlignment.Center
            };

            UIImage billImage     = UIImage.FromFile("Images/bill.png");
            var     billImageView = new UIImageView(new CGRect(new CGPoint((UIScreen.MainScreen.Bounds.Width - billImage.Size.Width) / 2, titleName.Frame.Bottom + 20f),
                                                               billImage.Size))
            {
                Image = billImage
            };

            _shopName = new UILabel(new CGRect(billImageView.Frame.X + 10f, billImageView.Frame.Y + 20f, billImageView.Frame.Width - 20f, 20f));
            _shopName.SetTitle();

            _productName = new UILabel(new CGRect(_shopName.Frame.X, _shopName.Frame.Bottom + 5f, _shopName.Frame.Width, 20f));
            _productName.SetTitle();

            _price = new UILabel(new CGRect(_shopName.Frame.X, _productName.Frame.Bottom + 10f, _shopName.Frame.Width, 26f));
            _price.SetTitle();

            _name = new UITextField(new CGRect(10f, billImageView.Frame.Bottom + 20f, UIScreen.MainScreen.Bounds.Width - 20f, 40f));
            _name.SetTextField(UIKeyboardType.Default, "Ваше имя");

            _phone = new UITextField(new CGRect(10f, _name.Frame.Bottom + 10f, UIScreen.MainScreen.Bounds.Width - 20f, 40f));
            _phone.SetTextField(UIKeyboardType.NumberPad, "Ваш номер телефона ");

            _payButton = new UIButton(new CGRect(10f, _phone.Frame.Bottom + 20f, UIScreen.MainScreen.Bounds.Width - 20f, 40f))
            {
                BackgroundColor = UIColor.Black
            };
            _payButton.SetTitle("ОПЛАТИТЬ", UIControlState.Normal);
            _payButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            _payButton.Layer.CornerRadius = 2f;

            _dataView.AddSubviews(titleName, billImageView, _shopName, _productName, _price, _name, _phone, _payButton);

            _dataView.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width, _payButton.Frame.Bottom + 20);
        }
    public override void ViewDidLoad()
    {
        base.ViewDidLoad();

        /*Depending on what else is on the screen, you can hard-code the
         * x, y, width and height, but in all other cases, use this:*/
        scrollView   = new UIScrollView(this.View.Bounds);
        txt_username = new UITextField(new RectangleF(5, 5, 50, 25));
        //Change other properties of the UITextfield to your liking here.
        txt_password = new UITextField(new RectangleF(5, 35, 50, 25));
        //Change other properties of the UITextfield to your liking here.
        btn_login = new UIButton(new RectangleF(5, 65, 50, 25));
        btn_login.TouchUpInside += Login;
        //Change other properties of the UIButton to your liking here.
        this.View.AddSubview(scrollView);
        scrollView.AddSubviews(new UIView[] { txt_username, txt_password, btn_login });
    }
Example #6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var viewModel = this.ViewModel;

            var scrollView = new UIScrollView(View.Frame)
            {
                ShowsHorizontalScrollIndicator = false,
                AutoresizingMask = UIViewAutoresizing.FlexibleHeight
            };
            var label = new UILabel();

            label.Text = "Info View";
            var thirdButton = new UIButton();

            thirdButton.SetTitle("Show Third ViewModel", UIControlState.Normal);
            thirdButton.BackgroundColor = UIColor.Blue;
            scrollView.AddSubviews(label, thirdButton);

            Add(scrollView);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                scrollView.AtLeftOf(View),
                scrollView.AtTopOf(View),
                scrollView.WithSameWidth(View),
                scrollView.WithSameHeight(View));
            scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            var set = this.CreateBindingSet <InfoView, InfoViewModel>();

            set.Bind(thirdButton).To(vm => vm.ShowThirdViewModelCommand);
            set.Apply();

            scrollView.AddConstraints(

                label.Below(scrollView).Plus(10),
                label.WithSameWidth(scrollView),
                label.WithSameLeft(scrollView),

                thirdButton.Below(label).Plus(10),
                thirdButton.WithSameWidth(label),
                thirdButton.WithSameLeft(label)
                );
        }
Example #7
0
        void InitializeComponents()
        {
            View.BackgroundColor = UIColor.White;

            btnAnimate = new UIBarButtonItem("Animate", UIBarButtonItemStyle.Done, BtnAnimate_Clicked);
            NavigationItem.RightBarButtonItem = btnAnimate;

            scrollView = new UIScrollView(View.Bounds)
            {
                ClipsToBounds = true,
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            if (UIDevice.CurrentDevice.CheckSystemVersion(9, 0))
            {
                scrollView.ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentBehavior.Always;
            }

            View.AddSubview(scrollView);

            lblLinear  = CreateLabel("Linear");
            linearView = CreateSphere();

            lblMaterialStandard  = CreateLabel("AnimationTimingFunction.Standard");
            materialStandardView = CreateSphere();

            lblMaterialDeceleration  = CreateLabel("AnimationTimingFunction.Deceleration");
            materialDecelerationView = CreateSphere();

            lblMaterialAcceleration  = CreateLabel("AnimationTimingFunction.Acceleration");
            materialAccelerationView = CreateSphere();

            lblMaterialSharp  = CreateLabel("AnimationTimingFunction.Sharp");
            materialSharpView = CreateSphere();

            scrollView.AddSubviews(lblLinear, linearView,
                                   lblMaterialStandard, materialStandardView,
                                   lblMaterialDeceleration, materialDecelerationView,
                                   lblMaterialAcceleration, materialAccelerationView,
                                   lblMaterialSharp, materialSharpView);

            lineSpace = (View.Frame.Height - 50) / 5 - sphereWidth - lblLinear.Frame.Height;

            AddConstraints();
        }
Example #8
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var viewModel = this.ViewModel;

            var scrollView = new UIScrollView(View.Frame)
            {
                ShowsHorizontalScrollIndicator = false,
                AutoresizingMask = UIViewAutoresizing.FlexibleHeight
            };

            var infoButton = new UIButton();

            infoButton.SetTitle("Show Info ViewModel", UIControlState.Normal);
            infoButton.BackgroundColor = UIColor.Blue;
            scrollView.AddSubviews(infoButton);

            Add(scrollView);

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            View.AddConstraints(
                scrollView.AtLeftOf(View),
                scrollView.AtTopOf(View),
                scrollView.WithSameWidth(View),
                scrollView.WithSameHeight(View));
            scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            var set = this.CreateBindingSet <TrackView, TrackViewModel>();

            set.Bind(infoButton).To("GoToInfoCommand");
            set.Apply();

            scrollView.AddConstraints(

                infoButton.Below(scrollView).Plus(10),
                infoButton.WithSameWidth(scrollView),
                infoButton.WithSameLeft(scrollView)
                );
        }
		private void InitSubviews ()
		{
			FitpulseTheme.Apply (View);

			scrollView = new UIScrollView (UIScreen.MainScreen.Bounds);
			Add (scrollView);

			if (UISwitch.Appearance.RespondsToSelector (new Selector ("onImage"))) {
			} else {
				bool showSwitchText = !UIDevice.CurrentDevice.CheckSystemVersion (7, 0);
				var onRect = new CGRect (72, 20, 76, 42);
				var offRect = new CGRect (176, 20, 76, 42);

				if (!showSwitchText) {
				  onRect.X += 20;
				  onRect.Width -= 20;
				  offRect.Width -= 20;
				}

				var onSwitch = new SwitchOnOff (onRect);
				onSwitch.SetOn (true);

				var offSwitch = new SwitchOnOff (offRect);
				offSwitch.SetOn (false);

				onSwitch.ShowText (showSwitchText);
				offSwitch.ShowText (showSwitchText);

				scrollView.AddSubviews (onSwitch, offSwitch);
			}

			progressBar = new PercentageProgressBar (new CGRect (20, 68, 280, 24));
			progressBar.Progress = 0.5f;

			scrollView.Add (progressBar);

			var loadingLabel = new UILabel (new CGRect (118, 91, 84, 19));
			loadingLabel.Text = "Loading...";
			loadingLabel.Font = UIFont.BoldSystemFontOfSize (15);
			loadingLabel.TextColor = UIColor.FromRGB (135, 141, 138);
			loadingLabel.BackgroundColor = UIColor.Clear;
			loadingLabel.TextAlignment = UITextAlignment.Center;

			scrollView.Add (loadingLabel);		

			slider = new UISlider (new CGRect (18, 121, 284, 23));
			slider.MinValue = 0;
			slider.MaxValue = 1;
			slider.Value = 0.5f;
			slider.ValueChanged += (sender, e) => {
				progressBar.Progress = slider.Value; };

			scrollView.Add (slider);	

			var uiSegmentedControl = new UISegmentedControl (new [] {"Yes", "No", "Maybe"}) {
				SelectedSegment = 0
			};

			FitpulseTheme.Apply (uiSegmentedControl);
			uiSegmentedControl.SetWidth (80.0f, 0);
			uiSegmentedControl.SetWidth (80.0f, 1);				
			
			uiSegmentedControl.Frame = new CGRect (26, 161, 268, 44);

			scrollView.Add (uiSegmentedControl);

			textField = new UITextField (new CGRect (20, 221, 280, 31));
			textField.LeftView = new UIView (new CGRect (0, 0, 5, 31));
			textField.LeftViewMode = UITextFieldViewMode.Always;
			textField.Font = UIFont.SystemFontOfSize (14);
			textField.TextColor = UIColor.White;
			textField.Background = UIImage.FromFile ("text-input.png");
			textField.VerticalAlignment = UIControlContentVerticalAlignment.Center;
			textField.Placeholder = "Text";
			FitpulseTheme.Apply (textField);

			textField.Delegate = new TextFieldDelegate ();

			scrollView.Add (textField);

			var leftTopButton = Buttons.ElementsButton ("Button", FitpulseTheme.SharedTheme.GrayButtonImage);
			var rightTopButton = Buttons.ElementsButton ("Button", FitpulseTheme.SharedTheme.GrayPressedButtonImage);

			var leftBottomButton = Buttons.ElementsButton ("Button", FitpulseTheme.SharedTheme.BlueButtonImage);
			var rightBottomButton = Buttons.ElementsButton ("Button", FitpulseTheme.SharedTheme.BluePressedButtonImage);

			leftBottomButton.SetTitleColor (UIColor.White, UIControlState.Normal);
			leftBottomButton.SetTitleColor (UIColor.DarkGray, UIControlState.Highlighted);
			rightBottomButton.SetTitleColor (UIColor.White, UIControlState.Normal);
			rightBottomButton.SetTitleColor (UIColor.DarkGray, UIControlState.Highlighted);

			leftBottomButton.SetTitleShadowColor (UIColor.DarkGray, UIControlState.Normal);
			leftBottomButton.SetTitleShadowColor (UIColor.Gray, UIControlState.Highlighted);
			rightBottomButton.SetTitleShadowColor (UIColor.DarkGray, UIControlState.Normal);
			rightBottomButton.SetTitleShadowColor (UIColor.Gray, UIControlState.Highlighted);

			leftTopButton.Frame = new CGRect (20, 268, 126, 42);
			leftBottomButton.Frame = new CGRect (20, 318, 126, 42);
			rightTopButton.Frame = new CGRect (174, 268, 126, 42);
			rightBottomButton.Frame = new CGRect (174, 318, 126, 42);

			scrollView.AddSubviews (leftTopButton, leftBottomButton, rightTopButton, rightBottomButton);
			
		}
        public UIViewController GetPage(int i)
        {
            var card = _GetOrderedCardByIndex(i);

            UIViewController viewController = new ScrollableViewController();
            viewController.View.BackgroundColor = ScreenResolutionMatcher.BackgroundColorFromImage();

            _scrollView = new UIScrollView() {
                Frame = ScreenResolutionMatcher.FullViewFrame(),
                ContentSize = ScreenResolutionMatcher.ViewFrame(),
                ScrollEnabled = true
            };
            _scrollView.AddSubview(new CardView(card));

            var matchDetailView = new MatchDetailView();
            int verticalOffset = 68 + ScreenResolutionMatcher.ContentViewStartingY();
            int offset = (card.Matches.Count <= 10) ? 28 : 26;

            if (card.IsEditable()) {
                var sorted_matches = card.Matches.OrderBy(m => m.MatchId);
                foreach (var match in sorted_matches) {
                    UIView[] matches;
                    if (card.IsKnockout) {
                        if (match.IsEditable ())
                            matches = matchDetailView.BuildForEdit (match, verticalOffset);
                        else if (match.HasRealScore())
                            matches = matchDetailView.BuildForPublished(match, verticalOffset);
                        else
                            matches = matchDetailView.BuildForReadOnly(match, verticalOffset);
                    }
                    else
                        matches = matchDetailView.BuildForEdit(match, verticalOffset);

                    verticalOffset += offset;

                    _scrollView.AddSubviews(matches);
                }

                var submitCardButton = new GlassButton(new RectangleF (10, ScreenResolutionMatcher.PushedToBottomButtonY(), 300, 40)) {
             			NormalColor = UIColor.FromRGBA(222/255f, 222/255f, 225/255f, 0.25f),
             			HighlightedColor = UIColor.Black
             			};
                submitCardButton.SetTitle("Guardar Tarjeta", UIControlState.Normal);
                submitCardButton.Font = UIFont.BoldSystemFontOfSize(14);
                submitCardButton.Tapped += delegate(GlassButton button) {
                    var firstResponder = button.Superview.FindFirstResponder();
                    if (firstResponder != null)
                        firstResponder.ResignFirstResponder();

                    //app could have been open for a while, and card might no longer be editable
                    if (card.IsEditable()) {
                        if (card.IsKnockout) { card = StripOverdueMatches(card); }
                        AppManager.Current.CardsService.SubmitCard(card);
                    }
                    else
                        new UIAlertView(Constants.APP_TITLE, "La fecha ya ha cerrado.", null, "Ok").Show();
                };
                _scrollView.AddSubview(submitCardButton);
            }
            else if (card.IsPublished()) {
                foreach (var match in card.Matches) {
                    var matches = matchDetailView.BuildForPublished(match, verticalOffset);
                    verticalOffset += offset;
                    _scrollView.AddSubviews(matches);
                }

                _scrollView.AddSubview(
                    new UILabel{
                        Text = string.Format("Fecha cerrada. Obtuviste {0} puntos!", card.Points),
                        TextAlignment = UITextAlignment.Center,
                        Frame = new RectangleF(10,ScreenResolutionMatcher.PushedToBottomButtonY(),300,40),
                        TextColor = UIColor.White,
                        Font = UIFont.BoldSystemFontOfSize(17),
                        BackgroundColor = UIColor.Clear
                });
            }
            else {
                foreach (var match in card.Matches) {
                    var matches = matchDetailView.BuildForReadOnly(match, verticalOffset);
                    verticalOffset += offset;
                    _scrollView.AddSubviews(matches);
                }

                _scrollView.AddSubview(
                    new UILabel{
                        Text = "Fecha cerrada. Pronto sabrás tus puntos!",
                        TextAlignment = UITextAlignment.Center,
                        Frame = new RectangleF(10,ScreenResolutionMatcher.PushedToBottomButtonY(),300,40),
                        TextColor = UIColor.White,
                        Font = UIFont.BoldSystemFontOfSize(15),
                        BackgroundColor = UIColor.Clear
                });
            }

            if (card.IsKnockout) {
                _scrollView.AddSubview(
                    new UILabel{
                    Text = string.Format("Total tarjeta Brasil 2014: {0} puntos!", card.Points),
                    TextAlignment = UITextAlignment.Center,
                    Frame = new RectangleF(10,ScreenResolutionMatcher.PushedToBottomButtonY()-40,300,40),
                    TextColor = UIColor.White,
                    Font = UIFont.BoldSystemFontOfSize(17),
                    BackgroundColor = UIColor.Clear
                });
            }

            viewController.View.AddSubview(_scrollView);
            //			viewController.View.AddSubview(new UIImageView() {
            //				Frame = new RectangleF(5,0,16,30),
            //				Image = UIImage.FromFile("Images/Arrow.png")
            //			});
            return viewController;
        }
Example #11
0
        protected override void InitializeObjects()
        {
            base.InitializeObjects();

            // Navigation bar
            var applicationLogo = new UIImageView(UIImage.FromBundle(@"Images/logo.png"));

            View.BackgroundColor  = UIColor.FromPatternImage(UIImage.FromFile(@"Images/main_background.png").Scale(View.Frame.Size));
            applicationLogo.Frame = new CGRect(10, 10, applicationLogo.Image.CGImage.Width, applicationLogo.Image.CGImage.Height);
            logoutButton          = RoundedButtonManager.ButtonInitiaziler("", UIImage.FromFile(@"Images/HomeView/ic_logout.png"));
            // Hide navigation bar
            NavigationController.SetNavigationBarHidden(true, false);

            var topView = new UIView();

            topView.AddIfNotNull(applicationLogo, logoutButton);
            topView.AddConstraints(
                applicationLogo.WithRelativeWidth(topView, 0.5f),
                applicationLogo.WithRelativeHeight(topView, 0.18f),
                applicationLogo.WithSameCenterX(topView),
                applicationLogo.WithSameCenterY(topView),

                logoutButton.AtTopOf(topView, 10),
                logoutButton.AtRightOf(topView),
                logoutButton.WithRelativeWidth(topView, 0.2f),
                logoutButton.WithRelativeHeight(topView, 0.4f)
                );

            // Central Board View
            boardScrollView          = CreateSliderBoard(true);
            buttonContainerView      = new UIView();
            roadInformationBoardView = new UIView();

            buttonContainerView.Frame = new CGRect(0, 0, (boardScrollView.Bounds.Width * EnvironmentInfo.GetValueForGettingWidthButtonsContainer),
                                                   (boardScrollView.Bounds.Height * 3));
            roadInformationBoardView.Frame = new CGRect((boardScrollView.Bounds.Width * EnvironmentInfo.GetValueForGettingWidthRoadInformationContainer),
                                                        EnvironmentInfo.GetValueForFirstSliderPositionY, (boardScrollView.Bounds.Width * 0.8), (boardScrollView.Bounds.Height * 2.5));
            boardScrollView.ContentSize = new CGSize((buttonContainerView.Bounds.Width + roadInformationBoardView.Bounds.Width), boardScrollView.Frame.Height);

            // Board View - Button Container
            profileButton    = RoundedButtonManager.ButtonInitiaziler("PROFILE", UIImage.FromFile(@"Images/HomeView/ic_home_profile.png"), UIImage.FromFile(@"Images/HomeView/InformationBoard/ic_pointer.png"));
            payButton        = RoundedButtonManager.ButtonInitiaziler("PAY", UIImage.FromFile(@"Images/HomeView/ic_home_pay.png"), UIImage.FromFile(@"Images/HomeView/InformationBoard/ic_pointer.png"));
            payHistoryButton = RoundedButtonManager.ButtonInitiaziler("PAY HISTORY", UIImage.FromFile(@"Images/HomeView/ic_home_pay_history.png"), UIImage.FromFile(@"Images/HomeView/InformationBoard/ic_pointer.png"));

            buttonContainerView.AddIfNotNull(profileButton, payButton, payHistoryButton);
            buttonContainerView.AddConstraints(
                profileButton.AtTopOf(buttonContainerView, EnvironmentInfo.GetMarginTopButtonsContainer),
                profileButton.AtLeftOf(buttonContainerView),
                profileButton.WithRelativeWidth(buttonContainerView, 0.4f),
                profileButton.WithRelativeHeight(buttonContainerView, 0.6f),

                payHistoryButton.AtTopOf(buttonContainerView, EnvironmentInfo.GetMarginTopButtonsContainer),
                payHistoryButton.WithSameCenterX(buttonContainerView),
                payHistoryButton.WithRelativeWidth(buttonContainerView, 0.4f),
                payHistoryButton.WithRelativeHeight(buttonContainerView, 0.6f),

                payButton.AtTopOf(buttonContainerView, EnvironmentInfo.GetMarginTopButtonsContainer),
                payButton.AtRightOf(buttonContainerView),
                payButton.WithRelativeWidth(buttonContainerView, 0.4f),
                payButton.WithRelativeHeight(buttonContainerView, 0.6f)
                );

            // Board View - Road Information Container
            nextWaypointString = BoardFieldInitializer(UIImage.FromFile(@"Images/HomeView/InformationBoard/ic_nearest_point.png"), "Nearest point in(ml):",
                                                       (roadInformationBoardView.Bounds.Width * EnvironmentInfo.GetDistanceBetweenLabelAndTextNearestPoint));
            geoLabelData = BoardFieldInitializer(UIImage.FromFile(@"Images/HomeView/InformationBoard/ic_location.png"), "Geolocation:",
                                                 (roadInformationBoardView.Bounds.Width * EnvironmentInfo.GetDistanceBetweenLabelAndTextGeolocation));
            tollRoadString = BoardFieldInitializer(UIImage.FromFile(@"Images/HomeView/InformationBoard/ic_tollroad.png"), "Tollroad:",
                                                   (roadInformationBoardView.Bounds.Width * EnvironmentInfo.GetDistanceBetweenLabelAndTextTollroad));
            statusLabel = BoardFieldInitializer(UIImage.FromFile(@"Images/HomeView/InformationBoard/ic_status.png"), "Status:",
                                                (roadInformationBoardView.Bounds.Width * EnvironmentInfo.GetDistanceBetweenLabelAndTextStatus));

            roadInformationBoardView.AddIfNotNull(nextWaypointString, geoLabelData, tollRoadString, statusLabel);
            roadInformationBoardView.AddConstraints(
                nextWaypointString.AtTopOf(roadInformationBoardView, 10),
                nextWaypointString.AtLeftOf(roadInformationBoardView, 10),
                nextWaypointString.WithSameWidth(roadInformationBoardView),
                nextWaypointString.WithRelativeHeight(roadInformationBoardView, 0.2f),

                geoLabelData.Below(nextWaypointString),
                geoLabelData.AtLeftOf(roadInformationBoardView, 10),
                geoLabelData.WithSameWidth(roadInformationBoardView),
                geoLabelData.WithRelativeHeight(roadInformationBoardView, 0.2f),

                tollRoadString.Below(geoLabelData),
                tollRoadString.AtLeftOf(roadInformationBoardView, 10),
                tollRoadString.WithSameWidth(roadInformationBoardView),
                tollRoadString.WithRelativeHeight(roadInformationBoardView, 0.2f),

                statusLabel.Below(tollRoadString),
                statusLabel.AtLeftOf(roadInformationBoardView, 10),
                statusLabel.WithSameWidth(roadInformationBoardView),
                statusLabel.WithRelativeHeight(roadInformationBoardView, 0.2f)
                );

            boardScrollView.AddSubviews(buttonContainerView, roadInformationBoardView);
            boardScrollView.Scrolled += (sender, e) =>
            {
                Debug.WriteLine(((UIScrollView)sender).ContentOffset.X);
            };

            // Slider container
            var applicationBoard = new UIImageView(UIImage.FromBundle(@"Images/HomeView/home_board.png"));

            applicationBoard.Frame = new CGRect(10, 10, applicationBoard.Image.CGImage.Width, applicationBoard.Image.CGImage.Height);
            boardContainerView     = new UIView();
            boardContainerView.AddIfNotNull(applicationBoard, boardScrollView);
            boardContainerView.AddConstraints(
                applicationBoard.WithSameHeight(boardContainerView),
                applicationBoard.WithSameWidth(boardContainerView),
                applicationBoard.WithSameCenterX(boardContainerView),
                applicationBoard.WithSameCenterY(boardContainerView),

                boardScrollView.AtTopOf(boardContainerView, 10),
                boardScrollView.AtLeftOf(boardContainerView, 25),
                boardScrollView.AtRightOf(boardContainerView, 25),
                boardScrollView.WithRelativeHeight(boardContainerView, 0.55f)
                );

            // Bottom View
            trackingButton = RoundedButtonManager.ButtonInitiaziler(EnvironmentInfo.GetTrackingButtonDistanceBetweenTextAndImage);
            this.AddLinqBinding(ViewModel, vm => vm.TrackingCommand, (value) =>
            {
                trackingButton.BackgroundColor = UIColor.White;
                trackingButton.Alpha           = 0.7f;
                trackingButton.ButtonTextColor = UIColor.FromRGB(3, 117, 27);
            });

            //var callCenterLabel = new UILabel();
            //_callCentergButton = ButtonInitiaziler(null, UIImage.FromFile(@"Images/ic_home_support.png"));
            //_callCentergButton.ButtonText.TextColor = UIColor.LightGray;
            //_callCentergButton.ButtonBackgroundColor = null;
            //callCenterLabel.Text = "+(1)305 335 85 08";
            //callCenterLabel.TextColor = UIColor.LightGray;

            var bottomView = new UIView();

            bottomView.AddIfNotNull(trackingButton);
            bottomView.AddConstraints(
                trackingButton.AtTopOf(bottomView),
                trackingButton.AtLeftOf(bottomView, 20),
                trackingButton.AtRightOf(bottomView, 20),
                trackingButton.WithRelativeHeight(bottomView, EnvironmentInfo.GetTrackingButtonHeight),
                trackingButton.WithRelativeWidth(bottomView, EnvironmentInfo.GetTrackingButtonWidth)
                );

            // View Initialising
            View.AddIfNotNull(topView, boardContainerView, bottomView);
            View.AddConstraints(
                topView.AtTopOf(View),
                topView.AtLeftOf(View),
                topView.AtRightOf(View),
                topView.WithRelativeHeight(View, 0.2f),

                boardContainerView.Below(topView),
                boardContainerView.AtLeftOf(View, 15),
                boardContainerView.AtRightOf(View, 15),
                boardContainerView.WithRelativeHeight(View, 0.43f),

                bottomView.Below(boardContainerView),
                bottomView.WithSameCenterX(topView),
                bottomView.WithRelativeHeight(View, 0.27f),
                bottomView.AtBottomOf(View, 30)
                );
        }
Example #12
0
        private void CreateView()
        {
            _scrollView = null;
            _borderView = null;
            View        = new UIView(new CGRect(0, 0, 600, 600))
            {
                BackgroundColor   = Consts.ColorMainBg,
                ContentMode       = UIViewContentMode.ScaleToFill,
                AutoresizingMask  = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight,
                AutosizesSubviews = true
            };

            #region main info
            _mainInfo = new UIView();
            //manufacture
            _manufactureLabel = new UILabel()
            {
                TextColor     = Consts.ColorGray,
                Font          = UIFont.FromName(Consts.FontNameRegular, 20),
                TextAlignment = UITextAlignment.Left,
                Lines         = 0,
                LineBreakMode = UILineBreakMode.WordWrap,
            };
            _mainInfo.Add(_manufactureLabel);
            //title
            _titleLabel = new UILabel(new CGRect(0, 5, 295, 40))
            {
                TextColor     = Consts.ColorBlack,
                Font          = UIFont.FromName(Consts.FontNameBold, 20),
                TextAlignment = UITextAlignment.Left,
                Lines         = 0,
                LineBreakMode = UILineBreakMode.WordWrap,
            };
            _mainInfo.AddSubview(_titleLabel);
            //slider
            _imageSlider = new ImageSlider()
            {
                BackgroundColor = Consts.ColorMainBg
            };
            foreach (var img in DetailViewModel.Product.Images)
            {
                _imageSlider.AddImage(UIImage.FromFile(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), img)));
            }
            _mainInfo.Add(_imageSlider);
            //price
            _listPriceLable = new UILabel(new RectangleF(0, 5, 50, 20))
            {
                TextColor     = Consts.ColorDarkLight,
                Font          = UIFont.FromName(Consts.FontNameRegular, 16),
                TextAlignment = UITextAlignment.Center,
            };
            _mainInfo.Add(_listPriceLable);
            _profitPriceLabel = new UILabel(new RectangleF(0, 5, 50, 30))
            {
                TextColor       = UIColor.White,
                Font            = UIFont.FromName(Consts.FontNameRegular, 14),
                TextAlignment   = UITextAlignment.Center,
                BackgroundColor = Consts.ColorRed
            };
            _mainInfo.Add(_profitPriceLabel);
            _salePriceLable = new UILabel(new RectangleF(0, 5, 50, 30))
            {
                TextColor     = Consts.ColorDark,
                Font          = UIFont.FromName(Consts.FontNameBold, 22),
                TextAlignment = UITextAlignment.Center,
            };
            _mainInfo.Add(_salePriceLable);
            #endregion

            #region Detail info
            _detailView = new UIView();

            //description
            _descriptionLabel = new UILabel(new RectangleF(0, 0, 295, 200))
            {
                Font          = UIFont.FromName(Consts.FontNameRegular, 17),
                TextAlignment = UITextAlignment.Left,
                TextColor     = Consts.ColorBlack,
                Lines         = 0,
                LineBreakMode = UILineBreakMode.WordWrap,
            };
            _detailView.AddSubview(_descriptionLabel);
            //tabbed
            _segmentControl = new Controls.UISimpleSegments(new CGRect(0, 0, 250, 50));
            _segmentControl.AddSegment("Properties");
            _segmentControl.AddSegment("Description");
            _segmentControl.ChangeSegment += ChangeSegment;
            _detailView.AddSubviews(_segmentControl);
            //properties
            _propertiesTable = new UITableView();
            _propertiesTable.BackgroundColor = Consts.ColorMainBg;
            _propertiesTable.ScrollEnabled   = true;
            _propertiesTable.Source          = new PropertiesSource(DetailViewModel.Product.Properties.Select(x => new KeyValuePair <string, string>(x.DisplayName, x.Value)).ToList());
            _propertiesTable.RowHeight       = PropertyCell.CellHeight;
            _propertiesTable.SeparatorStyle  = UITableViewCellSeparatorStyle.None;
            _propertiesTable.ReloadData();
            _detailView.AddSubview(_propertiesTable);
            //add to cart item
            _cartButton = Helpers.UICreator.CreateSimpleButton("Add to cart");
            _detailView.AddSubview(_cartButton);

            #endregion
            //cart button
            _cartOpenButton = new UIBarButtonItem("Cart", UIBarButtonItemStyle.Plain, (s, e) => { DetailViewModel.OpenCartCommad.Execute(); });
            NavigationItem.RightBarButtonItem = _cartOpenButton;
            if (_deviceOrientation == UIInterfaceOrientation.Portrait || _deviceOrientation == UIInterfaceOrientation.PortraitUpsideDown)
            {
                _scrollView = new UIScrollView();
                _scrollView.AddSubviews(_mainInfo, _detailView);
                View.Add(_scrollView);
            }
            else
            {
                View.AddSubviews(_mainInfo, _detailView);
                _borderView = new UIView
                {
                    BackgroundColor = Consts.ColorGray
                };
                Add(_borderView);
            }
            //bindings
            var set = this.CreateBindingSet <DetailProductView, DetailProductViewModel>();
            set.Bind(_titleLabel).To(x => x.Product.Name);
            set.Bind(_descriptionLabel).To(x => x.ProductDescription);
            set.Bind(_salePriceLable).To(x => x.Product.Price.FormattedSalePriceFull);
            set.Bind(NavigationItem).For(x => x.Title).To(x => x.Product.Name);
            set.Bind(_listPriceLable).For(x => x.AttributedText).To(x => x.Product.Price.FormattedListPriceFull).WithConversion(new StrikeTextConvertor());
            set.Bind(_manufactureLabel).For(x => x.Text).To(x => x.Product.Manufacture);
            set.Bind(_profitPriceLabel).For(x => x.Text).To(x => x.Product.Price).WithConversion(new ProfitConvertor());
            set.Bind(_descriptionLabel).For(x => x.Hidden).To(x => x.HideDescription);
            set.Bind(_propertiesTable).For(x => x.Hidden).To(x => x.HideProperties);
            set.Bind(_cartButton).To(x => x.AddToCartCommand);
            set.Bind(_cartOpenButton).For(x => x.Title).To(x => x.CountInCart);
            set.Apply();
        }
		public EditTripScreenView (RectangleF frame, Trip trip)
		{
			//this.Frame = frame;

			_scrollView = new UIScrollView (frame);
			this.BackgroundColor = UIColor.White;

			_tripNameTextField = new UITextField () { 
				Placeholder = "Trip Name",
				BorderStyle = UITextBorderStyle.RoundedRect,
			};

			_tripNameTextField = new UITextField () { 
				Placeholder = "trip name",
				BorderStyle = UITextBorderStyle.None,
				Font = UIFont.FromName("AvenirNext-Medium", 16f),
				TextColor = UIColor.Black,
				BackgroundColor = UIColor.White
			};

			_btnStartDate = UIButton.FromType (UIButtonType.Custom);
			_btnStartDate.SetTitle ("from Wednessday, Jul 17, 2013", UIControlState.Normal);
			_btnStartDate.SetTitleColor (UIColor.White, UIControlState.Normal);
			_btnStartDate.SetTitleColor (UIColor.LightGray, UIControlState.Highlighted);
			_btnStartDate.Font = UIFont.FromName ("AvenirNext-Medium", 16f);



			actionSheetDatePickerStartDate = new ActionSheetDatePicker (this);
			actionSheetDatePickerStartDate.Title = "Choose Date:";
			actionSheetDatePickerStartDate.DatePicker.Mode = UIDatePickerMode.Date;
			actionSheetDatePickerStartDate.DatePicker.ValueChanged += (sender, e) => {
				DateTime selectedDate = (sender as UIDatePicker).Date;
				_btnStartDate.SetTitle(selectedDate.ToString("D"), UIControlState.Normal); 
			};

			_btnStartDate.TouchUpInside += (sender, e) => {
				actionSheetDatePickerStartDate.Show(); 
			};

			_btnEndDate = UIButton.FromType (UIButtonType.Custom);
			_btnEndDate.SetTitle ("to Wednessday, Jul 17, 2013", UIControlState.Normal);
			_btnEndDate.SetTitleColor (UIColor.White, UIControlState.Normal);
			_btnEndDate.SetTitleColor (UIColor.LightGray, UIControlState.Highlighted);
			_btnEndDate.Font = UIFont.FromName ("AvenirNext-Medium", 16f);

			_btnEndDate.TouchUpInside += (sender, e) => {
				actionSheetDatePickerEndDate.Show();
			};
			actionSheetDatePickerEndDate = new ActionSheetDatePicker (this);
			actionSheetDatePickerEndDate.Title = "Choose Date:";
			actionSheetDatePickerEndDate.DatePicker.Mode = UIDatePickerMode.Date;
			actionSheetDatePickerEndDate.DatePicker.ValueChanged += (sender, e) => {
				DateTime selectedDate = (sender as UIDatePicker).Date;
				_btnEndDate.SetTitle(selectedDate.ToString("D"), UIControlState.Normal); 
			};


			_tripDescTextField = new UITextView () { 
				Font = UIFont.FromName("AvenirNext-Medium", 16f),
				TextColor = UIColor.Black,
				BackgroundColor = UIColor.White,
				Text = "Desc"
			};


			_tripBudgetTextField = new UITextField () { 
				Placeholder = "budget",
				BorderStyle = UITextBorderStyle.None,
				Font = UIFont.FromName("AvenirNext-Medium", 16f),
				TextColor = UIColor.Black,
				BackgroundColor = UIColor.White,
				KeyboardType = UIKeyboardType.NumberPad
			};

			ButtonExpenses = UIButton.FromType (UIButtonType.RoundedRect);
			ButtonExpenses.SetTitle ("expenses", UIControlState.Normal);


			ButtonDeleteTrip = UIButton.FromType (UIButtonType.RoundedRect);
			ButtonDeleteTrip.SetTitle ("delete trip", UIControlState.Normal);

			_tripNameTextField.SizeToFit ();
			_btnStartDate.SizeToFit ();
			_btnEndDate.SizeToFit ();
			_tripDescTextField.SizeToFit ();
			_tripBudgetTextField.SizeToFit ();
			ButtonExpenses.SizeToFit ();

			ButtonDeleteTrip.SizeToFit();

			_tripNameTextField.ShouldReturn += (t) => {
				t.ResignFirstResponder();
				return true;
			};


			// set content size to default for now
			//TODO: implement observer and set accordingly
			_scrollView.ContentSize = new SizeF (frame.Width, frame.Height);

			_scrollView.AddSubviews (_tripNameTextField, _btnStartDate, 
			                         _btnEndDate, _tripDescTextField,
			                         _tripBudgetTextField, ButtonExpenses, ButtonDeleteTrip);

			_scrollView.SizeToFit ();
			_scrollView.BackgroundColor = this.BackgroundColor = UIColor.DarkGray;

			this.AddSubview ( _scrollView);
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _guitarLabel = new UILabel
            {
                Text             = $"{_guitar?.Manufacturer} {_guitar.Name} (introduced: {_guitar.YearIntroduced})",
                TextColor        = UIColor.White,
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                Lines            = 1,
                TextAlignment    = UITextAlignment.Center,
                Frame            = new CGRect(
                    0,
                    36,
                    View.Bounds.Width,
                    31.0f)
            };
            _guitarLabel.Font.WithSize(24);

            _guitarImage = new UIImageView
            {
                Image            = UIImage.FromBundle(_guitar.LargeImageUrl),
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth,
                Frame            = new CGRect(
                    (int)(View.Bounds.GetMidX() - (_guitar.LargeImageWidth / 2)),
                    _guitarLabel.Frame.Bottom + 10,
                    _guitar.LargeImageWidth,
                    _guitar.LargeImageHeight)
            };

            NSUrl url = new NSUrl(_guitar.DetailsURL);

            _webviewButton = UIButton.FromType(UIButtonType.RoundedRect);
            _webviewButton.SetTitle("WV Details", UIControlState.Normal);
            _webviewButton.BackgroundColor = UIColor.SystemBlueColor;
            _webviewButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            _webviewButton.Layer.CornerRadius = 5f;
            _webviewButton.AutoresizingMask   = UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleBottomMargin;
            _webviewButton.Frame = new CGRect(
                (int)(View.Bounds.GetMidX() - (_guitar.LargeImageWidth / 2)),
                _guitarImage.Frame.Bottom + 20,
                _guitarImage.Frame.Width,
                31.0f);
            _webviewButton.TouchUpInside += (sender, e) =>
            {
                WKWebView webView = new WKWebView(View.Frame, new WKWebViewConfiguration());
                View.AddSubview(webView);
                var request = new NSUrlRequest(url);
                webView.LoadRequest(request);

                Console.WriteLine("WebView Details button clicked.");
            };

            _safariButton = UIButton.FromType(UIButtonType.RoundedRect);
            _safariButton.SetTitle("SF Details", UIControlState.Normal);
            _safariButton.BackgroundColor = UIColor.SystemBlueColor;
            _safariButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            _safariButton.Layer.CornerRadius = 5f;
            _safariButton.AutoresizingMask   = UIViewAutoresizing.FlexibleRightMargin | UIViewAutoresizing.FlexibleBottomMargin;
            _safariButton.Frame = new CGRect(
                (int)(View.Bounds.GetMidX() - (_guitar.LargeImageWidth / 2)),
                _webviewButton.Frame.Bottom + 20,
                _guitarImage.Frame.Width,
                31.0f);
            _safariButton.TouchUpInside += (sender, e) =>
            {
                SFSafariViewController sfViewController = new SFSafariViewController(url);
                sfViewController.ShouldAutorotate();
                this.PresentViewController(sfViewController, true, null);

                Console.WriteLine("SafariViewControllerButton Details button clicked.");
            };

            // SG Image 864 x 1152
            //_imageViewSG = new UIImageView(UIImage.FromBundle("SG_Standard_LG.jpg"));
            //_imageViewSG.TranslatesAutoresizingMaskIntoConstraints = false;
            //_imageViewSG.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);

            _scrollView                  = new UIScrollView(new RectangleF(0, 0, (float)View.Frame.Width, (float)View.Frame.Height));
            _scrollView.ContentSize      = new CGSize(UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);
            _scrollView.MaximumZoomScale = 3f;
            _scrollView.MinimumZoomScale = .1f;
            _scrollView.TranslatesAutoresizingMaskIntoConstraints = false;
            _scrollView.BackgroundColor  = UIColor.SystemOrangeColor;
            _scrollView.AutoresizingMask = UIViewAutoresizing.FlexibleDimensions;
            View.AddSubview(_scrollView);

            _scrollView.TopAnchor.ConstraintEqualTo(View.TopAnchor, 0).Active           = true;
            _scrollView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor, 0).Active     = true;
            _scrollView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor, 0).Active   = true;
            _scrollView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor, 0).Active = true;


            //_imageViewSG.Center = _scrollView.Center;
            _scrollView.AddSubviews(new UIView[] { _guitarLabel, _guitarImage, _webviewButton, _safariButton });

            //_scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return _imageViewSG; };

            //_imageViewSG.TopAnchor.ConstraintEqualTo(_scrollView.TopAnchor, 0).Active = true;
            ////_imageViewSG.WidthAnchor.ConstraintEqualTo(UIScreen.MainScreen.Bounds.Width).Active = true;
            ////_imageViewSG.HeightAnchor.ConstraintEqualTo(UIScreen.MainScreen.Bounds.Height).Active = true;
            ////_imageViewSG.TrailingAnchor.ConstraintEqualTo(_scrollView.TrailingAnchor, 0).Active = true;
        }
        public EditTripScreenView(RectangleF frame, Trip trip)
        {
            //this.Frame = frame;

            _scrollView          = new UIScrollView(frame);
            this.BackgroundColor = UIColor.White;

            _tripNameTextField = new UITextField()
            {
                Placeholder = "Trip Name",
                BorderStyle = UITextBorderStyle.RoundedRect,
            };

            _tripNameTextField = new UITextField()
            {
                Placeholder     = "trip name",
                BorderStyle     = UITextBorderStyle.None,
                Font            = UIFont.FromName("AvenirNext-Medium", 16f),
                TextColor       = UIColor.Black,
                BackgroundColor = UIColor.White
            };

            _btnStartDate = UIButton.FromType(UIButtonType.Custom);
            _btnStartDate.SetTitle("from Wednessday, Jul 17, 2013", UIControlState.Normal);
            _btnStartDate.SetTitleColor(UIColor.White, UIControlState.Normal);
            _btnStartDate.SetTitleColor(UIColor.LightGray, UIControlState.Highlighted);
            _btnStartDate.Font = UIFont.FromName("AvenirNext-Medium", 16f);



            actionSheetDatePickerStartDate                          = new ActionSheetDatePicker(this);
            actionSheetDatePickerStartDate.Title                    = "Choose Date:";
            actionSheetDatePickerStartDate.DatePicker.Mode          = UIDatePickerMode.Date;
            actionSheetDatePickerStartDate.DatePicker.ValueChanged += (sender, e) => {
                DateTime selectedDate = (sender as UIDatePicker).Date;
                _btnStartDate.SetTitle(selectedDate.ToString("D"), UIControlState.Normal);
            };

            _btnStartDate.TouchUpInside += (sender, e) => {
                actionSheetDatePickerStartDate.Show();
            };

            _btnEndDate = UIButton.FromType(UIButtonType.Custom);
            _btnEndDate.SetTitle("to Wednessday, Jul 17, 2013", UIControlState.Normal);
            _btnEndDate.SetTitleColor(UIColor.White, UIControlState.Normal);
            _btnEndDate.SetTitleColor(UIColor.LightGray, UIControlState.Highlighted);
            _btnEndDate.Font = UIFont.FromName("AvenirNext-Medium", 16f);

            _btnEndDate.TouchUpInside += (sender, e) => {
                actionSheetDatePickerEndDate.Show();
            };
            actionSheetDatePickerEndDate                          = new ActionSheetDatePicker(this);
            actionSheetDatePickerEndDate.Title                    = "Choose Date:";
            actionSheetDatePickerEndDate.DatePicker.Mode          = UIDatePickerMode.Date;
            actionSheetDatePickerEndDate.DatePicker.ValueChanged += (sender, e) => {
                DateTime selectedDate = (sender as UIDatePicker).Date;
                _btnEndDate.SetTitle(selectedDate.ToString("D"), UIControlState.Normal);
            };


            _tripDescTextField = new UITextView()
            {
                Font            = UIFont.FromName("AvenirNext-Medium", 16f),
                TextColor       = UIColor.Black,
                BackgroundColor = UIColor.White,
                Text            = "Desc"
            };


            _tripBudgetTextField = new UITextField()
            {
                Placeholder     = "budget",
                BorderStyle     = UITextBorderStyle.None,
                Font            = UIFont.FromName("AvenirNext-Medium", 16f),
                TextColor       = UIColor.Black,
                BackgroundColor = UIColor.White,
                KeyboardType    = UIKeyboardType.NumberPad
            };

            ButtonExpenses = UIButton.FromType(UIButtonType.RoundedRect);
            ButtonExpenses.SetTitle("expenses", UIControlState.Normal);


            ButtonDeleteTrip = UIButton.FromType(UIButtonType.RoundedRect);
            ButtonDeleteTrip.SetTitle("delete trip", UIControlState.Normal);

            _tripNameTextField.SizeToFit();
            _btnStartDate.SizeToFit();
            _btnEndDate.SizeToFit();
            _tripDescTextField.SizeToFit();
            _tripBudgetTextField.SizeToFit();
            ButtonExpenses.SizeToFit();

            ButtonDeleteTrip.SizeToFit();

            _tripNameTextField.ShouldReturn += (t) => {
                t.ResignFirstResponder();
                return(true);
            };


            // set content size to default for now
            //TODO: implement observer and set accordingly
            _scrollView.ContentSize = new SizeF(frame.Width, frame.Height);

            _scrollView.AddSubviews(_tripNameTextField, _btnStartDate,
                                    _btnEndDate, _tripDescTextField,
                                    _tripBudgetTextField, ButtonExpenses, ButtonDeleteTrip);

            _scrollView.SizeToFit();
            _scrollView.BackgroundColor = this.BackgroundColor = UIColor.DarkGray;

            this.AddSubview(_scrollView);
        }
Example #16
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Title =
                new UILabel(new CGRect(60, 0, NavigationController.Toolbar.Frame.Width,
                                       NavigationController.Toolbar.Frame.Height))
            {
                TextColor       = Style.Header.TextColor,
                BackgroundColor = UIColor.Clear
            };

            GoBackButton = new UIButton(new CGRect(0, 0, 60, NavigationController.Toolbar.Frame.Height))
            {
                TintColor = Style.Header.TextColor,
                Hidden    = true
            };

            GoBackButton.TouchDown += OnClickGoBack;
            GoBackButton.SetImage(UIImage.FromBundle("back").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIControlState.Normal);

            GalleryView = new UIView()
            {
                Hidden = true
            };

            ChoosePicture       = UIButton.FromType(UIButtonType.RoundedRect);
            ChoosePicture.Frame = new CGRect(0, 0, View.Frame.Width / 2, 40);

            ChoosePicture.TintColor       = Style.Header.TextColor;
            ChoosePicture.BackgroundColor = UIColor.LightGray;

            ChoosePicture.SetTitle(Translator.GetText("choose_picture"), UIControlState.Normal);

            ChoosePicture.TouchDown += OnClickChoosePicture;

            TakePicture       = UIButton.FromType(UIButtonType.RoundedRect);
            TakePicture.Frame = new CGRect(View.Frame.Width / 2, 0, View.Frame.Width / 2, 40);

            TakePicture.TintColor       = Style.Header.TextColor;
            TakePicture.BackgroundColor = UIColor.LightGray;

            TakePicture.SetTitle(Translator.GetText("take_picture"), UIControlState.Normal);

            TakePicture.TouchDown += OnClickTakePicture;

            GalleryView.AddSubviews(ChoosePicture, TakePicture);

            NavigationController.NavigationBar.AddSubviews(GoBackButton);

            NavigationController.NavigationBar.TintColor    = Style.Header.TextColor;
            NavigationController.NavigationBar.BarTintColor = Style.Header.BackgroundColor;

            NavigationController.NavigationBar.AddSubviews(Title);

            var scrollView = new UIScrollView(View.Frame)
            {
                ShowsHorizontalScrollIndicator = false,
                AutoresizingMask = UIViewAutoresizing.FlexibleHeight
            };

            WebView = new UIWebView
            {
                ScalesPageToFit = true
            };

            scrollView.AddSubviews(WebView, GalleryView);

            Add(scrollView);

            View.AddConstraints(
                scrollView.AtLeftOf(View),
                scrollView.AtTopOf(View),
                scrollView.WithSameWidth(View),
                scrollView.WithSameHeight(View),

                WebView.AtLeftOf(scrollView),
                WebView.AtTopOf(scrollView),
                WebView.WithSameWidth(scrollView),
                WebView.WithSameHeight(scrollView),

                GalleryView.AtLeftOf(scrollView),
                GalleryView.AtTopOf(scrollView),
                GalleryView.WithSameWidth(scrollView),
                GalleryView.WithSameHeight(scrollView),

                TakePicture.AtLeftOf(GalleryView),
                TakePicture.AtTopOf(GalleryView),

                ChoosePicture.AtRightOf(GalleryView),
                ChoosePicture.AtTopOf(GalleryView)
                );

            View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            scrollView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();

            MenuClickEvent.AddListener(this);

            var menuItem = MenuViewModel.MenuItems.First();

            OnMenuItemClick(menuItem.menu_title, menuItem.url, 0);

            _spinner = new Spinner(View);

            WebView.Delegate = new WebViewDelegate(_spinner, this);
        }
        public void DrawOpeningPage()
        {
            try
            {
                int iDownloaded;
                int iOpenBtnStatus = 1; //Default is on
                int iUploadBtnStatus = 0; //Default is off
                int iRemoveBtnStatus = 0; //Default is off
                string sStatusText = "";
                int iColNo = 0;
                string sId = "";
                int iOpenBtnId = -1;
                float iTotalHeight = 0.0f;

                float iVert = 100.0f;
                float iRowHeight = 50f;
                UIScrollView layout = new UIScrollView();
                layout.Frame = new RectangleF(0f,0f,1000f,620f);
                layout.Tag = 2;
                View.AddSubview(layout);

                //Place the headings
                UIView[] arrItems = new UIView[7];

                //Create the headings
                iUtils.CreateFormGridItem lblProjIdHdr = new iUtils.CreateFormGridItem();
                UIView lblProjIdHdrVw = new UIView();
                lblProjIdHdr.SetDimensions(10f,iVert, 100f, iRowHeight, 2f, 2f, 2f, 2f);
                lblProjIdHdr.SetLabelText("Project Id");
                lblProjIdHdr.SetBorderWidth(1.0f);
                lblProjIdHdr.SetFontName("Verdana-Bold");
                lblProjIdHdr.SetFontSize(12f);
                lblProjIdHdr.SetCellColour("DarkSlateGrey");
                lblProjIdHdr.SetTextColour("White");
                lblProjIdHdr.SetTextAlignment("centre");
                lblProjIdHdrVw = lblProjIdHdr.GetLabelCell();
                arrItems[0] = lblProjIdHdrVw;

                iUtils.CreateFormGridItem lblDescHdr = new iUtils.CreateFormGridItem();
                UIView lblDescHdrVw = new UIView();
                lblDescHdr.SetDimensions(109f,iVert, 250f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
                lblDescHdr.SetLabelText("Description");
                lblDescHdr.SetBorderWidth(1.0f);
                lblDescHdr.SetFontName("Verdana-Bold");
                lblDescHdr.SetFontSize(12f);
                lblDescHdr.SetCellColour("DarkSlateGrey");
                lblDescHdr.SetTextColour("White");
                lblDescHdr.SetTextAlignment("centre");
                lblDescHdrVw = lblDescHdr.GetLabelCell();
                arrItems[1] = lblDescHdrVw;

                iUtils.CreateFormGridItem lblOpenHdr = new iUtils.CreateFormGridItem();
                UIView lblOpenHdrVw = new UIView();
                lblOpenHdr.SetDimensions(358f,iVert,100f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
                lblOpenHdr.SetLabelText("Open");
                lblOpenHdr.SetBorderWidth(1.0f);
                lblOpenHdr.SetFontName("Verdana-Bold");
                lblOpenHdr.SetFontSize(12f);
                lblOpenHdr.SetCellColour("DarkSlateGrey");
                lblOpenHdr.SetTextColour("White");
                lblOpenHdr.SetTextAlignment("centre");
                lblOpenHdrVw = lblOpenHdr.GetLabelCell();
                arrItems[2] = lblOpenHdrVw;

                iUtils.CreateFormGridItem lblUploadHdr = new iUtils.CreateFormGridItem();
                UIView lblUploadHdrVw = new UIView();
                lblUploadHdr.SetDimensions(457f,iVert,100f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
                lblUploadHdr.SetLabelText("Upload");
                lblUploadHdr.SetBorderWidth(1.0f);
                lblUploadHdr.SetFontName("Verdana-Bold");
                lblUploadHdr.SetFontSize(12f);
                lblUploadHdr.SetCellColour("DarkSlateGrey");
                lblUploadHdr.SetTextColour("White");
                lblUploadHdr.SetTextAlignment("centre");
                lblUploadHdrVw = lblUploadHdr.GetLabelCell();
                arrItems[3] = lblUploadHdrVw;

                iUtils.CreateFormGridItem lblBackupHdr = new iUtils.CreateFormGridItem();
                UIView lblBackupHdrVw = new UIView();
                lblBackupHdr.SetDimensions(556f,iVert,100f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
                lblBackupHdr.SetLabelText("Backup");
                lblBackupHdr.SetBorderWidth(1.0f);
                lblBackupHdr.SetFontName("Verdana-Bold");
                lblBackupHdr.SetFontSize(12f);
                lblBackupHdr.SetCellColour("DarkSlateGrey");
                lblBackupHdr.SetTextColour("White");
                lblBackupHdr.SetTextAlignment("centre");
                lblBackupHdrVw = lblBackupHdr.GetLabelCell();
                arrItems[4] = lblBackupHdrVw;

                iUtils.CreateFormGridItem lblRemoveHdr = new iUtils.CreateFormGridItem();
                UIView lblRemoveHdrVw = new UIView();
                lblRemoveHdr.SetDimensions(655f,iVert,100f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
                lblRemoveHdr.SetLabelText("Remove");
                lblRemoveHdr.SetBorderWidth(1.0f);
                lblRemoveHdr.SetFontName("Verdana-Bold");
                lblRemoveHdr.SetFontSize(12f);
                lblRemoveHdr.SetCellColour("DarkSlateGrey");
                lblRemoveHdr.SetTextColour("White");
                lblRemoveHdr.SetTextAlignment("centre");
                lblRemoveHdrVw = lblRemoveHdr.GetLabelCell();
                arrItems[5] = lblRemoveHdrVw;

                iUtils.CreateFormGridItem lblStatusHdr = new iUtils.CreateFormGridItem();
                UIView lblStatusHdrVw = new UIView();
                lblStatusHdr.SetDimensions(754f,iVert,246f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
                lblStatusHdr.SetLabelText("Status");
                lblStatusHdr.SetBorderWidth(1.0f);
                lblStatusHdr.SetFontName("Verdana-Bold");
                lblStatusHdr.SetFontSize(12f);
                lblStatusHdr.SetCellColour("DarkSlateGrey");
                lblStatusHdr.SetTextColour("White");
                lblStatusHdr.SetTextAlignment("centre");
                lblStatusHdrVw = lblStatusHdr.GetLabelCell();
                arrItems[6] = lblStatusHdrVw;

                layout.AddSubviews(arrItems);

                //Loop around for each item and place in the psuedo table
                DataSet arrITP = GetITPsDownloadedLocal();
                if(arrITP.Tables.Count >0)
                {
                    UIView[] arrItems2 = new UIView[10];
                    int iRows = arrITP.Tables[0].Rows.Count;
                    m_iProjectsInList = iRows;
                    iTotalHeight = (iRows+1) * iRowHeight;

                    for (int i = 0; i < iRows; i++)
                    {
                        sStatusText = "";

                        iVert += (iRowHeight - 1.0f); //Make it 1 less so that the border does not double up
                        iUtils.CreateFormGridItem lblProjId = new iUtils.CreateFormGridItem();
                        UIView lblProjIdVw = new UIView();
                        lblProjId.SetDimensions(10f,iVert, 100f, iRowHeight, 2f, 2f, 2f, 2f);
                        iColNo = arrITP.Tables[0].Columns["ID"].Ordinal;
                        sId = arrITP.Tables[0].Rows[i].ItemArray[iColNo].ToString();
                        lblProjId.SetLabelText(sId);
                        lblProjId.SetBorderWidth(1.0f);
                        lblProjId.SetFontName("Verdana");
                        lblProjId.SetFontSize(12f);
                        lblProjId.SetTag(iProjectIdTagId * (i+1));
                        lblProjIdVw = lblProjId.GetLabelCell();
                        arrItems2[0] = lblProjIdVw;

                        iUtils.CreateFormGridItem lblDesc = new iUtils.CreateFormGridItem();
                        UIView lblDescVw = new UIView();
                        lblDesc.SetDimensions(109f,iVert, 250f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
                        iColNo = arrITP.Tables[0].Columns["ProjectDesc"].Ordinal;
                        lblDesc.SetLabelText(arrITP.Tables[0].Rows[i].ItemArray[iColNo].ToString());
                        lblDesc.SetBorderWidth(1.0f);
                        lblDesc.SetFontName("Verdana");
                        lblDesc.SetFontSize(12f);
                        lblDesc.SetTag(iProjectDescTagId * (i+1));
                        lblDescVw = lblDesc.GetLabelCell();
                        arrItems2[1] = lblDescVw;

                        //If uploaded back to main DB then disable the open button
                        iColNo = arrITP.Tables[0].Columns["Downloaded"].Ordinal;
                        iDownloaded = Convert.ToInt16(arrITP.Tables[0].Rows[i].ItemArray[iColNo]);

                        iUtils.CreateFormGridItem btnOpen = new iUtils.CreateFormGridItem();
                        UIView btnOpenVw = new UIView();
                        btnOpen.SetDimensions(358f,iVert, 100f, iRowHeight, 8f, 4f, 8f, 4f); //Set left to 1 less so border does not double up
                        btnOpen.SetLabelText("Open");
                        btnOpen.SetBorderWidth(1.0f);
                        btnOpen.SetFontName("Verdana");
                        btnOpen.SetFontSize(14f);
                        iOpenBtnId = iOpenBtnTagId * (i+1);
                        btnOpen.SetTag(iOpenBtnId);
                        btnOpenVw = btnOpen.GetButtonCell();

                        UIButton btnOpenButton = new UIButton();
                        btnOpenButton = btnOpen.GetButton();
                        btnOpenButton.TouchUpInside += (sender,e) => {OpenITP(sender, e);};
                        iOpenBtnStatus = 1;
                        if (iDownloaded == 1)
                        {
                            btnOpenButton.Enabled = false;
                            sStatusText += "Uploaded already. You can remove the project or you must download again to make changes.";
                            iOpenBtnStatus = 0;
                            iRemoveBtnStatus = 1;
                        }
                        else
                        {
                            sStatusText += "Ready for modification, backup or upload.";
                        }

                        arrItems2[2] = btnOpenVw;

                        iUtils.CreateFormGridItem btnUpload = new iUtils.CreateFormGridItem();
                        UIView btnUploadVw = new UIView();
                        btnUpload.SetDimensions(457f,iVert, 100f, iRowHeight, 8f, 4f, 8f, 4f); //Set left to 1 less so border does not double up
                        btnUpload.SetLabelText("Upload");
                        btnUpload.SetBorderWidth(1.0f);
                        btnUpload.SetFontName("Verdana");
                        btnUpload.SetFontSize(14f);
                        btnUpload.SetTag(iUploadBtnTagId * (i+1));
                        btnUploadVw = btnUpload.GetButtonCell();

                        UIButton btnUploadButton = new UIButton();
                        btnUploadButton = btnUpload.GetButton();
                        btnUploadButton.TouchUpInside += (sender,e) => {UploadITPQuestion(sender, e, 1);};

                        iUploadBtnStatus = 1;

                        iUtils.CreateFormGridItem btnBackup = new iUtils.CreateFormGridItem();
                        UIView btnBackupVw = new UIView();
                        btnBackup.SetDimensions(556f,iVert, 100f, iRowHeight, 8f, 4f, 8f, 4f); //Set left to 1 less so border does not double up
                        btnBackup.SetLabelText("Backup");
                        btnBackup.SetBorderWidth(1.0f);
                        btnBackup.SetFontName("Verdana");
                        btnBackup.SetFontSize(14f);
                        btnBackup.SetTag(iBackupBtnTagId * (i+1));
                        btnBackupVw = btnBackup.GetButtonCell();

                        UIButton btnBackupButton = new UIButton();
                        btnBackupButton = btnBackup.GetButton();
                        btnBackupButton.TouchUpInside += (sender,e) => {UploadITPQuestion(sender, e, 2);};

                        //iBackupBtnStatus = 1;

                        iUtils.CreateFormGridItem btnRemove = new iUtils.CreateFormGridItem();
                        UIView btnRemoveVw = new UIView();
                        btnRemove.SetDimensions(655f,iVert, 100f, iRowHeight, 8f, 4f, 8f, 4f); //Set left to 1 less so border does not double up
                        btnRemove.SetLabelText("Remove");
                        btnRemove.SetBorderWidth(1.0f);
                        btnRemove.SetFontName("Verdana");
                        btnRemove.SetFontSize(14f);
                        btnRemove.SetTag(iRemoveBtnTagId * (i+1));
                        btnRemoveVw = btnRemove.GetButtonCell();

                        UIButton btnRemoveButton = new UIButton();
                        btnRemoveButton = btnRemove.GetButton();
                        btnRemoveButton.TouchUpInside += (sender,e) => {RemoveITP(sender, e);};
                        btnRemoveButton.Enabled = false;

                        //If not logged in then you cannot upload
                        if (m_sUser == "Not logged in to SCMS" )
                        {
                            btnUploadButton.Enabled = false;
                            btnBackupButton.Enabled = false;
                            iUploadBtnStatus = 0;
                            if (iDownloaded != 1)
                            {
                                sStatusText += "You must login to upload.";
                            }
                        }

                        if (iDownloaded == 1)
                        {
                            btnUploadButton.Enabled = false;
                            btnBackupButton.Enabled = false;
                            iUploadBtnStatus = 0;
                            btnRemoveButton.Enabled = true;
                            iRemoveBtnStatus = 1;
                        }

                        arrItems2[3] = btnUploadVw;
                        arrItems2[4] = btnBackupVw;
                        arrItems2[5] = btnRemoveVw;

                        iUtils.CreateFormGridItem lblStatus = new iUtils.CreateFormGridItem();
                        UIView lblStatusVw = new UIView();
                        lblStatus.SetDimensions(754f,iVert, 246f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
                        lblStatus.SetLabelText(sStatusText);
                        lblStatus.SetBorderWidth(1.0f);
                        lblStatus.SetFontName("Verdana");
                        lblStatus.SetFontSize(12f);
                        lblStatus.SetTag(iProjStatusTagId * (i+1));
                        lblStatusVw = lblStatus.GetLabelCell();
                        arrItems2[6] = lblStatusVw;

                        UILabel hfOpenBtnStatus = new UILabel();
                        hfOpenBtnStatus.Tag = (iOpenBtnStatusTagId * (i+1));
                        hfOpenBtnStatus.Text = iOpenBtnStatus.ToString();
                        hfOpenBtnStatus.Hidden = true;
                        arrItems2[7] = hfOpenBtnStatus;

                        UILabel hfUploadBtnStatus = new UILabel();
                        hfUploadBtnStatus.Tag = (iUploadBtnStatusTagId * (i+1));
                        hfUploadBtnStatus.Text = iUploadBtnStatus.ToString();
                        hfUploadBtnStatus.Hidden = true;
                        arrItems2[8] = hfUploadBtnStatus;

                        UILabel hfRemoveBtnStatus = new UILabel();
                        hfRemoveBtnStatus.Tag = (iRemoveBtnStatusTagId * (i+1));
                        hfRemoveBtnStatus.Text = iRemoveBtnStatus.ToString();
                        hfRemoveBtnStatus.Hidden = true;
                        arrItems2[9] = hfRemoveBtnStatus;

                        layout.AddSubviews(arrItems2);

                    }
                }

                //And reduce the content size of the main scroll view by the same amount
                SizeF layoutSize = new SizeF(1000f, iTotalHeight);
                layout.ContentSize = layoutSize;

            }
            catch (Exception except)
            {
                iUtils.AlertBox alert = new iUtils.AlertBox();
                alert.CreateErrorAlertDialog(except.Message);
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            MainView = new UIView();

            scrollView = new UIScrollView();

            imageView = new UIImageView();
            imageView.BackgroundColor = UIColor.Black;

            textView = new UITextView();
            textView.Editable = false;
            textView.BackgroundColor = UIColor.Black;
            textView.TextColor = UIColor.White;

            scrollView.AddSubviews(new UIView[] { imageView, textView });

            this.View.AddSubview(scrollView);
        }