void ReleaseDesignerOutlets()
 {
     if (ScrollView != null) {
         ScrollView.Dispose ();
         ScrollView = null;
     }
     if (stackView != null) {
         stackView.Dispose ();
         stackView = null;
     }
 }
        public ScrollingTabView(List<UIViewController> viewControllers)
        {
            //Create views
            tabbarBackground = new UIView();
            selectedTabUnderlineView = new UIStackView();
            contentScrollView = new UIScrollView();

            ViewControllers = viewControllers;
            DefaultColors();

            CurrentIndex = 0;
            TabItemSelected += HandleTabItemSelected;
        }
 void ReleaseDesignerOutlets()
 {
     if (peopleStackView != null) {
         peopleStackView.Dispose ();
         peopleStackView = null;
     }
     if (distributionSegmentControl != null) {
         distributionSegmentControl.Dispose ();
         distributionSegmentControl = null;
     }
     if (alignmentSegmentControl != null) {
         alignmentSegmentControl.Dispose ();
         alignmentSegmentControl = null;
     }
 }
        public UIView CreateView()
        {
            var screenWidth = UIScreen.MainScreen.Bounds.Width;

            UserInteractionEnabled = true;

            #region topPanel

            topView = new UIView();
            topView.BackgroundColor = UIColor.Clear;
            topView.Frame           = new CGRect(mainMargin - 5, mainMargin, screenWidth - mainMargin * 2, topViewHeight);

            avatar = new UIImageView(new CGRect(5, 5, photoSide, photoSide));
            avatar.Layer.CornerRadius     = photoSide / 2;
            avatar.ClipsToBounds          = true;
            avatar.UserInteractionEnabled = true;
            avatar.ContentMode            = UIViewContentMode.ScaleAspectFill;
            avatar.BackgroundColor        = UIColor.Clear;
            powerFrame = new CircleFrame(avatar, new CGRect(0, 0, powerFrameSide, powerFrameSide));

            infoView              = new UIStackView();
            infoView.Axis         = UILayoutConstraintAxis.Vertical;
            infoView.Alignment    = UIStackViewAlignment.Fill;
            infoView.Distribution = UIStackViewDistribution.FillEqually;
            infoView.Frame        = new CGRect(powerFrameSide + topViewSpacing, 0, screenWidth - mainMargin * 2 - (powerFrameSide + topViewSpacing), topViewHeight + 8);

            userName = new UILabel();
            userName.UserInteractionEnabled = false;
            userName.TextColor       = Helpers.Constants.R15G24B30;
            userName.Font            = Helpers.Constants.Semibold20;
            userName.Lines           = 1;
            userName.LineBreakMode   = UILineBreakMode.TailTruncation;
            userName.BackgroundColor = UIColor.Clear;

            userLocation = new UILabel();
            userLocation.UserInteractionEnabled = false;
            userLocation.TextColor       = Helpers.Constants.R151G155B158;
            userLocation.Font            = Helpers.Constants.Regular14;
            userLocation.Lines           = 1;
            userLocation.LineBreakMode   = UILineBreakMode.TailTruncation;
            userLocation.BackgroundColor = UIColor.Clear;

            var topEmptyView    = new UIView();
            var bottomEmptyView = new UIView();

            infoView.AddArrangedSubview(topEmptyView);
            infoView.AddArrangedSubview(userName);
            infoView.AddArrangedSubview(userLocation);
            infoView.AddArrangedSubview(bottomEmptyView);

            topView.AddSubview(powerFrame);
            topView.AddSubview(infoView);
            AddSubview(topView);

            #endregion

            attributedLabel       = new TTTAttributedLabel();
            attributedLabel.Lines = 0;
            attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;

            var prop = new NSDictionary();
            attributedLabel.LinkAttributes       = prop;
            attributedLabel.ActiveLinkAttributes = prop;

            attributedLabel.Delegate = new TTTAttributedLabelCustomDelegate();

            at = new NSMutableAttributedString();

            followButton = new UIButton();
            followButton.BackgroundColor = UIColor.Clear;
            AddSubview(followButton);

            followProgress = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.Gray);
            followProgress.HidesWhenStopped = false;
            followProgress.StartAnimating();
            AddSubview(followProgress);

            #region originality

            originalityContainer = new UIView();
            originalityContainer.BackgroundColor    = Helpers.Constants.R250G250B250;
            originalityContainer.Layer.CornerRadius = 10;

            originalityLabel = new UILabel();
            originalityLabel.UserInteractionEnabled = false;
            //originalityLabel.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Originality);
            originalityLabel.TextColor     = UIColor.Black;
            originalityLabel.Font          = Helpers.Constants.Regular14;
            originalityLabel.Lines         = 1;
            originalityLabel.LineBreakMode = UILineBreakMode.TailTruncation;

            originality = new UILabel();
            originality.UserInteractionEnabled = false;
            originality.Text      = "100%";
            originality.TextColor = Helpers.Constants.R255G34B5;
            originality.Font      = Helpers.Constants.Semibold14;
            originality.Lines     = 1;

            originalityContainer.AddSubview(originalityLabel);
            originalityContainer.AddSubview(originality);

            //contentView.AddSubview(originalityContainer);

            #endregion

            #region stats

            statsView              = new UIStackView();
            statsView.Axis         = UILayoutConstraintAxis.Horizontal;
            statsView.Alignment    = UIStackViewAlignment.Fill;
            statsView.Distribution = UIStackViewDistribution.Fill;
            statsView.TranslatesAutoresizingMaskIntoConstraints = false;

            photos    = new UIButton();
            following = new UIButton();
            followers = new UIButton();

            var emptySpace = new UIView();

            var firstSpacing  = new UIView();
            var secondSpacing = new UIView();

            statsView.AddArrangedSubview(photos);
            statsView.AddArrangedSubview(firstSpacing);
            statsView.AddArrangedSubview(following);
            statsView.AddArrangedSubview(secondSpacing);
            statsView.AddArrangedSubview(followers);
            statsView.AddArrangedSubview(emptySpace);

            statsContainer = new UIView();
            statsContainer.AddSubview(statsView);

            AddSubview(statsContainer);

            #endregion

            #region balance

            balanceContainer = new UIView();
            balanceContainer.UserInteractionEnabled = true;

            var topSeparator    = new UIView();
            var bottomSeparator = new UIView();
            topSeparator.BackgroundColor = bottomSeparator.BackgroundColor = Helpers.Constants.R245G245B245;

            var balanceImage = new UIImageView();
            balanceImage.Image = UIImage.FromBundle("ic_balance");

            var balanceLabel = new UILabel();
            balanceLabel.UserInteractionEnabled = false;
            balanceLabel.Text      = AppSettings.LocalizationManager.GetText(LocalizationKeys.AccountBalance);
            balanceLabel.TextColor = UIColor.Black;
            balanceLabel.Font      = Helpers.Constants.Regular14;
            balanceLabel.Lines     = 1;

            balance = new UILabel();
            balance.UserInteractionEnabled = false;
            balance.TextColor     = Helpers.Constants.R255G34B5;
            balance.TextAlignment = UITextAlignment.Right;
            balance.Font          = Helpers.Constants.Semibold14;
            balance.Lines         = 1;

            var balanceArrow = new UIImageView();
            balanceArrow.Image = UIImage.FromBundle("ic_forward");

            balanceContainer.AddSubview(topSeparator);
            balanceContainer.AddSubview(bottomSeparator);
            balanceContainer.AddSubview(balanceImage);
            balanceContainer.AddSubview(balanceLabel);
            balanceContainer.AddSubview(balanceArrow);
            balanceContainer.AddSubview(balance);

            UITapGestureRecognizer balanceTap = new UITapGestureRecognizer(() =>
            {
                ProfileAction?.Invoke(ActionType.Balance);
            });
            balanceContainer.AddGestureRecognizer(balanceTap);
//#if DEBUG
            AddSubview(balanceContainer);
//#endif
            #endregion

            AddSubview(bottomSeparator);

            #region constraints

            /*
             * originalityLabel.AutoPinEdgeToSuperviewEdge(ALEdge.Left, extraMargin);
             * originalityLabel.AutoAlignAxis(ALAxis.Horizontal, originalityContainer);
             * originality.AutoPinEdgeToSuperviewEdge(ALEdge.Right, extraMargin);
             * originality.AutoAlignAxis(ALAxis.Horizontal, originalityContainer);
             */

            statsView.AutoPinEdgesToSuperviewEdges();

            topSeparator.AutoSetDimension(ALDimension.Height, 1);
            topSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Top);
            topSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            topSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Right);

            bottomSeparator.AutoSetDimension(ALDimension.Height, 1);
            bottomSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Left);
            bottomSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Right);
            bottomSeparator.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom);

            followProgress.AutoAlignAxis(ALAxis.Horizontal, followButton);
            followProgress.AutoAlignAxis(ALAxis.Vertical, followButton);
//#if DEBUG
            balanceImage.AutoSetDimensionsToSize(new CGSize(10, 10));
            balanceImage.AutoPinEdgeToSuperviewEdge(ALEdge.Left, mainMargin);
            balanceImage.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            balanceLabel.AutoPinEdge(ALEdge.Left, ALEdge.Right, balanceImage, 20);
            balanceLabel.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            balanceArrow.AutoSetDimensionsToSize(new CGSize(6, 10));
            balanceArrow.AutoPinEdgeToSuperviewEdge(ALEdge.Right, mainMargin);
            balanceArrow.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
            balance.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 55);
            balance.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal);
//#endif
            firstSpacing.AutoSetDimension(ALDimension.Width, 48);
            secondSpacing.AutoSetDimension(ALDimension.Width, 48);

            #endregion

            return(this);
        }
        public override void LoadView()
        {
            // Create the views.
            View = new UIView {
                BackgroundColor = UIColor.White
            };

            _myMapView = new MapView();
            _myMapView.TranslatesAutoresizingMaskIntoConstraints = false;

            UILabel helpLabel = new UILabel
            {
                Text                      = "Tap the map to create planar and geodesic buffers.",
                TextAlignment             = UITextAlignment.Center,
                AdjustsFontSizeToFitWidth = true,
                Lines                     = 1,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            UIView formArea = new UIView {
                BackgroundColor = UIColor.White
            };

            formArea.TranslatesAutoresizingMaskIntoConstraints = false;

            UILabel bufferInputLabel = new UILabel
            {
                Text          = "Distance (miles):",
                TextAlignment = UITextAlignment.Right,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _bufferDistanceMilesTextField = new UITextField
            {
                BackgroundColor = UIColor.LightGray,
                KeyboardType    = UIKeyboardType.NumberPad,
                Text            = "1000",
                TextAlignment   = UITextAlignment.Right,
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _bufferDistanceMilesTextField.Layer.CornerRadius = 5;

            // Add padding within the field.
            _bufferDistanceMilesTextField.RightView     = new UIView(new CGRect(0, 0, 5, 20)); // 5 is amount of left padding.
            _bufferDistanceMilesTextField.RightViewMode = UITextFieldViewMode.Always;

            UIStackView legendView = new UIStackView();

            legendView.TranslatesAutoresizingMaskIntoConstraints = false;
            legendView.Axis      = UILayoutConstraintAxis.Horizontal;
            legendView.Alignment = UIStackViewAlignment.Center;
            legendView.Spacing   = 8;

            _geodesicSwatchSwatch = new UIView();
            _geodesicSwatchSwatch.TranslatesAutoresizingMaskIntoConstraints = false;
            _geodesicSwatchSwatch.BackgroundColor = UIColor.Red;
            _geodesicSwatchSwatch.WidthAnchor.ConstraintEqualTo(16).Active  = true;
            _geodesicSwatchSwatch.HeightAnchor.ConstraintEqualTo(16).Active = true;
            _geodesicSwatchSwatch.ClipsToBounds      = true;
            _geodesicSwatchSwatch.Layer.CornerRadius = 8;
            legendView.AddArrangedSubview(_geodesicSwatchSwatch);

            UILabel geodesicSwatchLabel = new UILabel
            {
                Text      = "Geodesic buffers",
                TextColor = UIColor.Red,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            legendView.AddArrangedSubview(geodesicSwatchLabel);

            UIView spacer = new UIView();

            spacer.TranslatesAutoresizingMaskIntoConstraints = false;
            spacer.SetContentCompressionResistancePriority((float)UILayoutPriority.DefaultLow, UILayoutConstraintAxis.Horizontal);
            legendView.AddArrangedSubview(spacer);

            _planarSwatchSwatch = new UIView();
            _planarSwatchSwatch.BackgroundColor = UIColor.Blue;
            _planarSwatchSwatch.TranslatesAutoresizingMaskIntoConstraints = false;
            _planarSwatchSwatch.WidthAnchor.ConstraintEqualTo(16).Active  = true;
            _planarSwatchSwatch.HeightAnchor.ConstraintEqualTo(16).Active = true;
            _planarSwatchSwatch.ClipsToBounds      = true;
            _planarSwatchSwatch.Layer.CornerRadius = 8;
            legendView.AddArrangedSubview(_planarSwatchSwatch);

            UILabel planarSwatchLabel = new UILabel
            {
                Text      = "Planar buffers",
                TextColor = UIColor.Blue,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            legendView.AddArrangedSubview(planarSwatchLabel);

            _clearBuffersButton = new UIButton
            {
                ClipsToBounds   = true,
                BackgroundColor = View.TintColor
            };
            _clearBuffersButton.SetTitle("Clear", UIControlState.Normal);
            _clearBuffersButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            _clearBuffersButton.Layer.CornerRadius = 5;
            _clearBuffersButton.TranslatesAutoresizingMaskIntoConstraints = false;

            // Add the views.
            View.AddSubviews(_myMapView,
                             formArea,
                             helpLabel,
                             bufferInputLabel,
                             _bufferDistanceMilesTextField,
                             legendView,
                             _clearBuffersButton);

            // Lay out the views.
            // TODO: consider replacing with UIStackView-based layout.
            nfloat margin        = 8;
            nfloat controlHeight = 4 * margin;

            NSLayoutConstraint.ActivateConstraints(new[]
            {
                formArea.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                formArea.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                formArea.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                formArea.HeightAnchor.ConstraintEqualTo((3 * margin) + (2 * controlHeight)),

                legendView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor, 8),
                legendView.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor, -8),
                legendView.TopAnchor.ConstraintEqualTo(formArea.BottomAnchor),
                legendView.HeightAnchor.ConstraintEqualTo(24),

                _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _myMapView.TopAnchor.ConstraintEqualTo(legendView.BottomAnchor),
                _myMapView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor),

                helpLabel.TopAnchor.ConstraintEqualTo(formArea.TopAnchor, margin),
                helpLabel.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor),
                helpLabel.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor),
                helpLabel.HeightAnchor.ConstraintEqualTo(controlHeight),

                bufferInputLabel.TopAnchor.ConstraintEqualTo(helpLabel.BottomAnchor, margin),
                bufferInputLabel.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor, margin),
                bufferInputLabel.TrailingAnchor.ConstraintEqualTo(formArea.CenterXAnchor, -margin),
                bufferInputLabel.HeightAnchor.ConstraintEqualTo(controlHeight),

                _bufferDistanceMilesTextField.TopAnchor.ConstraintEqualTo(bufferInputLabel.TopAnchor),
                _bufferDistanceMilesTextField.LeadingAnchor.ConstraintEqualTo(formArea.CenterXAnchor, margin),
                _bufferDistanceMilesTextField.TrailingAnchor.ConstraintEqualTo(_clearBuffersButton.LeadingAnchor, -margin),
                _bufferDistanceMilesTextField.HeightAnchor.ConstraintEqualTo(controlHeight),

                _clearBuffersButton.TopAnchor.ConstraintEqualTo(_bufferDistanceMilesTextField.TopAnchor),
                _clearBuffersButton.WidthAnchor.ConstraintEqualTo(100),
                _clearBuffersButton.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor, -margin),
                _clearBuffersButton.HeightAnchor.ConstraintEqualTo(controlHeight)
            });
        }
Exemplo n.º 6
0
        public override void LoadView()
        {
            // Create the UI for the symbol selection.
            View = new UIView {
                BackgroundColor = UIColor.White
            };

            // A vertical stack view to contain all the controls.
            _outerStackView = new UIStackView
            {
                Axis = UILayoutConstraintAxis.Vertical,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing      = 2,
                Distribution = UIStackViewDistribution.EqualSpacing,
                Alignment    = UIStackViewAlignment.Center
            };

            // A vertical stack view to contain the symbol layer picker.
            UIStackView pickersView = new UIStackView
            {
                Axis = UILayoutConstraintAxis.Vertical,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Distribution = UIStackViewDistribution.EqualSpacing,
                Alignment    = UIStackViewAlignment.Top
            };

            // Add the symbol layer picker to the stack view.
            pickersView.AddArrangedSubview(_symbolLayersPicker);

            // Add the picker stack view to the outer stack view.
            _outerStackView.AddArrangedSubview(pickersView);

            // Create a label to show the size of the symbol (specified with the slider).
            UILabel sizeLabel = new UILabel
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Text = $"Size: {_sizeSlider.Value:0}"
            };

            // Handle the slider value changed event to update the label with the specified size.
            _sizeSlider.ValueChanged += async(sender, e) =>
            {
                sizeLabel.Text = $"Size: {_sizeSlider.Value:0}";
                await UpdateSymbol();
            };

            _sizeSlider.TranslatesAutoresizingMaskIntoConstraints = false;

            // Create a vertical stack view to contain the color segmented control, size slider, and size label.
            UIStackView colorSizeStack = new UIStackView(new UIView[] { _colorSegments, _sizeSlider, sizeLabel })
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis         = UILayoutConstraintAxis.Vertical,
                Alignment    = UIStackViewAlignment.Center,
                Distribution = UIStackViewDistribution.Fill
            };

            // Add the color and size stack view to the outer stack view.
            _outerStackView.AddArrangedSubview(colorSizeStack);

            // Add the preview image view to the outer stack view.
            _outerStackView.AddArrangedSubview(_symbolPreviewImageView);

            // Add the outer stack view to the main view.
            View.AddSubview(_outerStackView);

            // Set constraints on the outer stack view.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                _outerStackView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor, 8),
                _outerStackView.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor, -8),
                _outerStackView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor, 8),
                _outerStackView.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor, -8),
                _sizeSlider.LeftAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeftAnchor, 20),
                _sizeSlider.RightAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.RightAnchor, -20)
            });
        }
Exemplo n.º 7
0
        private void InitializeViews()
        {
            base.TranslatesAutoresizingMaskIntoConstraints = false;
            base.BackgroundColor = new UIColor(247f / 255f, 1);

            // [ [labelName] [labelDates] ]
            // [ [class] [credits] [gpa]  ]
            // [ stackViewClasses         ]
            // [ buttonOpenSemester       ]

            // stackView
            // + viewNameAndDates
            //   + labelName
            //   + labelDates
            // + stackViewClassesTable
            //   + viewClassesTableHeader
            //     + labelHeaderClass
            //     + labelHeaderCredits
            //     + labelHeaderGpa
            //   + stackViewClasses
            //   + viewClassesTableFooter
            //     + labelTotal
            //     + labelTotalCredits
            //     + labelTotalGpa
            // + buttonAddSemester

            var stackView = new UIStackView()
            {
                Axis = UILayoutConstraintAxis.Vertical,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 8
            };

            // Name and dates
            var viewNameAndDates = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            viewNameAndDates.TouchUpInside += new WeakEventHandler(delegate { OnRequestEditSemester?.Invoke(this, DataContext as ViewItemSemester); }).Handler;
            {
                var labelName = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                BindingHost.SetLabelTextBinding(labelName, nameof(ViewItemSemester.Name));
                viewNameAndDates.AddSubview(labelName);

                var labelDates = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Font          = UIFont.PreferredCaption2,
                    TextColor     = UIColor.DarkGray,
                    Lines         = 0,
                    TextAlignment = UITextAlignment.Right
                };
                BindingHost.SetLabelTextBinding(labelDates, nameof(ViewItemSemester.Start), delegate
                {
                    return(SemesterToSemesterViewStartEndStringConverter.Convert(DataContext as ViewItemSemester));
                });
                viewNameAndDates.AddSubview(labelDates);

                viewNameAndDates.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelName]->=6-[labelDates]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                        "labelName", labelName,
                                                                                        "labelDates", labelDates)));
                labelName.StretchHeight(viewNameAndDates);
                labelDates.StretchHeight(viewNameAndDates);
            }
            stackView.AddArrangedSubview(viewNameAndDates);
            viewNameAndDates.StretchWidth(stackView);

            // Table
            var classesTouchContainer = new UIControl()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            classesTouchContainer.TouchUpInside += new WeakEventHandler(delegate { OnRequestOpenSemester?.Invoke(this, DataContext as ViewItemSemester); }).Handler;
            {
                var stackViewClassesTable = new UIStackView()
                {
                    Axis = UILayoutConstraintAxis.Vertical,
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    // Table header
                    var viewClassesTableHeader = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        var labelHeaderClass = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Text      = "Class",
                            Font      = UIFont.PreferredCaption2,
                            TextColor = UIColor.DarkGray
                        };
                        viewClassesTableHeader.AddSubview(labelHeaderClass);

                        var labelHeaderCredits = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Font          = UIFont.PreferredCaption2,
                            Text          = "Credits",
                            TextColor     = UIColor.DarkGray,
                            TextAlignment = UITextAlignment.Right
                        };
                        viewClassesTableHeader.AddSubview(labelHeaderCredits);

                        var labelHeaderGpa = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Font          = UIFont.PreferredCaption2,
                            Text          = "GPA",
                            TextColor     = UIColor.DarkGray,
                            TextAlignment = UITextAlignment.Right
                        };
                        viewClassesTableHeader.AddSubview(labelHeaderGpa);

                        viewClassesTableHeader.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelHeaderClass]->=6-[labelHeaderCredits(50)]-6-[labelHeaderGpa(50)]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                                      "labelHeaderClass", labelHeaderClass,
                                                                                                      "labelHeaderCredits", labelHeaderCredits,
                                                                                                      "labelHeaderGpa", labelHeaderGpa)));
                        labelHeaderClass.StretchHeight(viewClassesTableHeader);
                        labelHeaderCredits.StretchHeight(viewClassesTableHeader);
                        labelHeaderGpa.StretchHeight(viewClassesTableHeader);
                    }
                    stackViewClassesTable.AddArrangedSubview(viewClassesTableHeader);
                    viewClassesTableHeader.StretchWidth(stackViewClassesTable);

                    // Classes stack view
                    var stackViewClasses = new UIStackView()
                    {
                        Axis = UILayoutConstraintAxis.Vertical,
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    _itemsSourceClasses = new BareUIStackViewItemsSourceAdapter <UIClassView>(stackViewClasses);
                    stackViewClassesTable.AddArrangedSubview(stackViewClasses);
                    stackViewClasses.StretchWidth(stackViewClassesTable);

                    // Totals
                    var viewClassesTableFooter = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        var labelTotal = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            Text = "Total",
                            Font = UIFont.PreferredFootnote
                        };
                        viewClassesTableFooter.AddSubview(labelTotal);

                        var labelTotalCredits = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            TextAlignment = UITextAlignment.Right,
                            Font          = UIFont.PreferredFootnote
                        };
                        BindingHost.SetLabelTextBinding <double>(labelTotalCredits, nameof(ViewItemSemester.CreditsEarned), (credits) =>
                        {
                            return(CreditsToStringConverter.Convert(credits));
                        });
                        viewClassesTableFooter.AddSubview(labelTotalCredits);

                        var labelTotalGpa = new UILabel()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            TextAlignment = UITextAlignment.Right,
                            Font          = UIFont.PreferredFootnote
                        };
                        BindingHost.SetLabelTextBinding <double>(labelTotalGpa, nameof(ViewItemSemester.GPA), (gpa) =>
                        {
                            return(GpaToStringConverter.Convert(gpa));
                        });
                        viewClassesTableFooter.AddSubview(labelTotalGpa);

                        viewClassesTableFooter.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[labelTotal]->=6-[labelTotalCredits(50)]-6-[labelTotalGpa(50)]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                                      "labelTotal", labelTotal,
                                                                                                      "labelTotalCredits", labelTotalCredits,
                                                                                                      "labelTotalGpa", labelTotalGpa)));
                        labelTotal.StretchHeight(viewClassesTableFooter);
                        labelTotalCredits.StretchHeight(viewClassesTableFooter);
                        labelTotalGpa.StretchHeight(viewClassesTableFooter);
                    }
                    stackViewClassesTable.AddArrangedSubview(viewClassesTableFooter);
                    viewClassesTableFooter.StretchWidth(stackViewClassesTable);
                }
                classesTouchContainer.Add(stackViewClassesTable);
                stackViewClassesTable.StretchWidthAndHeight(classesTouchContainer);
            }
            stackView.AddArrangedSubview(classesTouchContainer);
            classesTouchContainer.StretchWidth(stackView);

            // Add semester button
            var buttonOpenSemester = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            buttonOpenSemester.SetTitle("Open Semester", UIControlState.Normal);
            buttonOpenSemester.TouchUpInside += new WeakEventHandler(ButtonOpenSemester_TouchUpInside).Handler;
            stackView.AddArrangedSubview(buttonOpenSemester);
            buttonOpenSemester.StretchWidth(stackView);

            base.AddSubview(stackView);
            stackView.StretchWidthAndHeight(this, top: 6, bottom: 6, left: 8, right: 8);
        }
Exemplo n.º 8
0
        public override void LoadView()
        {
            // Create the views.
            View = new UIView();

            UIScrollView scrollView = new UIScrollView();

            scrollView.TranslatesAutoresizingMaskIntoConstraints = false;

            View.AddSubviews(scrollView);

            scrollView.TopAnchor.ConstraintEqualTo(View.TopAnchor).Active           = true;
            scrollView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active   = true;
            scrollView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true;
            scrollView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor).Active     = true;

            UIStackView formContainer = new UIStackView();

            formContainer.TranslatesAutoresizingMaskIntoConstraints = false;
            formContainer.Spacing = 8;
            formContainer.LayoutMarginsRelativeArrangement = true;
            formContainer.Alignment     = UIStackViewAlignment.Fill;
            formContainer.LayoutMargins = new UIEdgeInsets(8, 8, 8, 8);
            formContainer.Axis          = UILayoutConstraintAxis.Vertical;
            formContainer.WidthAnchor.ConstraintEqualTo(320).Active = true;

            // Form controls here.
            UILabel slopeTypesLabel = new UILabel();

            slopeTypesLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            slopeTypesLabel.Text = "Slope type:";
            formContainer.AddArrangedSubview(slopeTypesLabel);

            _slopeTypesPicker = new UISegmentedControl(Enum.GetNames(typeof(SlopeType)));
            _slopeTypesPicker.TranslatesAutoresizingMaskIntoConstraints = false;
            _slopeTypesPicker.SelectedSegment = 0;
            formContainer.AddArrangedSubview(_slopeTypesPicker);

            UILabel colorRampsLabel = new UILabel();

            colorRampsLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            colorRampsLabel.Text = "Color ramp:";
            formContainer.AddArrangedSubview(colorRampsLabel);

            _colorRampsPicker = new UISegmentedControl(Enum.GetNames(typeof(PresetColorRampType)));
            _colorRampsPicker.TranslatesAutoresizingMaskIntoConstraints = false;
            _colorRampsPicker.SelectedSegment = 0;
            formContainer.AddArrangedSubview(_colorRampsPicker);

            UILabel altitudeLabel = new UILabel();

            altitudeLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            altitudeLabel.Text = "Altitude:";
            formContainer.AddArrangedSubview(altitudeLabel);

            _altitudeSlider = new UISlider();
            _altitudeSlider.TranslatesAutoresizingMaskIntoConstraints = false;
            _altitudeSlider.MinValue = 0;
            _altitudeSlider.MaxValue = 90;
            _altitudeSlider.Value    = 45;
            formContainer.AddArrangedSubview(_altitudeSlider);

            UILabel azimuthLabel = new UILabel();

            azimuthLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            azimuthLabel.Text = "Azimuth:";
            formContainer.AddArrangedSubview(azimuthLabel);

            _azimuthSlider = new UISlider();
            _azimuthSlider.TranslatesAutoresizingMaskIntoConstraints = false;
            _azimuthSlider.MinValue = 0;
            _azimuthSlider.MaxValue = 360;
            _azimuthSlider.Value    = 180;
            formContainer.AddArrangedSubview(_azimuthSlider);

            // Add the views.
            scrollView.AddSubview(formContainer);

            // Put the apply button in the top-right part of the popover.
            NavigationItem.RightBarButtonItem = new UIBarButtonItem("Apply", UIBarButtonItemStyle.Plain, UpdateRendererButton_Clicked);

            // Lay out the views.
            formContainer.TopAnchor.ConstraintEqualTo(scrollView.TopAnchor).Active           = true;
            formContainer.LeadingAnchor.ConstraintEqualTo(scrollView.LeadingAnchor).Active   = true;
            formContainer.TrailingAnchor.ConstraintEqualTo(scrollView.TrailingAnchor).Active = true;
            formContainer.BottomAnchor.ConstraintEqualTo(scrollView.BottomAnchor).Active     = true;

            // Disable horizontal scrolling.
            formContainer.WidthAnchor.ConstraintEqualTo(scrollView.WidthAnchor).Active = true;
        }
        private void Initialize()
        {
            BackgroundColor = UIColor.Clear;

            // At run-time, don't display the sub-views until their dimensions have been calculated
            if (!DesignTime.IsDesignMode)
            {
                Hidden = true;
            }

            // Vertically-oriented stack view for containing all scalebar components
            _rootStackView = new UIStackView()
            {
                Axis         = UILayoutConstraintAxis.Vertical,
                Alignment    = UIStackViewAlignment.Leading,
                Distribution = UIStackViewDistribution.Fill,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 0
            };

            // Initialize scalebar components with placeholder sizes and values
            var font = UIFont.SystemFontOfSize(11);

            _combinedScaleLine = new RectangleView(200, 2)
            {
                BackgroundColor = ForegroundColor
            };
            _metricScaleLine = new RectangleView(200, 2);
            _metricValue     = new UILabel()
            {
                Text = "100", Font = font
            };
            _metricUnit = new UILabel()
            {
                Text = "m", Font = font
            };
            _usScaleLine = new RectangleView(_metricScaleLine.Width * .9144, 2);
            _usValue     = new UILabel()
            {
                Text = "300", Font = font
            };
            _usUnit = new UILabel()
            {
                Text = "ft", Font = font
            };

            // Listen for width updates on metric and imperial scale lines to update the combined scale line
            _metricScaleLine.PropertyChanged += ScaleLine_PropertyChanged;
            _usScaleLine.PropertyChanged     += ScaleLine_PropertyChanged;

            // ===============================================================
            // First row - placeholder, numeric text, and units text
            // ===============================================================
            var firstRowStackView = new UIStackView()
            {
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Leading,
                Distribution = UIStackViewDistribution.Fill,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 0
            };

            firstRowStackView.AddArrangedSubview(_metricScaleLine);
            firstRowStackView.AddArrangedSubview(_metricValue);
            firstRowStackView.AddArrangedSubview(_metricUnit);

            // ================================================================================
            // Second row - first metric tick line, placeholder, and second metric tick line
            // ================================================================================
            var secondRowStackView = new UIStackView()
            {
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Leading,
                Distribution = UIStackViewDistribution.Fill,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 0
            };

            var tickWidth  = 2;
            var tickHeight = 5;

            _firstMetricTickLine = new RectangleView(tickWidth, tickHeight)
            {
                BackgroundColor = ForegroundColor
            };

            var metricWidthPlaceholder = new UIView();

            _secondMetricTickLine = new RectangleView(tickWidth, tickHeight)
            {
                BackgroundColor = ForegroundColor
            };

            secondRowStackView.AddArrangedSubview(_firstMetricTickLine);
            secondRowStackView.AddArrangedSubview(metricWidthPlaceholder);
            secondRowStackView.AddArrangedSubview(_secondMetricTickLine);

            // ==============================================================================================
            // Third row - filler segment at start of scale line, metric scale line, imperial scale line
            // ==============================================================================================
            var thirdRowStackView = new UIStackView()
            {
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Leading,
                Distribution = UIStackViewDistribution.Fill,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 0
            };

            _scaleLineStartSegment = new RectangleView(4, 2)
            {
                BackgroundColor = ForegroundColor
            };

            thirdRowStackView.AddArrangedSubview(_scaleLineStartSegment);
            thirdRowStackView.AddArrangedSubview(_combinedScaleLine);

            // ==============================================================================================
            // Fourth row - first imperial tick line, placeholder, second imperial tick line
            // ==============================================================================================
            var fourthRowStackView = new UIStackView()
            {
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Leading,
                Distribution = UIStackViewDistribution.Fill,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 0
            };

            _firstUsTickLine = new RectangleView(tickWidth, tickHeight)
            {
                BackgroundColor = ForegroundColor
            };
            _secondUsTickLine = new RectangleView(tickWidth, tickHeight)
            {
                BackgroundColor = ForegroundColor
            };

            fourthRowStackView.AddArrangedSubview(_firstUsTickLine);
            fourthRowStackView.AddArrangedSubview(_usScaleLine);
            fourthRowStackView.AddArrangedSubview(_secondUsTickLine);

            // ==========================================================================
            // Fifth row - placeholder, imperial numeric text, imperial unit text
            // ==========================================================================
            var fifthRowStackView = new UIStackView()
            {
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Leading,
                Distribution = UIStackViewDistribution.Fill,
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 0
            };

            var usWidthPlaceholder = new UIView();

            fifthRowStackView.AddArrangedSubview(usWidthPlaceholder);
            fifthRowStackView.AddArrangedSubview(_usValue);
            fifthRowStackView.AddArrangedSubview(_usUnit);

            // Add all scalebar rows to the root stack view
            _rootStackView.AddArrangedSubview(firstRowStackView);
            _rootStackView.AddArrangedSubview(secondRowStackView);
            _rootStackView.AddArrangedSubview(thirdRowStackView);
            _rootStackView.AddArrangedSubview(fourthRowStackView);
            _rootStackView.AddArrangedSubview(fifthRowStackView);

            AddSubview(_rootStackView);

            // Anchor the root stack view to the bottom left of the view
            _rootStackView.LeadingAnchor.ConstraintEqualTo(LeadingAnchor).Active = true;
            _rootStackView.BottomAnchor.ConstraintEqualTo(BottomAnchor).Active   = true;

            // Set up constraints to resize scalebar components when scale line resizes
            metricWidthPlaceholder.WidthAnchor.ConstraintEqualTo(_metricScaleLine.WidthAnchor).Active       = true;
            metricWidthPlaceholder.HeightAnchor.ConstraintEqualTo(_firstMetricTickLine.HeightAnchor).Active = true;
            usWidthPlaceholder.WidthAnchor.ConstraintEqualTo(_usScaleLine.WidthAnchor).Active = true;
            usWidthPlaceholder.HeightAnchor.ConstraintEqualTo(_usValue.HeightAnchor).Active   = true;

            InvalidateIntrinsicContentSize();
        }
Exemplo n.º 10
0
        void Sample13()
        {
            _parentView = new UIView();

            _container = new UIStackView {
                Axis         = UILayoutConstraintAxis.Horizontal,   //並べる方向
                Alignment    = UIStackViewAlignment.Fill,           //垂直位置属性
                Distribution = UIStackViewDistribution.FillEqually, //余白分配設定 均等
                Spacing      = 6                                    //要素間のマージン
            };

            _container.AddArrangedSubview(_label1);
            _container.AddArrangedSubview(_label2);
            _container.AddArrangedSubview(_label3);

            //親Viewにサイズぴったりにする
            _parentView.AddSubview(_container);
            _container.TranslatesAutoresizingMaskIntoConstraints = false;
            _container.TopAnchor.ConstraintEqualTo(_parentView.TopAnchor, 0).Active       = true;
            _container.LeftAnchor.ConstraintEqualTo(_parentView.LeftAnchor, 0).Active     = true;
            _container.BottomAnchor.ConstraintEqualTo(_parentView.BottomAnchor, 0).Active = true;
            _container.RightAnchor.ConstraintEqualTo(_parentView.RightAnchor, 0).Active   = true;


            var label4 = new UILabel {
                Text = "Four", BackgroundColor = UIColor.FromRGBA(0, 0, 0, 125), TextColor = UIColor.White
            };

            _parentView.AddSubview(label4);

            //左上から6,6の位置に置く
            label4.TranslatesAutoresizingMaskIntoConstraints = false;
            label4.TopAnchor.ConstraintEqualTo(_parentView.TopAnchor, 6).Active   = true;
            label4.LeftAnchor.ConstraintEqualTo(_parentView.LeftAnchor, 6).Active = true;

            var label5 = new UILabel {
                Text = "Five", BackgroundColor = UIColor.FromRGBA(0, 0, 0, 125), TextColor = UIColor.White
            };

            _parentView.AddSubview(label5);

            //右上から6,6の位置に置く(RightとBottomから内側へのマージンはマイナス指定)
            label5.TranslatesAutoresizingMaskIntoConstraints = false;
            label5.TopAnchor.ConstraintEqualTo(_parentView.TopAnchor, 6).Active      = true;
            label5.RightAnchor.ConstraintEqualTo(_parentView.RightAnchor, -6).Active = true;

            var label6 = new UILabel {
                Text = "Six", BackgroundColor = UIColor.FromRGBA(0, 0, 0, 125), TextColor = UIColor.White
            };

            _parentView.AddSubview(label6);

            //右下から6,6の位置に置く
            label6.TranslatesAutoresizingMaskIntoConstraints = false;
            label6.RightAnchor.ConstraintEqualTo(_parentView.RightAnchor, -6).Active   = true;
            label6.BottomAnchor.ConstraintEqualTo(_parentView.BottomAnchor, -6).Active = true;

            var label7 = new UILabel {
                Text = "Seven", BackgroundColor = UIColor.FromRGBA(0, 0, 0, 125), TextColor = UIColor.White
            };

            _parentView.AddSubview(label7);

            //左下から6,6,の位置に置く
            label7.TranslatesAutoresizingMaskIntoConstraints = false;
            label7.LeftAnchor.ConstraintEqualTo(_parentView.LeftAnchor, 6).Active      = true;
            label7.BottomAnchor.ConstraintEqualTo(_parentView.BottomAnchor, -6).Active = true;

            var label8 = new UILabel {
                Text = "Eight", BackgroundColor = UIColor.FromRGBA(0, 0, 0, 125), TextColor = UIColor.White
            };

            _parentView.AddSubview(label8);

            //ど真ん中に置く
            label8.TranslatesAutoresizingMaskIntoConstraints = false;
            label8.CenterXAnchor.ConstraintEqualTo(_parentView.CenterXAnchor).Active = true;
            label8.CenterYAnchor.ConstraintEqualTo(_parentView.CenterYAnchor).Active = true;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Main scrolled stack

            var stackView = new UIStackView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis          = UILayoutConstraintAxis.Vertical,
                Alignment     = UIStackViewAlignment.Fill,
                Distribution  = UIStackViewDistribution.EqualSpacing,
                Spacing       = 4,
                LayoutMargins = new UIEdgeInsets(4, 4, 4, 4), // apply padding
                LayoutMarginsRelativeArrangement = true       // apply padding
            };

            var scroll = new UIScrollView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            Add(scroll);

            scroll.AddSubview(stackView);
            scroll.FullSizeOf(View);

            stackView.FullSizeOf(scroll);
            stackView.WidthAnchor.ConstraintEqualTo(scroll.WidthAnchor).Active = true;

            // Nested stacks

            var nested1 = new UIStackView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Fill,
                Distribution = UIStackViewDistribution.FillEqually,
                Spacing      = 4
            };

            var nested2 = new UIStackView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Fill,
                Distribution = UIStackViewDistribution.EqualSpacing,
                Spacing      = 4
            };

            var nested3 = new UIStackView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Fill,
                Distribution = UIStackViewDistribution.FillProportionally,
                Spacing      = 4
            };

            var nested4 = new UIStackView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Top,
                Distribution = UIStackViewDistribution.EqualCentering,
                Spacing      = 4
            };

            var nested5 = new UIStackView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Fill,
                Distribution = UIStackViewDistribution.EqualSpacing,
                Spacing      = 4
            };

            for (var i = 0; i < 3; i++)
            {
                nested1.AddArrangedSubview(GetRandomView());
                nested2.AddArrangedSubview(GetRandomView());
                nested3.AddArrangedSubview(GetRandomView());
                nested4.AddArrangedSubview(GetRandomView(50, 15 * (i + 1)));
            }

            stackView.AddArrangedSubview(GetNestedStackContainer("Fill Equally", nested1));
            stackView.AddArrangedSubview(GetNestedStackContainer("Equal Spacing", nested2));
            stackView.AddArrangedSubview(GetNestedStackContainer("Fill Proportionally", nested3));

            for (var i = 0; i < 30; i++)
            {
                nested5.AddArrangedSubview(GetRandomView());
            }

            var nestedScroll = new UIScrollView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            nestedScroll.AddSubview(nested5);

            stackView.AddArrangedSubview(GetNestedStackContainer("Nested stack with scroll", nestedScroll));

            nested5.FullSizeOf(nestedScroll);
            nested5.HeightAnchor.ConstraintEqualTo(nestedScroll.HeightAnchor).Active = true;

            stackView.AddArrangedSubview(GetNestedStackContainer("Align Top", nested4));
        }
Exemplo n.º 12
0
        public override void OnViewModelLoadedOverride()
        {
            bool isTask = ViewModel.Item.Type == TaskOrEventType.Task;

            BindingHost.SetBinding <string>(nameof(ViewModel.PageTitle), (t) => Title = StringWithCapitals(t));

            var buttonEdit = new UIBarButtonItem(UIBarButtonSystemItem.Edit);

            buttonEdit.Clicked += new WeakEventHandler(delegate { ViewModel.Edit(); }).Handler;

            var buttonMore = new UIBarButtonItem(UIImage.FromBundle("MenuVerticalIcon").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate), UIBarButtonItemStyle.Plain, new WeakEventHandler(ButtonMore_Clicked).Handler);

            NavItem.RightBarButtonItems = new UIBarButtonItem[]
            {
                buttonMore,
                buttonEdit
            };

            int bottomSliderHeight = isTask ? CIRCLE_BUTTON_HEIGHT + 16 + 16 : 0;

            _scrollView = new UIScrollView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                ShowsHorizontalScrollIndicator            = false
            };
            base.ContentView.AddSubview(_scrollView);
            _scrollView.StretchWidthAndHeight(base.ContentView, bottom: bottomSliderHeight);

            _stackView = new UIStackView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis = UILayoutConstraintAxis.Vertical
            };
            _scrollView.AddSubview(_stackView);
            _stackView.ConfigureForVerticalScrolling(_scrollView, top: 16, bottom: 16, left: 16, right: 16);

            _itemBindingHost = new BindingHost()
            {
                BindingObject = ViewModel.Item
            };
            _classBindingHost = new BindingHost();
            _itemBindingHost.SetBinding(nameof(ViewItemTaskOrEvent.Class), delegate
            {
                _classBindingHost.BindingObject = ViewModel.Item.Class;
            });

            var labelTitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font  = UIFont.PreferredTitle3,
                Lines = 0
            };

            _itemBindingHost.SetLabelTextBinding(labelTitle, nameof(ViewModel.Item.Name));
            _stackView.AddArrangedSubview(labelTitle);
            labelTitle.StretchWidth(_stackView);

            _stackView.AddArrangedSubview(new UIView().SetHeight(4));

            var labelSubtitle = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font  = UIFont.PreferredSubheadline,
                Lines = 0
            };

            _itemBindingHost.SetLabelTextBinding(labelSubtitle, nameof(ViewItemTaskOrEvent.Subtitle));
            _classBindingHost.SetBinding <byte[]>(nameof(ViewItemClass.Color), (color) =>
            {
                labelSubtitle.TextColor = BareUIHelper.ToColor(color);
            });
            _stackView.AddArrangedSubview(labelSubtitle);
            labelSubtitle.StretchWidth(_stackView);

            _stackView.AddArrangedSubview(new UIView().SetHeight(4));

            _stackView.AddSpacing(12);

            var textViewDetails = new UITextView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Font          = UIFont.PreferredBody,
                TextColor     = UIColorCompat.SecondaryLabelColor,
                Editable      = false,
                ScrollEnabled = false,

                // Link detection: http://iosdevelopertips.com/user-interface/creating-clickable-hyperlinks-from-a-url-phone-number-or-address.html
                DataDetectorTypes = UIDataDetectorType.All
            };

            // Lose the padding: https://stackoverflow.com/questions/746670/how-to-lose-margin-padding-in-uitextview
            textViewDetails.TextContainerInset = UIEdgeInsets.Zero;
            textViewDetails.TextContainer.LineFragmentPadding = 0;

            _itemBindingHost.SetTextViewTextBinding(textViewDetails, nameof(ViewItemTaskOrEvent.Details));
            _stackView.AddArrangedSubview(textViewDetails);
            textViewDetails.StretchWidth(_stackView);

            if (ViewModel.IsUnassigedMode)
            {
                var buttonAddGrade = new UIButton(UIButtonType.System)
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                buttonAddGrade.SetTitle("Add Grade", UIControlState.Normal);
                buttonAddGrade.SetTitleColor(new UIColor(1, 1), UIControlState.Normal);
                buttonAddGrade.BackgroundColor = ColorResources.PowerPlannerAccentBlue;
                buttonAddGrade.TouchUpInside  += new WeakEventHandler <EventArgs>(delegate { ViewModel.AddGrade(); }).Handler;
                base.ContentView.Add(buttonAddGrade);

                // https://stackoverflow.com/questions/46344381/ios-11-layout-guidance-about-safe-area-for-iphone-x
                if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
                {
                    NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] {
                        buttonAddGrade.LeftAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.LeftAnchor, 16),
                        buttonAddGrade.RightAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.RightAnchor, -16),
                        buttonAddGrade.BottomAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.BottomAnchor, -16)
                    });
                }
                else
                {
                    buttonAddGrade.StretchWidth(base.ContentView, left: 16, right: 16);
                    buttonAddGrade.PinToBottom(base.ContentView, bottom: 16);
                }
            }

            else
            {
                var completionSliderVisibilityContainer = new BareUIVisibilityContainer()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    var completionSliderContainer = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        _completionSlider = new UISlider()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            MaxValue = 1,
                            MinValue = 0,
                            MinimumTrackTintColor = UIColor.FromRGB(42 / 255f, 222 / 255f, 42 / 255f),
                            ThumbTintColor        = UIColor.FromRGB(42 / 255f, 222 / 255f, 42 / 255f)
                        };
                        _itemBindingHost.SetSliderBinding(_completionSlider, nameof(ViewItemTaskOrEvent.PercentComplete));
                        _completionSlider.TouchUpInside  += new WeakEventHandler(CompletionSlider_ValueCommitted).Handler;
                        _completionSlider.TouchUpOutside += new WeakEventHandler(CompletionSlider_ValueCommitted).Handler;
                        completionSliderContainer.Add(_completionSlider);
                        _completionSlider.StretchHeight(completionSliderContainer);
                        _completionSlider.StretchWidth(completionSliderContainer, left: CIRCLE_BUTTON_HEIGHT + 8, right: CIRCLE_BUTTON_HEIGHT + 8);

                        var incompleteImageContainer = new UIControl()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        {
                            _incompleteImageView = new UIImageView()
                            {
                                TranslatesAutoresizingMaskIntoConstraints = false,
                                ContentMode = UIViewContentMode.ScaleAspectFit,
                                TintColor   = UIColor.LightGray
                            };
                            incompleteImageContainer.Add(_incompleteImageView);
                            _incompleteImageView.StretchHeight(incompleteImageContainer);
                            _incompleteImageView.SetWidth(CIRCLE_BUTTON_HEIGHT);
                            _incompleteImageView.PinToLeft(incompleteImageContainer);
                        }
                        incompleteImageContainer.TouchUpInside += new WeakEventHandler(delegate { _completionSlider.Value = 0; ViewModel.SetPercentComplete(0); UpdateSliderImages(); }).Handler;
                        completionSliderContainer.Add(incompleteImageContainer);
                        incompleteImageContainer.StretchHeight(completionSliderContainer);
                        incompleteImageContainer.PinToLeft(completionSliderContainer);
                        incompleteImageContainer.SetWidth(CIRCLE_BUTTON_HEIGHT);

                        var completeImageContainer = new UIControl()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        {
                            _completeImageView = new UIImageView()
                            {
                                TranslatesAutoresizingMaskIntoConstraints = false,
                                ContentMode = UIViewContentMode.ScaleAspectFit,
                                TintColor   = UIColor.LightGray
                            };
                            completeImageContainer.Add(_completeImageView);
                            _completeImageView.StretchHeight(completeImageContainer);
                            _completeImageView.SetWidth(CIRCLE_BUTTON_HEIGHT);
                            _completeImageView.PinToRight(completeImageContainer);
                        }
                        completeImageContainer.TouchUpInside += new WeakEventHandler(delegate { _completionSlider.Value = 1; ViewModel.SetPercentComplete(1); UpdateSliderImages(); }).Handler;
                        completionSliderContainer.Add(completeImageContainer);
                        completeImageContainer.StretchHeight(completionSliderContainer);
                        completeImageContainer.PinToRight(completionSliderContainer);
                        completeImageContainer.SetWidth(CIRCLE_BUTTON_HEIGHT);

                        _completionSlider.ValueChanged += new WeakEventHandler(delegate { UpdateSliderImages(); }).Handler;
                    }

                    completionSliderContainer.SetHeight(CIRCLE_BUTTON_HEIGHT);

                    completionSliderVisibilityContainer.Child = completionSliderContainer;
                }
                BindingHost.SetVisibilityBinding(completionSliderVisibilityContainer, nameof(ViewModel.IsCompletionSliderVisible));
                base.ContentView.Add(completionSliderVisibilityContainer);

                // https://stackoverflow.com/questions/46344381/ios-11-layout-guidance-about-safe-area-for-iphone-x
                if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
                {
                    NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] {
                        completionSliderVisibilityContainer.LeftAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.LeftAnchor, 16),
                        completionSliderVisibilityContainer.RightAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.RightAnchor, -16),
                        completionSliderVisibilityContainer.BottomAnchor.ConstraintEqualTo(base.ContentView.SafeAreaLayoutGuide.BottomAnchor, -16)
                    });
                }
                else
                {
                    completionSliderVisibilityContainer.StretchWidth(base.ContentView, left: 16, right: 16);
                    completionSliderVisibilityContainer.PinToBottom(base.ContentView, bottom: 16);
                }

                _itemBindingHost.SetBinding(nameof(ViewItemTaskOrEvent.PercentComplete), UpdateSliderImages);
            }

            base.OnViewModelLoadedOverride();
        }
        private void CreateLayout()
        {
            nfloat height = 80;

            //set up UIStackView for laying out controls
            var stackView = new UIStackView(new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height));
            stackView.Axis = UILayoutConstraintAxis.Vertical;
            stackView.Alignment = UIStackViewAlignment.Fill;
            stackView.Distribution = UIStackViewDistribution.FillProportionally;
            stackView.BackgroundColor = UIColor.Gray;

            // Setup the visual frame for the MapView
            _myMapView = new MapView()
            {
                Frame = new CoreGraphics.CGRect(0, 0, View.Bounds.Width, View.Bounds.Height-80)
            };

            stackView.AddArrangedSubview(_myMapView);

            // Create a tableview for displaying layer view status for each layer
            _tableView = new UITableView(new CoreGraphics.CGRect(0, _myMapView.Frame.Height, View.Bounds.Width, height));
            stackView.AddArrangedSubview(_tableView);

            // Add MapView to the page
            View.AddSubviews(stackView);
        }
Exemplo n.º 14
0
 public void SetLayuots(UIStackView publisherLayout, UIStackView subscriberLayout)
 {
     this.PublisherView  = publisherLayout;
     this.SubscriberView = subscriberLayout;
 }
Exemplo n.º 15
0
        void Sample14()
        {
            _parentView = new UIView();

            _container = new UIStackView {
                Axis         = UILayoutConstraintAxis.Horizontal, //並べる方向
                Alignment    = UIStackViewAlignment.Center,       //垂直位置属性
                Distribution = UIStackViewDistribution.Fill,      //余白分配設定
                Spacing      = 6                                  //要素間のマージン
            };

            //レイアウトの余白設定
            _container.LayoutMargins = new UIEdgeInsets(6, 6, 6, 6);
            _container.LayoutMarginsRelativeArrangement = true;

            var image = new UIImageView(UIImage.FromBundle("icon.png"));

            image.ContentMode = UIViewContentMode.ScaleAspectFit;

            _container.AddArrangedSubview(image);

            image.WidthAnchor.ConstraintEqualTo(80).Active  = true;
            image.HeightAnchor.ConstraintEqualTo(46).Active = true;

            var vStack = new UIStackView {
                Axis         = UILayoutConstraintAxis.Vertical,
                Alignment    = UIStackViewAlignment.Fill,
                Distribution = UIStackViewDistribution.Fill,
                Spacing      = 6
            };

            var hStack = new UIStackView {
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Center,
                Distribution = UIStackViewDistribution.Fill,
                Spacing      = 6
            };

            var label1 = new UILabel {
                Text = "Xamarin Native Layout Sample TextTextTextTextText"
            };
            var label2 = new UILabel {
                Text = "******"
            };

            label1.Font = label1.Font.WithSize(16);
            label2.Font = label2.Font.WithSize(16);

            hStack.AddArrangedSubview(label1);
            hStack.AddArrangedSubview(label2);

            //余った領域を広げる優先度の設定(低いものが優先して拡大する)
            label1.SetContentHuggingPriority(1f, UILayoutConstraintAxis.Horizontal);
            label2.SetContentHuggingPriority(999f, UILayoutConstraintAxis.Horizontal);

            //縮まりやすさの設定(低いものが優先して縮まる)
            label1.SetContentCompressionResistancePriority(1f, UILayoutConstraintAxis.Horizontal);
            label2.SetContentCompressionResistancePriority(999f, UILayoutConstraintAxis.Horizontal);

            vStack.AddArrangedSubview(hStack);

            var label3 = new UILabel {
                Text = "複雑なレイアウトも入れ子にすることで実現可能です。Androidの方が簡単なのでiOS側からレイアウトを組んで行く方が良いかもしれません。"
            };

            label3.LineBreakMode = UILineBreakMode.CharacterWrap;
            label3.Lines         = 2;
            label3.Font          = label3.Font.WithSize(12);

            vStack.AddArrangedSubview(label3);

            hStack.SetContentHuggingPriority(999f, UILayoutConstraintAxis.Vertical);
            label3.SetContentHuggingPriority(1f, UILayoutConstraintAxis.Vertical);

            _container.AddArrangedSubview(vStack);

            image.SetContentHuggingPriority(999f, UILayoutConstraintAxis.Horizontal);
            vStack.SetContentHuggingPriority(1f, UILayoutConstraintAxis.Horizontal);

            image.SetContentCompressionResistancePriority(999f, UILayoutConstraintAxis.Horizontal);
            vStack.SetContentCompressionResistancePriority(1f, UILayoutConstraintAxis.Horizontal);

            _parentView.AddSubview(_container);
            _container.TranslatesAutoresizingMaskIntoConstraints = false;
            _container.TopAnchor.ConstraintEqualTo(_parentView.TopAnchor, 0).Active       = true;
            _container.LeftAnchor.ConstraintEqualTo(_parentView.LeftAnchor, 0).Active     = true;
            _container.BottomAnchor.ConstraintEqualTo(_parentView.BottomAnchor, 0).Active = true;
            _container.RightAnchor.ConstraintEqualTo(_parentView.RightAnchor, 0).Active   = true;


            var label4 = new UILabel {
                Text = "Sample", BackgroundColor = UIColor.FromRGBA(0, 0, 0, 125), TextColor = UIColor.White
            };

            label4.Font = label4.Font.WithSize(12);

            _parentView.AddSubview(label4);

            label4.TranslatesAutoresizingMaskIntoConstraints = false;
            label4.TopAnchor.ConstraintEqualTo(_parentView.TopAnchor, 3).Active   = true;
            label4.LeftAnchor.ConstraintEqualTo(_parentView.LeftAnchor, 3).Active = true;
        }
Exemplo n.º 16
0
        public UIDayScheduleSnapshot()
        {
            var background = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = UIColorCompat.SecondarySystemBackgroundColor
            };

            {
                var paddingContainer = new UIControl()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    _stackViewHolidays = new UIStackView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Axis    = UILayoutConstraintAxis.Vertical,
                        Spacing = 1
                    };
                    paddingContainer.Add(_stackViewHolidays);
                    _stackViewHolidays.StretchWidth(paddingContainer);

                    _timetable = new UIView()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false
                    };
                    {
                        _scheduleGapLines = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _timetable.Add(_scheduleGapLines);
                        _scheduleGapLines.StretchWidthAndHeight(_timetable);

                        _scheduleTimesColumn = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _timetable.Add(_scheduleTimesColumn);
                        _scheduleTimesColumn.StretchHeight(_timetable);
                        _scheduleTimesColumn.SetWidth(TIME_INDICATOR_SIZE);
                        _scheduleTimesColumn.PinToLeft(_timetable);

                        var verticalDivider = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false,
                            BackgroundColor = UIColorCompat.SecondaryLabelColor
                        };
                        _timetable.Add(verticalDivider);
                        verticalDivider.StretchHeight(_timetable);
                        verticalDivider.SetWidth(GAP_SIZE);
                        verticalDivider.PinToLeft(_timetable, left: (int)TIME_INDICATOR_SIZE);

                        _scheduleItemsColumn = new UIView()
                        {
                            TranslatesAutoresizingMaskIntoConstraints = false
                        };
                        _timetable.Add(_scheduleItemsColumn);
                        _scheduleItemsColumn.StretchHeight(_timetable);
                        _scheduleItemsColumn.StretchWidth(_timetable, left: TIME_INDICATOR_SIZE + GAP_SIZE + 8, right: 8);

                        // Normally we would have used constraints to lay these out horizontally, but for some reason constraints
                        // are acting up and the horizontal constraints weren't working correctly, so just pinning things to the left
                        // and applying correct padding
                        // Maybe it was because I originally forgot TranslatesAutoresizing on the verticalDivider... that would explain it
                    }
                    paddingContainer.Add(_timetable);
                    _timetable.StretchWidth(paddingContainer);

                    _holidaysItemsSourceAdapter = new BareUIStackViewItemsSourceAdapter <UIMainCalendarItemView>(_stackViewHolidays);

                    paddingContainer.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[holidays][timetable]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                        "holidays", _stackViewHolidays,
                                                                                        "timetable", _timetable));
                }
                background.Add(paddingContainer);
                paddingContainer.StretchWidthAndHeight(background);
            }
            this.Add(background);
            background.StretchWidthAndHeight(this, top: 16, bottom: 16);
        }
Exemplo n.º 17
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            UIView contentView = new UIView()
            {
                BackgroundColor = UIColor.FromRGB(123, 123, 123)
            };

            View = contentView;
            CGRect rect = UIScreen.MainScreen.Bounds;

            rect.Y      += 50;
            rect.Height -= 100;

            UIStackView vertStackView = new UIStackView(rect)
            {
                Axis = UILayoutConstraintAxis.Vertical
            };

            UIStackView horizStackView = new UIStackView(rect)
            {
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Center,
                Distribution = UIStackViewDistribution.EqualSpacing
            };

            CanvasView canvasView = new CanvasView();


            contentView.Add(vertStackView);
            vertStackView.AddArrangedSubview(horizStackView);
            vertStackView.AddArrangedSubview(canvasView);

            UILabel placeHolder1 = new UILabel(new CGRect(0, 0, 10, 10));
            UILabel placeHolder2 = new UILabel(new CGRect(0, 0, 10, 10));

            horizStackView.AddArrangedSubview(placeHolder1);

            PickerDataModel <UIColor> colorModel = new PickerDataModel <UIColor>
            {
                Items =
                {
                    new NamedValue <UIColor>("Rot",  UIColor.Red),
                    new NamedValue <UIColor>("Grün", UIColor.Green),
                    new NamedValue <UIColor>("Gelb", UIColor.Yellow),
                    new NamedValue <UIColor>("Blau", UIColor.Blue)
                }
            };

            UIPickerView colorPicker = new UIPickerView
            {
                Model = colorModel
            };

            PickerDataModel <float> thicknessModel = new PickerDataModel <float>
            {
                Items =
                {
                    new NamedValue <float>("Dünn",    2),
                    new NamedValue <float>("Medium", 10),
                    new NamedValue <float>("Normal", 20),
                    new NamedValue <float>("Dick", 40)
                }
            };

            UIPickerView thicknessPicker = new UIPickerView
            {
                Model = thicknessModel
            };

            var toolbar = new UIToolbar(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, 45))
            {
                BarStyle    = UIBarStyle.BlackTranslucent,
                Translucent = true
            };

            //UIFont font = UIFont.SystemFontOfSize(24);
            UIFont font = UIFont.FromName("Chalkduster", 24);

            UITextField txtColor = new UITextField
            {
                Text               = "Rot",
                InputView          = colorPicker,
                InputAccessoryView = toolbar,
                Font               = font
            };

            UITextField txtThickness = new UITextField
            {
                Text               = "Dünn",
                InputView          = thicknessPicker,
                InputAccessoryView = toolbar,
                Font               = font
            };


            horizStackView.AddArrangedSubview(txtColor);
            horizStackView.AddArrangedSubview(txtThickness);

            UIButton btnClear = new UIButton(UIButtonType.RoundedRect)
            {
                Font = font
            };

            btnClear.Layer.BorderColor  = UIColor.White.CGColor;
            btnClear.Layer.BorderWidth  = 1;
            btnClear.Layer.CornerRadius = 10;
            btnClear.SetTitle("Clear", UIControlState.Normal);
            btnClear.SetTitleColor(UIColor.Black, UIControlState.Normal);

            horizStackView.AddArrangedSubview(btnClear);

            horizStackView.AddArrangedSubview(placeHolder2);

            btnClear.TouchUpInside += (sender, args) =>
            {
                canvasView.clear();
            };

            thicknessModel.valueChanged += (sender, args) =>
            {
                txtThickness.Text      = thicknessModel.SelectedItem.Name;
                canvasView.StrokeWidth = thicknessModel.SelectedItem.Value;
            };

            colorModel.valueChanged += (semder, args) =>
            {
                txtColor.Text = colorModel.SelectedItem.Name;
                //canvasView.StrokeColor = UIColor.FromRGB(123, 123, 123).CGColor;
                canvasView.StrokeColor = colorModel.SelectedItem.Value.CGColor;
            };

            var spacer     = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);
            var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, (sender, args) =>
            {
                txtColor.ResignFirstResponder();
                txtThickness.ResignFirstResponder();
            });

            toolbar.SetItems(new[] { spacer, doneButton }, true);
        }
        protected virtual void SetUpContentView()
        {
            //remove existing views
            ImageView.RemoveFromSuperview();
            TextLabel.RemoveFromSuperview();
            ImageView.Hidden = true;
            TextLabel.Hidden = true;

            //外側のHorizontalStackView
            //Outer HorizontalStackView
            StackH = new UIStackView
            {
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Center,
                Spacing      = 16,
                Distribution = UIStackViewDistribution.Fill
            };
            //set margin
            StackH.LayoutMargins = new UIEdgeInsets(6, 16, 6, 16);
            StackH.LayoutMarginsRelativeArrangement = true;

            IconView = new UIImageView();

            //round corners
            IconView.ClipsToBounds = true;

            StackH.AddArrangedSubview(IconView);

            UpdateIconSize();

            //右に配置するVerticalStackView(コアの部品とDescriptionを格納)
            //VerticalStackView that is arranged at right. ( put main parts and Description )
            StackV = new UIStackView
            {
                Axis         = UILayoutConstraintAxis.Vertical,
                Alignment    = UIStackViewAlignment.Fill,
                Spacing      = 4,
                Distribution = UIStackViewDistribution.Fill,
            };

            //右側上段に配置するHorizontalStackView(LabelTextとValueTextを格納)
            //HorizontalStackView that is arranged at upper in right.(put LabelText and ValueText)
            ContentStack = new UIStackView
            {
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Fill,
                Spacing      = 6,
                Distribution = UIStackViewDistribution.Fill,
            };

            TitleLabel       = new UILabel();
            DescriptionLabel = new UILabel();

            DescriptionLabel.Lines         = 0;
            DescriptionLabel.LineBreakMode = UILineBreakMode.WordWrap;

            ContentStack.AddArrangedSubview(TitleLabel);

            StackV.AddArrangedSubview(ContentStack);
            StackV.AddArrangedSubview(DescriptionLabel);

            StackH.AddArrangedSubview(StackV);

            //余った領域を広げる優先度の設定(低いものが優先して拡大する)
            IconView.SetContentHuggingPriority(999f, UILayoutConstraintAxis.Horizontal); //if possible, not to expand. 極力広げない
            StackV.SetContentHuggingPriority(1f, UILayoutConstraintAxis.Horizontal);
            ContentStack.SetContentHuggingPriority(1f, UILayoutConstraintAxis.Horizontal);
            TitleLabel.SetContentHuggingPriority(1f, UILayoutConstraintAxis.Horizontal);
            DescriptionLabel.SetContentHuggingPriority(1f, UILayoutConstraintAxis.Horizontal);


            //縮まりやすさの設定(低いものが優先して縮まる)
            IconView.SetContentCompressionResistancePriority(999f, UILayoutConstraintAxis.Horizontal); //if possible, not to shrink. 極力縮めない
            StackV.SetContentCompressionResistancePriority(999f, UILayoutConstraintAxis.Horizontal);
            ContentStack.SetContentCompressionResistancePriority(999f, UILayoutConstraintAxis.Horizontal);
            TitleLabel.SetContentCompressionResistancePriority(999f, UILayoutConstraintAxis.Horizontal);
            DescriptionLabel.SetContentCompressionResistancePriority(999f, UILayoutConstraintAxis.Horizontal);

            IconView.SetContentCompressionResistancePriority(999f, UILayoutConstraintAxis.Vertical);
            IconView.SetContentHuggingPriority(1f, UILayoutConstraintAxis.Vertical);
            StackV.SetContentCompressionResistancePriority(999f, UILayoutConstraintAxis.Vertical);
            StackV.SetContentHuggingPriority(1f, UILayoutConstraintAxis.Vertical);

            ContentView.AddSubview(StackH);

            StackH.TranslatesAutoresizingMaskIntoConstraints = false;
            StackH.TopAnchor.ConstraintEqualTo(ContentView.TopAnchor).Active       = true;
            StackH.LeftAnchor.ConstraintEqualTo(ContentView.LeftAnchor).Active     = true;
            StackH.BottomAnchor.ConstraintEqualTo(ContentView.BottomAnchor).Active = true;
            StackH.RightAnchor.ConstraintEqualTo(ContentView.RightAnchor).Active   = true;


            var minHeight = Math.Max(CellParent?.RowHeight ?? 44, SettingsViewRenderer.MinRowHeight);

            _minheightConstraint = StackH.HeightAnchor.ConstraintGreaterThanOrEqualTo(minHeight);
            // fix warning-log:Unable to simultaneously satisfy constraints.
            _minheightConstraint.Priority = 999f; // this is superior to any other view.
            _minheightConstraint.Active   = true;
        }
        public override void OnViewModelLoadedOverride()
        {
            AddTopSectionDivider();

            _errorContainer = new BareUIVisibilityContainer()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                IsVisible = false
            };
            {
                var stackViewIncorrect = new UIStackView()
                {
                    Axis = UILayoutConstraintAxis.Vertical
                };
                stackViewIncorrect.AddArrangedSubview(new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                }.SetHeight(8));
                _labelError = new UILabel()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Text      = "Error",
                    Lines     = 0,
                    TextColor = UIColor.Red
                };
                stackViewIncorrect.AddArrangedSubview(_labelError);
                _labelError.StretchWidth(stackViewIncorrect, left: 16, right: 16);
                stackViewIncorrect.AddArrangedSubview(new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                }.SetHeight(8));

                AddDivider(stackViewIncorrect);

                _errorContainer.Child = stackViewIncorrect;
            }
            StackView.AddArrangedSubview(_errorContainer);
            _errorContainer.StretchWidth(StackView);

            var textField = new UITextField()
            {
                Placeholder            = "New username",
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType     = UITextAutocorrectionType.No,
                KeyboardType           = UIKeyboardType.ASCIICapable,
                ReturnKeyType          = UIReturnKeyType.Done
            };

            textField.AddTarget(new WeakEventHandler <EventArgs>(delegate
            {
                _errorContainer.IsVisible = false;
            }).Handler, UIControlEvent.EditingChanged);
            AddTextField(textField, nameof(ViewModel.Username), firstResponder: true);

            AddSectionDivider();

            var buttonContinue = new UIButton(UIButtonType.System)
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            buttonContinue.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.Update(); }).Handler;
            buttonContinue.SetTitle("Update Username", UIControlState.Normal);
            StackView.AddArrangedSubview(buttonContinue);
            buttonContinue.StretchWidth(StackView);
            buttonContinue.SetHeight(44);

            AddBottomSectionDivider();

            ViewModel.ActionError += new WeakEventHandler <string>(ViewModel_ActionError).Handler;

            BindingHost.SetBinding(nameof(ViewModel.IsUpdatingUsername), delegate
            {
                IsLoadingOverlayVisible = ViewModel.IsUpdatingUsername;
            });

            base.OnViewModelLoadedOverride();
        }
Exemplo n.º 20
0
        //public override void ViewWillLayoutSubviews()
        //{
        //    base.ViewWillLayoutSubviews();

        //    // Set background colour
        //    this.View.BackgroundColor = UIColor.LightGray.ColorWithAlpha(0.4f);

        //    // Create container view to house add list item elements.
        //    UIView popupBox = new UIView(new CGRect(0, 0, (UIScreen.MainScreen.Bounds.Width - 40), (UIScreen.MainScreen.Bounds.Height - 280)));
        //    popupBox.Center = View.Center;
        //    popupBox.BackgroundColor = UIColor.White;
        //    popupBox.Layer.CornerRadius = 5;
        //    View.AddSubview(popupBox);


        //    ////// Create Cancel button
        //    //UIButton cancelBtn = new SizeView(new CGSize(40, 100));
        //    //cancelBtn.BackgroundColor = UIColor.Blue;
        //    //cancelBtn.SetTitle("Cancel", UIControlState.Normal);

        //    ////// Create Add button
        //    //UIButton addBtn = new SizeView(new CGSize(40, 100));
        //    //addBtn.BackgroundColor = UIColor.Blue;
        //    //addBtn.SetTitle("Add", UIControlState.Normal);


        //    //var buttonLayout = new UIStackView()
        //    //{
        //    //    Axis = UILayoutConstraintAxis.Horizontal,
        //    //    Alignment = UIStackViewAlignment.Center,
        //    //    Distribution = UIStackViewDistribution.EqualSpacing,
        //    //    Spacing = 20
        //    //};

        //    //buttonLayout.BackgroundColor = UIColor.Black;

        //    //View.AddSubview(buttonLayout);
        //    //View.AddConstraint(buttonLayout.BottomAnchor.ConstraintEqualTo(popupBox.BottomAnchor));
        //    //View.AddConstraint(buttonLayout.LeftAnchor.ConstraintEqualTo(popupBox.LeftAnchor));
        //    //View.AddConstraint(buttonLayout.RightAnchor.ConstraintEqualTo(popupBox.RightAnchor));
        //    //View.AddConstraint(buttonLayout.HeightAnchor.ConstraintEqualTo(60));

        //    //buttonLayout.AddArrangedSubview(cancelBtn);
        //    //buttonLayout.AddArrangedSubview(addBtn);

        //    // Create UIView for title label
        //    UIView titleLabelView = new UIView(new CGRect(0, 0, popupBox.Bounds.Width, 60));
        //    titleLabelView.Frame.Top.Equals(popupBox.Frame.Top);
        //    titleLabelView.BackgroundColor = UIColor.FromRGB(253, 81, 201);
        //    popupBox.AddSubview(titleLabelView);

        //    ////// Create container view to house add buttons.
        //    //UIView btnView = new UIView(new CGRect(0, (popupBox.Bounds.Height - 60), popupBox.Bounds.Width, 60));
        //    //btnView.Frame.Bottom.Equals(popupBox.Frame.Bottom);
        //    //btnView.BackgroundColor = UIColor.Black;
        //    //popupBox.AddSubview(btnView);

        //    UILabel titleLabel = new UILabel(new CGRect(titleLabelView.Bounds.X, titleLabelView.Bounds.Y, titleLabelView.Bounds.Width, titleLabelView.Bounds.Height));
        //    // titleLabel.Frame.Size.Equals(titleLabelView.Frame.Size);
        //    titleLabel.Text = "Add Item to List";
        //    titleLabel.TextColor = UIColor.White;
        //    titleLabel.TextAlignment = UITextAlignment.Center;
        //    titleLabelView.AddSubview(titleLabel);
        //    titleLabelView.BringSubviewToFront(titleLabel);

        //    //// Create Cancel button
        //    //UIButton cancelBtn = new UIButton(new CGRect(20, ((btnView.Bounds.Height / 2) - 20), (popupBox.Bounds.Width / 3), 40));
        //    //cancelBtn.BackgroundColor = UIColor.Blue;
        //    //cancelBtn.SetTitle("Cancel", UIControlState.Normal);
        //    //btnView.AddSubview(cancelBtn);

        //    UITextField itemTitle = new UITextField(new CGRect((popupBox.Bounds.Width/2 - (popupBox.Bounds.Width - 40) /2), titleLabelView.Bounds.Y + 80, popupBox.Bounds.Width - 40, 30));
        //    itemTitle.Font = UIFont.FromName("Helvetica-Neue", 14.0f);
        //    itemTitle.Placeholder = "Enter item title";
        //    itemTitle.Layer.CornerRadius = 5;
        //    itemTitle.Layer.BorderWidth = 1;
        //    popupBox.AddSubview(itemTitle);
        //    titleLabelView.BringSubviewToFront(itemTitle);


        //    UITextView itemDescription = new UITextView(new CGRect((popupBox.Bounds.Width / 2 - (popupBox.Bounds.Width - 40) / 2), itemTitle.Bounds.Y + 110, popupBox.Bounds.Width - 40, 80));
        //    itemDescription.Text = "Enter item description";
        //    itemTitle.Font = UIFont.FromName("Helvetica-Neue", 14.0f);
        //    itemDescription.Layer.CornerRadius = 5;
        //    itemDescription.Layer.BorderWidth = 1;
        //    popupBox.AddSubview(itemDescription);
        //    titleLabelView.BringSubviewToFront(itemDescription);

        //    // Create Cancel button
        //    cancelBtn.Layer.BorderColor = UIColor.FromRGB(253, 81, 201).CGColor;
        //    cancelBtn.HeightAnchor.ConstraintEqualTo(100);
        //    cancelBtn.WidthAnchor.ConstraintEqualTo(200);
        //    popupBox.AddSubview(cancelBtn);

        //    // Create Add button
        //    UIButton addBtn = new UIButton();
        //    addBtn.BackgroundColor = UIColor.Red;
        //    addBtn.HeightAnchor.ConstraintEqualTo(100);
        //    addBtn.WidthAnchor.ConstraintEqualTo(200);

        //    ////// Create Add button
        //    //UIButton addBtn = new UIButton(new CGRect(280, ((btnView.Bounds.Height / 2) - 20), (popupBox.Bounds.Width / 3), 40));
        //    //addBtn.BackgroundColor = UIColor.Blue;
        //    //addBtn.SetTitle("Add", UIControlState.Normal);
        //    //btnView.AddSubview(addBtn);

        //    UIStackView btnStack = new UIStackView()
        //    {
        //        Axis = UILayoutConstraintAxis.Horizontal,
        //        Alignment = UIStackViewAlignment.Center,
        //        Distribution = UIStackViewDistribution.EqualSpacing,
        //        Spacing = 40
        //    };

        //    btnStack.AddArrangedSubview(cancelBtn);
        //    btnStack.AddArrangedSubview(addBtn);

        //    //Layout for Stack View
        //    btnStack.Center.Equals(View.Center);
        //    btnStack.TranslatesAutoresizingMaskIntoConstraints = false;


        //}


        public void setupStackViews()
        {
            //Create Container Stackview
            UIStackView containerStackView = new UIStackView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis          = UILayoutConstraintAxis.Horizontal,
                Alignment     = UIStackViewAlignment.Fill,
                Distribution  = UIStackViewDistribution.EqualSpacing,
                Spacing       = 20,
                LayoutMargins = new UIEdgeInsets(150, 20, 150, 20),
                LayoutMarginsRelativeArrangement = true
            };

            View.AddSubview(containerStackView);

            // Nested stacks

            var buttonView = new UIStackView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Fill,
                Distribution = UIStackViewDistribution.FillEqually,
                Spacing      = 4
            };

            var nested2 = new UIStackView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Fill,
                Distribution = UIStackViewDistribution.EqualSpacing,
                Spacing      = 4
            };

            var nested3 = new UIStackView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Fill,
                Distribution = UIStackViewDistribution.FillProportionally,
                Spacing      = 4
            };

            //View 1
            UIView view1 = new UIView();

            view1.BackgroundColor = UIColor.Blue;
            view1.HeightAnchor.ConstraintEqualTo(100);
            view1.WidthAnchor.ConstraintEqualTo(200);


            //View 2
            UIView view2 = new UIView();

            view2.BackgroundColor = UIColor.Blue;
            view2.HeightAnchor.ConstraintEqualTo(100);
            view2.WidthAnchor.ConstraintEqualTo(200);

            //View 3
            UIView view3 = new UIView();

            view3.BackgroundColor = UIColor.Blue;
            view3.HeightAnchor.ConstraintEqualTo(100);
            view3.WidthAnchor.ConstraintEqualTo(200);


            containerStackView.AddArrangedSubview(buttonView);
            containerStackView.AddArrangedSubview(nested2);
            containerStackView.AddArrangedSubview(nested3);
            //stackView.TranslatesAutoresizingMaskIntoConstraints = false;
            //View.AddSubview(stackView);


            //Layout for Stack View
            //stackView.Center.Equals(View.Center);
        }
        public override void LoadView()
        {
            // Create the views.
            View = new UIView()
            {
                BackgroundColor = UIColor.White
            };

            UIScrollView scrollView = new UIScrollView();

            scrollView.TranslatesAutoresizingMaskIntoConstraints = false;

            View.AddSubviews(scrollView);

            NSLayoutConstraint.ActivateConstraints(new[]
            {
                scrollView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                scrollView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor),
                scrollView.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor),
                scrollView.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),
            });

            UIStackView buttonContainer = new UIStackView();

            buttonContainer.Axis = UILayoutConstraintAxis.Vertical;
            buttonContainer.TranslatesAutoresizingMaskIntoConstraints = false;
            buttonContainer.Distribution = UIStackViewDistribution.Fill;
            buttonContainer.Alignment    = UIStackViewAlignment.Top;
            buttonContainer.Spacing      = 5;
            buttonContainer.LayoutMarginsRelativeArrangement = true;
            buttonContainer.DirectionalLayoutMargins         = new NSDirectionalEdgeInsets(10, 10, 10, 0);

            UILabel barrierLabel = new UILabel()
            {
                Text = "Include barriers   ", TranslatesAutoresizingMaskIntoConstraints = false
            };

            _barrierSwitch = new UISwitch()
            {
                TranslatesAutoresizingMaskIntoConstraints = false, On = true
            };
            buttonContainer.AddArrangedSubview(GetRowStackView(new UIView[] { barrierLabel, _barrierSwitch }));

            UILabel containerLabel = new UILabel()
            {
                Text = "Include containers", TranslatesAutoresizingMaskIntoConstraints = false
            };

            _containerSwitch = new UISwitch()
            {
                TranslatesAutoresizingMaskIntoConstraints = false, On = true
            };
            buttonContainer.AddArrangedSubview(GetRowStackView(new UIView[] { containerLabel, _containerSwitch }));

            UILabel helpLabel = new UILabel()
            {
                Text = "Example barrier condition for this data: 'Transformer Load' Equal '15'", TranslatesAutoresizingMaskIntoConstraints = false, Lines = 0
            };

            buttonContainer.AddArrangedSubview(helpLabel);

            UILabel conditionTitleLabel = new UILabel()
            {
                Text = "Barrier Condition:", TranslatesAutoresizingMaskIntoConstraints = false, Lines = 0, MinimumFontSize = (nfloat)(helpLabel.MinimumFontSize * 1.5)
            };

            buttonContainer.AddArrangedSubview(conditionTitleLabel);

            _attributeButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _attributeButton.SetTitle("Attribute", UIControlState.Normal);
            _attributeButton.SetTitleColor(View.TintColor, UIControlState.Normal);
            _comparisonButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _comparisonButton.SetTitle("Comparison", UIControlState.Normal);
            _comparisonButton.SetTitleColor(View.TintColor, UIControlState.Normal);
            _valueButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _valueButton.SetTitle("Value", UIControlState.Normal);
            _valueButton.SetTitleColor(View.TintColor, UIControlState.Normal);
            buttonContainer.AddArrangedSubview(GetRowStackView(new UIView[] { _attributeButton, _comparisonButton, _valueButton }));

            _addButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _addButton.SetTitle("Add barrier condition", UIControlState.Normal);
            _addButton.SetTitleColor(View.TintColor, UIControlState.Normal);
            buttonContainer.AddArrangedSubview(GetRowStackView(new UIView[] { _addButton }));

            _expressionLabel = new UILabel()
            {
                TranslatesAutoresizingMaskIntoConstraints = false, Text = "", Lines = 0
            };
            buttonContainer.AddArrangedSubview(_expressionLabel);

            _traceButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _traceButton.SetTitle("Trace", UIControlState.Normal);
            _traceButton.SetTitleColor(View.TintColor, UIControlState.Normal);

            _resetButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            _resetButton.SetTitle("Reset", UIControlState.Normal);
            _resetButton.SetTitleColor(View.TintColor, UIControlState.Normal);
            buttonContainer.AddArrangedSubview(GetRowStackView(new UIView[] { _traceButton, _resetButton }));

            scrollView.AddSubview(buttonContainer);

            NSLayoutConstraint.ActivateConstraints(new[]
            {
                buttonContainer.TopAnchor.ConstraintEqualTo(scrollView.TopAnchor),
                buttonContainer.LeadingAnchor.ConstraintEqualTo(scrollView.LeadingAnchor),
                buttonContainer.TrailingAnchor.ConstraintEqualTo(scrollView.TrailingAnchor),
                buttonContainer.BottomAnchor.ConstraintEqualTo(scrollView.BottomAnchor),
                buttonContainer.WidthAnchor.ConstraintEqualTo(scrollView.WidthAnchor),
            });
        }
Exemplo n.º 22
0
        private void setupView()
        {
            var margins = View.LayoutMarginsGuide;

            CancelButton = new UIButton()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            View.Add(CancelButton);
            //CancelButton.SetTitle("Close", UIControlState.Normal);
            CancelButton.SetImage(UIImage.FromBundle("Cancel").
                                  ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate),
                                  UIControlState.Normal);
            CancelButton.TintColor = UIColor.White;
            CancelButton.TopAnchor.ConstraintEqualTo(margins.TopAnchor).Active           = true;
            CancelButton.LeadingAnchor.ConstraintEqualTo(margins.LeadingAnchor).Active   = true;
            CancelButton.TrailingAnchor.ConstraintEqualTo(margins.TrailingAnchor).Active = true;
            CancelButton.HeightAnchor.ConstraintEqualTo(50).Active = true;
            CancelButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            CancelButton.TouchUpInside      += CancelButton_TouchUpInside;
            CancelButton.BackgroundColor     = UIColor.Clear;
            int count = 0;

            LeftStackView = new UIStackView
            {
                Axis         = UILayoutConstraintAxis.Vertical,
                Alignment    = UIStackViewAlignment.Fill,
                Distribution = UIStackViewDistribution.FillEqually,
                Spacing      = 10,
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            RightStackView = new UIStackView
            {
                Axis         = UILayoutConstraintAxis.Vertical,
                Alignment    = UIStackViewAlignment.Fill,
                Distribution = UIStackViewDistribution.FillEqually,
                Spacing      = 10,
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            foreach (var i in buttonList)
            {
                UIButton SettingsButton = new UIButton
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                SettingsButton.TitleLabel.Font = UIFont.BoldSystemFontOfSize(25);
                CancelButton.BackgroundColor   = UIColor.Clear;
                SettingsButton.TouchUpInside  += SettingsButton_TouchUpInside;
                SettingsButton.SetTitle(i, UIControlState.Normal);

                if (count < 3)
                {
                    LeftStackView.AddArrangedSubview(SettingsButton);
                }
                else
                {
                    RightStackView.AddArrangedSubview(SettingsButton);
                }
                count++;
            }
            FullStackView = new UIStackView
            {
                Axis         = UILayoutConstraintAxis.Horizontal,
                Alignment    = UIStackViewAlignment.Fill,
                Distribution = UIStackViewDistribution.FillEqually,
                Spacing      = 10,
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            FullStackView.AddArrangedSubview(LeftStackView);
            FullStackView.AddArrangedSubview(RightStackView);
            View.Add(FullStackView);
            FullStackView.TopAnchor.ConstraintEqualTo(CancelButton.BottomAnchor, 20).Active     = true;
            FullStackView.BottomAnchor.ConstraintEqualTo(margins.BottomAnchor, -200).Active     = true;
            FullStackView.LeadingAnchor.ConstraintEqualTo(margins.LeadingAnchor, 100).Active    = true;
            FullStackView.TrailingAnchor.ConstraintEqualTo(margins.TrailingAnchor, -100).Active = true;
        }
 public BareUIStackViewItemsSourceAdapter(UIStackView stackView, Func <object, UIView> createViewFuction)
     : base(createViewFuction)
 {
     StackView = stackView;
 }
Exemplo n.º 24
0
        void UpdateSwipeItems()
        {
            if (_contentView == null || _actionView != null)
            {
                return;
            }

            _swipeItemsRect = new List <CGRect>();

            SwipeItems items = GetSwipeItemsByDirection();
            double     swipeItemsWidth;

            if (_swipeDirection == SwipeDirection.Left || _swipeDirection == SwipeDirection.Right)
            {
                swipeItemsWidth = (items != null ? items.Count : 0) * SwipeItemWidth;
            }
            else
            {
                swipeItemsWidth = _contentView.Frame.Width;
            }

            if (items == null || items.Count == 0)
            {
                return;
            }

            _actionView = new UIStackView
            {
                Axis  = UILayoutConstraintAxis.Horizontal,
                Frame = new CGRect(0, 0, swipeItemsWidth, _contentView.Frame.Height)
            };

            int   i             = 0;
            float previousWidth = 0;

            foreach (var item in items)
            {
                var swipeItem = (item is SwipeItem) ? CreateSwipeItem((SwipeItem)item) : CreateSwipeItemView((SwipeItemView)item);

                var   swipeItemSize   = GetSwipeItemSize(item);
                float swipeItemHeight = (float)swipeItemSize.Height;
                float swipeItemWidth  = (float)swipeItemSize.Width;

                switch (_swipeDirection)
                {
                case SwipeDirection.Left:
                    swipeItem.Frame = new CGRect(_contentView.Frame.Width - (swipeItemWidth + previousWidth), 0, i + 1 * swipeItemWidth, swipeItemHeight);
                    break;

                case SwipeDirection.Right:
                case SwipeDirection.Up:
                case SwipeDirection.Down:
                    swipeItem.Frame = new CGRect(previousWidth, 0, i + 1 * swipeItemWidth, swipeItemHeight);
                    break;
                }

                _actionView.AddSubview(swipeItem);
                _swipeItemsRect.Add(swipeItem.Frame);
                previousWidth += swipeItemWidth;

                i++;
            }

            AddSubview(_actionView);
            BringSubviewToFront(_contentView);
        }
Exemplo n.º 25
0
        public override void LoadView()
        {
            // Create the views.
            View = new UIView {
                BackgroundColor = ApplicationTheme.BackgroundColor
            };

            _staticSceneView = new SceneView();
            _staticSceneView.TranslatesAutoresizingMaskIntoConstraints = false;
            _dynamicSceneView = new SceneView();
            _dynamicSceneView.TranslatesAutoresizingMaskIntoConstraints = false;

            _stackView = new UIStackView(new UIView[] { _staticSceneView, _dynamicSceneView });
            _stackView.TranslatesAutoresizingMaskIntoConstraints = false;
            _stackView.Distribution = UIStackViewDistribution.FillEqually;
            _stackView.Axis         = View.TraitCollection.VerticalSizeClass == UIUserInterfaceSizeClass.Compact ? UILayoutConstraintAxis.Horizontal : UILayoutConstraintAxis.Vertical;

            _zoomButton       = new UIBarButtonItem();
            _zoomButton.Title = "Zoom";

            UIToolbar toolbar = new UIToolbar();

            toolbar.TranslatesAutoresizingMaskIntoConstraints = false;
            toolbar.Items = new[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                _zoomButton,
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace)
            };

            UILabel staticLabel = new UILabel
            {
                Text            = "Static",
                BackgroundColor = UIColor.FromWhiteAlpha(0f, .6f),
                TextColor       = UIColor.White,
                TextAlignment   = UITextAlignment.Center,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            UILabel dynamicLabel = new UILabel
            {
                Text            = "Dynamic",
                BackgroundColor = UIColor.FromWhiteAlpha(0f, .6f),
                TextColor       = UIColor.White,
                TextAlignment   = UITextAlignment.Center,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            // Add the views.
            View.AddSubviews(_stackView, toolbar, staticLabel, dynamicLabel);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                _stackView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _stackView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor),
                _stackView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _stackView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),

                toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),

                staticLabel.TopAnchor.ConstraintEqualTo(_staticSceneView.TopAnchor),
                staticLabel.HeightAnchor.ConstraintEqualTo(40),
                staticLabel.LeadingAnchor.ConstraintEqualTo(_staticSceneView.LeadingAnchor),
                staticLabel.TrailingAnchor.ConstraintEqualTo(_staticSceneView.TrailingAnchor),

                dynamicLabel.TopAnchor.ConstraintEqualTo(_dynamicSceneView.TopAnchor),
                dynamicLabel.HeightAnchor.ConstraintEqualTo(40),
                dynamicLabel.LeadingAnchor.ConstraintEqualTo(_dynamicSceneView.LeadingAnchor),
                dynamicLabel.TrailingAnchor.ConstraintEqualTo(_dynamicSceneView.TrailingAnchor)
            });
        }
Exemplo n.º 26
0
        public override void OnViewModelLoadedOverride()
        {
            var safeView = BareUISafeView.CreateAndAddTo(View);

            {
                var viewTopSpacer = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                safeView.Add(viewTopSpacer);
                viewTopSpacer.StretchWidth(safeView);

                var viewCenterContainer = new UIStackView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Axis    = UILayoutConstraintAxis.Vertical,
                    Spacing = 8
                };
                {
                    var icon = new UIImageView(UIImage.FromBundle("PowerPlannerIcon"))
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        ContentMode = UIViewContentMode.ScaleAspectFit
                    };
                    icon.SetHeight(100);
                    viewCenterContainer.AddArrangedSubview(icon);

                    // In iOS 13, WhiteLarge was deprecated and Large was added
                    var progressRing = new UIActivityIndicatorView(UIDevice.CurrentDevice.CheckSystemVersion(13, 0) ? UIActivityIndicatorViewStyle.Large : UIActivityIndicatorViewStyle.WhiteLarge)
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Color = UIColor.White
                    };
                    progressRing.StartAnimating();
                    viewCenterContainer.AddUnderVisiblity(progressRing, BindingHost, nameof(ViewModel.IsSyncing));

                    var labelSyncing = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Text          = PowerPlannerResources.GetString("LoginPage_String_SyncingAccount"),
                        TextColor     = new UIColor(1, 1),
                        Font          = UIFont.PreferredTitle2,
                        TextAlignment = UITextAlignment.Center
                    };
                    viewCenterContainer.AddUnderVisiblity(labelSyncing, BindingHost, nameof(ViewModel.IsSyncing));

                    var labelSyncError = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Text          = PowerPlannerResources.GetString("String_SyncError"),
                        TextColor     = new UIColor(1, 1),
                        Font          = UIFont.PreferredTitle2,
                        TextAlignment = UITextAlignment.Center
                    };
                    viewCenterContainer.AddUnderVisiblity(labelSyncError, BindingHost, nameof(ViewModel.IsSyncing), invert: true);

                    var buttonTryAgain = PowerPlannerUIHelper.CreatePowerPlannerBlueButton("Try again");
                    buttonTryAgain.TranslatesAutoresizingMaskIntoConstraints = false;
                    buttonTryAgain.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.TryAgain(); }).Handler;
                    viewCenterContainer.AddUnderVisiblity(buttonTryAgain, BindingHost, nameof(ViewModel.IsSyncing), invert: true);

                    var labelErrorDescription = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        TextColor     = new UIColor(0.9f, 1),
                        Font          = UIFont.PreferredCaption1,
                        TextAlignment = UITextAlignment.Left,
                        Lines         = 0
                    };
                    BindingHost.SetLabelTextBinding(labelErrorDescription, nameof(ViewModel.Error));
                    viewCenterContainer.AddUnderVisiblity(labelErrorDescription, BindingHost, nameof(ViewModel.Error));
                }
                safeView.Add(viewCenterContainer);
                viewCenterContainer.StretchWidth(safeView, left: 16, right: 16);

                var viewLowerSpacer = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                safeView.Add(viewLowerSpacer);
                viewLowerSpacer.StretchWidth(safeView);

                safeView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-16-[viewTopSpacer(==viewLowerSpacer)][viewCenterContainer][viewLowerSpacer]-16-|", NSLayoutFormatOptions.AlignAllCenterX, null, new NSDictionary(
                                                                                "viewCenterContainer", viewCenterContainer,
                                                                                "viewTopSpacer", viewTopSpacer,
                                                                                "viewLowerSpacer", viewLowerSpacer)));

                var buttonSettings = new UIControl()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    var settingsImage = new UIImageView(UIImage.FromBundle("SettingsIcon").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate))
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        TintColor   = UIColor.White,
                        ContentMode = UIViewContentMode.ScaleAspectFit
                    };
                    buttonSettings.Add(settingsImage);
                    settingsImage.StretchHeight(buttonSettings, top: 4, bottom: 4);

                    var label = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Font      = UIFont.PreferredCaption1,
                        TextColor = UIColor.White,
                        Text      = PowerPlannerResources.GetString("MainMenuItem_Settings")
                    };
                    buttonSettings.Add(label);
                    label.StretchHeight(buttonSettings);

                    buttonSettings.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[image(22)]-8-[label]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                      "image", settingsImage,
                                                                                      "label", label));
                }
                BindingHost.SetVisibilityBinding(buttonSettings, nameof(ViewModel.IsSyncing), invert: true);
                safeView.Add(buttonSettings);

                buttonSettings.TouchUpInside += new WeakEventHandler(delegate { ViewModel.OpenSettings(asPopup: true); }).Handler;
                buttonSettings.PinToTop(safeView, top: UIDevice.CurrentDevice.CheckSystemVersion(11, 0) ? 12 : 28); // We do this comparison since on iOS 11 the safe view adds extra padding
                buttonSettings.PinToLeft(safeView, left: 12);
                buttonSettings.SetHeight(30);
            }

            base.OnViewModelLoadedOverride();
        }
Exemplo n.º 27
0
        public override void OnViewModelLoadedOverride()
        {
            // [viewTextContainer]
            // [viewButtons]
            var safeView = BareUISafeView.CreateAndAddTo(View);

            {
                var viewTopSpacer = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                safeView.Add(viewTopSpacer);
                viewTopSpacer.StretchWidth(safeView);

                var viewTextContainer = new UIStackView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false,
                    Axis    = UILayoutConstraintAxis.Vertical,
                    Spacing = 8
                };
                {
                    var labelTitle = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Text          = "Power Planner",
                        TextColor     = new UIColor(1, 1),
                        Font          = UIFont.PreferredTitle1,
                        TextAlignment = UITextAlignment.Center
                    };
                    viewTextContainer.AddArrangedSubview(labelTitle);
                    labelTitle.StretchWidth(viewTextContainer);

                    var labelSubtitle = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Text          = "The ultimate homework planner",
                        TextColor     = new UIColor(0.9f, 1),
                        Font          = UIFont.PreferredCaption1,
                        TextAlignment = UITextAlignment.Center
                    };
                    viewTextContainer.AddArrangedSubview(labelSubtitle);
                    labelSubtitle.StretchWidth(viewTextContainer);
                }
                safeView.Add(viewTextContainer);
                viewTextContainer.StretchWidth(safeView, left: 16, right: 16);

                var viewLowerSpacer = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                safeView.Add(viewLowerSpacer);
                viewLowerSpacer.StretchWidth(safeView);

                var viewButtons = new UIView()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    var buttonLogin = PowerPlannerUIHelper.CreatePowerPlannerBlueButton("Log In");
                    buttonLogin.TranslatesAutoresizingMaskIntoConstraints = false;
                    buttonLogin.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.Login(); }).Handler;
                    viewButtons.Add(buttonLogin);
                    buttonLogin.StretchHeight(viewButtons);

                    var buttonCreateAccount = PowerPlannerUIHelper.CreatePowerPlannerBlueButton("Create Account");
                    buttonCreateAccount.TranslatesAutoresizingMaskIntoConstraints = false;
                    buttonCreateAccount.TouchUpInside += new WeakEventHandler <EventArgs>(delegate { ViewModel.CreateAccount(); }).Handler;
                    viewButtons.Add(buttonCreateAccount);
                    buttonCreateAccount.StretchHeight(viewButtons);

                    viewButtons.AddConstraints(NSLayoutConstraint.FromVisualFormat($"H:|[buttonLogin(==buttonCreateAccount)]-8-[buttonCreateAccount]|", NSLayoutFormatOptions.DirectionLeadingToTrailing, null, new NSDictionary(
                                                                                       "buttonLogin", buttonLogin,
                                                                                       "buttonCreateAccount", buttonCreateAccount)));
                }
                safeView.Add(viewButtons);
                viewButtons.StretchWidth(safeView, left: 16, right: 16);

                safeView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"V:|-16-[viewTopSpacer(==viewLowerSpacer)][viewTextContainer][viewLowerSpacer]-16-[viewButtons]-16-|", NSLayoutFormatOptions.AlignAllCenterX, null, new NSDictionary(
                                                                                "viewTextContainer", viewTextContainer,
                                                                                "viewButtons", viewButtons,
                                                                                "viewTopSpacer", viewTopSpacer,
                                                                                "viewLowerSpacer", viewLowerSpacer)));

                var buttonSettings = new UIControl()
                {
                    TranslatesAutoresizingMaskIntoConstraints = false
                };
                {
                    var settingsImage = new UIImageView(UIImage.FromBundle("TabSettings").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate))
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        TintColor   = UIColor.White,
                        ContentMode = UIViewContentMode.ScaleAspectFit
                    };
                    buttonSettings.Add(settingsImage);
                    settingsImage.StretchHeight(buttonSettings, top: 4, bottom: 4);

                    var label = new UILabel()
                    {
                        TranslatesAutoresizingMaskIntoConstraints = false,
                        Font      = UIFont.PreferredCaption1,
                        TextColor = UIColor.White,
                        Text      = "About"
                    };
                    buttonSettings.Add(label);
                    label.StretchHeight(buttonSettings);

                    buttonSettings.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:|[image(22)]-8-[label]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                                      "image", settingsImage,
                                                                                      "label", label));
                }
                safeView.Add(buttonSettings);
                buttonSettings.TouchUpInside += new WeakEventHandler(delegate { OpenAboutPageAsPopup(); }).Handler;
                buttonSettings.PinToTop(safeView, top: UIDevice.CurrentDevice.CheckSystemVersion(11, 0) ? 12 : 28); // We do this comparison since on iOS 11 the safe view adds extra padding
                buttonSettings.PinToLeft(safeView, left: 12);
                buttonSettings.SetHeight(30);
            }

            base.OnViewModelLoadedOverride();
        }
Exemplo n.º 28
0
        private void CreateView()
        {
            //    SelectionStyle = UITableViewCellSelectionStyle.Gray;

            _pm = new UIStackView
            {
                Axis         = UILayoutConstraintAxis.Horizontal,
                Distribution = UIStackViewDistribution.Fill,
                LayoutMarginsRelativeArrangement = true,
                LayoutMargins = new UIEdgeInsets(10, 20, 10, 10),

                Spacing = 5
            };

            ContentView.AddSubview(_pm);

            NameLabel = new UILabel
            {
                Lines           = 0,
                LineBreakMode   = UILineBreakMode.WordWrap,
                Font            = UIFont.PreferredFootnote, //  PreferredSubheadline,
                BackgroundColor = UIColor.Clear
            };

            //    headingLabel.SetContentHuggingPriority(100, UILayoutConstraintAxis.Horizontal);
            NameLabel.TranslatesAutoresizingMaskIntoConstraints = false;

            var margins    = ContentView.SafeAreaLayoutGuide;
            var contraints = new[]
            {
                NameLabel.WidthAnchor.ConstraintEqualTo(130)
                //   imageView.HeightAnchor.ConstraintEqualTo(30)
            };

            NSLayoutConstraint.ActivateConstraints(contraints);

            CheckImage = new UIImageView
            {
            };


            //  CheckImage.SetContentHuggingPriority(0, UILayoutConstraintAxis.Horizontal);
            CheckImage.TranslatesAutoresizingMaskIntoConstraints = false;

            var contraints3 = new[]
            {
                CheckImage.WidthAnchor.ConstraintEqualTo(24),
                CheckImage.HeightAnchor.ConstraintEqualTo(24)
            };

            NSLayoutConstraint.ActivateConstraints(contraints3);

            _pm.TranslatesAutoresizingMaskIntoConstraints = false;

            var margins2    = ContentView.SafeAreaLayoutGuide;
            var contraints2 = new[]
            {
                _pm.LeadingAnchor.ConstraintEqualTo(margins2.LeadingAnchor),
                _pm.TrailingAnchor.ConstraintEqualTo(margins2.TrailingAnchor),
                _pm.BottomAnchor.ConstraintEqualTo(margins2.BottomAnchor),
                _pm.TopAnchor.ConstraintEqualTo(margins2.TopAnchor)
            };

            NSLayoutConstraint.ActivateConstraints(contraints2);

            _pm.AddArrangedSubview(NameLabel);
            _pm.AddArrangedSubview(CheckImage);
        }
        public override void LoadView()
        {
            // Create the views.
            View = new UIView {
                BackgroundColor = ApplicationTheme.BackgroundColor
            };

            _myMapView = new MapView();
            _myMapView.TranslatesAutoresizingMaskIntoConstraints = false;

            _topView = new UIView
            {
                BackgroundColor = ApplicationTheme.BackgroundColor,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _defaultView = new UIStackView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 8,
                LayoutMarginsRelativeArrangement = true,
                Alignment     = UIStackViewAlignment.Top,
                LayoutMargins = new UIEdgeInsets(8, 8, 8, 8),
                Axis          = UILayoutConstraintAxis.Vertical,
            };

            UILabel instructions = new UILabel {
                TranslatesAutoresizingMaskIntoConstraints = false, Text = "Tap to select a feature."
            };

            _versionLabel = new UILabel {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            _versionButton = new UIButton {
                TranslatesAutoresizingMaskIntoConstraints = false, Enabled = false
            };
            _versionButton.SetTitle("Create version", UIControlState.Normal);
            _versionButton.SetTitleColor(View.TintColor, UIControlState.Normal);

            _defaultView.AddArrangedSubview(instructions);
            _defaultView.AddArrangedSubview(_versionLabel);
            _defaultView.AddArrangedSubview(_versionButton);

            _versionView = new UIStackView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 8,
                LayoutMarginsRelativeArrangement = true,
                Alignment     = UIStackViewAlignment.Top,
                LayoutMargins = new UIEdgeInsets(8, 8, 8, 8),
                Axis          = UILayoutConstraintAxis.Vertical,
                Hidden        = true,
            };

            _nameField = new UITextField {
                Placeholder = "Name",
            };

            _proButton = new UIButton {
            };
            _proButton.SetTitle("Protection:", UIControlState.Normal);
            _proButton.SetTitleColor(View.TintColor, UIControlState.Normal);

            _descriptionField = new UITextField {
                Placeholder = "Description"
            };

            _confirmButton = new UIButton {
            };
            _confirmButton.SetTitle("Confirm", UIControlState.Normal);
            _confirmButton.SetTitleColor(View.TintColor, UIControlState.Normal);

            _cancelButton = new UIButton {
            };
            _cancelButton.SetTitle("Cancel", UIControlState.Normal);
            _cancelButton.SetTitleColor(UIColor.Red, UIControlState.Normal);

            _versionView.AddArrangedSubview(_nameField);
            _versionView.AddArrangedSubview(_proButton);
            _versionView.AddArrangedSubview(_descriptionField);
            _versionView.AddArrangedSubview(getRowStackView(new UIView[] { _confirmButton, _cancelButton }));

            _damageView = new UIStackView
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Spacing = 8,
                LayoutMarginsRelativeArrangement = true,
                Alignment     = UIStackViewAlignment.Top,
                LayoutMargins = new UIEdgeInsets(8, 8, 8, 8),
                Axis          = UILayoutConstraintAxis.Vertical,
                Hidden        = true,
            };

            _moveText = new UILabel {
                TranslatesAutoresizingMaskIntoConstraints = false, Text = "Tap to move feature."
            };

            _damageButton = new UIButton {
            };
            _damageButton.SetTitle("Damage:", UIControlState.Normal);
            _damageButton.SetTitleColor(View.TintColor, UIControlState.Normal);

            _closeButton = new UIButton {
            };
            _closeButton.SetTitle("Close", UIControlState.Normal);
            _closeButton.SetTitleColor(UIColor.Red, UIControlState.Normal);

            _damageView.AddArrangedSubview(_moveText);
            _damageView.AddArrangedSubview(_damageButton);
            _damageView.AddArrangedSubview(_closeButton);

            _topView.AddSubviews(_defaultView, _versionView, _damageView);

            // Add the views.
            View.AddSubviews(_myMapView, _topView);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                _topView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _topView.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor),
                _topView.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor),
                _topView.HeightAnchor.ConstraintEqualTo(150),

                _myMapView.TopAnchor.ConstraintEqualTo(_topView.BottomAnchor),
                _myMapView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor),
                _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
            });
        }
        public override void LoadView()
        {
            // Create the views.
            View = new UIView {
                BackgroundColor = ApplicationTheme.BackgroundColor
            };

            UIToolbar topToolbar = new UIToolbar {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _myMapView = new MapView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            _timeLabel = new UILabel();

            _timeSlider = new UISlider
            {
                MinValue = 0,
                MaxValue = 1,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            UIToolbar bottomToolbar = new UIToolbar();

            bottomToolbar.TranslatesAutoresizingMaskIntoConstraints = false;

            bottomToolbar.Items = new[]
            {
                new UIBarButtonItem {
                    CustomView = _timeSlider, Width = 100
                },
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem {
                    CustomView = _timeLabel
                },
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
            };

            UIStackView legendView = new UIStackView();

            legendView.TranslatesAutoresizingMaskIntoConstraints = false;
            legendView.Axis    = UILayoutConstraintAxis.Horizontal;
            legendView.Spacing = 8;

            UIView redIcon = new UIView();

            redIcon.TranslatesAutoresizingMaskIntoConstraints = false;
            redIcon.BackgroundColor = UIColor.Red;
            redIcon.WidthAnchor.ConstraintEqualTo(16).Active  = true;
            redIcon.HeightAnchor.ConstraintEqualTo(16).Active = true;
            redIcon.ClipsToBounds      = true;
            redIcon.Layer.CornerRadius = 8;
            legendView.AddArrangedSubview(redIcon);

            UILabel _redLabel = new UILabel
            {
                Text      = "Offset 10 days",
                TextColor = UIColor.Red,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            legendView.AddArrangedSubview(_redLabel);

            UIView spacer = new UIView();

            spacer.TranslatesAutoresizingMaskIntoConstraints = false;
            spacer.SetContentCompressionResistancePriority((float)UILayoutPriority.DefaultLow, UILayoutConstraintAxis.Horizontal);
            legendView.AddArrangedSubview(spacer);

            UIView blueIcon = new UIView();

            blueIcon.BackgroundColor = UIColor.Blue;
            blueIcon.TranslatesAutoresizingMaskIntoConstraints = false;
            blueIcon.WidthAnchor.ConstraintEqualTo(16).Active  = true;
            blueIcon.HeightAnchor.ConstraintEqualTo(16).Active = true;
            blueIcon.ClipsToBounds      = true;
            blueIcon.Layer.CornerRadius = 8;
            legendView.AddArrangedSubview(blueIcon);

            UILabel _blueLabel = new UILabel
            {
                Text      = "No offset",
                TextColor = UIColor.Blue,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            legendView.AddArrangedSubview(_blueLabel);

            // Add the views.
            View.AddSubviews(topToolbar, _myMapView, bottomToolbar);
            topToolbar.AddSubview(legendView);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                topToolbar.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                topToolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                topToolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),

                _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _myMapView.TopAnchor.ConstraintEqualTo(topToolbar.BottomAnchor),
                _myMapView.BottomAnchor.ConstraintEqualTo(bottomToolbar.TopAnchor),

                bottomToolbar.LeadingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.LeadingAnchor),
                bottomToolbar.TrailingAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TrailingAnchor),
                bottomToolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),

                legendView.LeftAnchor.ConstraintEqualTo(topToolbar.SafeAreaLayoutGuide.LeftAnchor, 8),
                legendView.RightAnchor.ConstraintEqualTo(topToolbar.SafeAreaLayoutGuide.RightAnchor, -8),
                legendView.TopAnchor.ConstraintEqualTo(topToolbar.SafeAreaLayoutGuide.TopAnchor, 8),
                legendView.BottomAnchor.ConstraintEqualTo(topToolbar.SafeAreaLayoutGuide.BottomAnchor, -8),

                redIcon.CenterYAnchor.ConstraintEqualTo(blueIcon.CenterYAnchor),
                blueIcon.CenterYAnchor.ConstraintEqualTo(topToolbar.CenterYAnchor),

                _timeLabel.WidthAnchor.ConstraintEqualTo(150),
                _timeSlider.WidthAnchor.ConstraintEqualTo(600),
            });
        }
Exemplo n.º 31
0
        public override void LoadView()
        {
            // Create and add the container views.
            View = new UIView();

            UIScrollView scrollView = new UIScrollView();

            scrollView.TranslatesAutoresizingMaskIntoConstraints = false;

            View.AddSubviews(scrollView);

            scrollView.TopAnchor.ConstraintEqualTo(View.TopAnchor).Active           = true;
            scrollView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active   = true;
            scrollView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true;
            scrollView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor).Active     = true;

            UIStackView formContainer = new UIStackView();

            formContainer.TranslatesAutoresizingMaskIntoConstraints = false;
            formContainer.Spacing = 8;
            formContainer.LayoutMarginsRelativeArrangement = true;
            formContainer.Alignment     = UIStackViewAlignment.Fill;
            formContainer.LayoutMargins = new UIEdgeInsets(8, 8, 8, 8);
            formContainer.Axis          = UILayoutConstraintAxis.Vertical;
            formContainer.WidthAnchor.ConstraintEqualTo(300).Active = true;

            // Create and add each row.
            UILabel analysisLabel = new UILabel();

            analysisLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            analysisLabel.Text           = "Analysis overlay";
            _analysisVisibilitySwitch    = new UISwitch();
            _analysisVisibilitySwitch.On = _viewshed.IsVisible;
            _analysisVisibilitySwitch.TranslatesAutoresizingMaskIntoConstraints = false;
            formContainer.AddArrangedSubview(getRowStackView(new UIView[] { analysisLabel, _analysisVisibilitySwitch }));

            UILabel frustumLabel = new UILabel();

            frustumLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            frustumLabel.Text           = "Frustum";
            _frustumVisibilitySwitch    = new UISwitch();
            _frustumVisibilitySwitch.On = _viewshed.IsFrustumOutlineVisible;
            _frustumVisibilitySwitch.TranslatesAutoresizingMaskIntoConstraints = false;
            formContainer.AddArrangedSubview(getRowStackView(new UIView[] { frustumLabel, _frustumVisibilitySwitch }));

            UILabel headingLabel = new UILabel();

            headingLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            headingLabel.Text = "Heading";
            _headingSlider    = new UISlider {
                MinValue = 0, MaxValue = 360, Value = (float)_viewshed.Heading
            };
            _headingSlider.TranslatesAutoresizingMaskIntoConstraints = false;
            formContainer.AddArrangedSubview(getRowStackView(new UIView[] { headingLabel, _headingSlider }));

            UILabel pitchLabel = new UILabel();

            pitchLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            pitchLabel.Text = "pitch";
            _pitchSlider    = new UISlider {
                MinValue = 0, MaxValue = 180, Value = (float)_viewshed.Pitch
            };
            _pitchSlider.TranslatesAutoresizingMaskIntoConstraints = false;
            formContainer.AddArrangedSubview(getRowStackView(new UIView[] { pitchLabel, _pitchSlider }));

            UILabel horizontalLabel = new UILabel();

            horizontalLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            horizontalLabel.Text   = "horizontal";
            _horizontalAngleSlider = new UISlider {
                MinValue = 1, MaxValue = 120, Value = (float)_viewshed.HorizontalAngle
            };
            _horizontalAngleSlider.TranslatesAutoresizingMaskIntoConstraints = false;
            formContainer.AddArrangedSubview(getRowStackView(new UIView[] { horizontalLabel, _horizontalAngleSlider }));

            UILabel verticalLabel = new UILabel();

            verticalLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            verticalLabel.Text   = "vertical";
            _verticalAngleSlider = new UISlider {
                MinValue = 1, MaxValue = 120, Value = (float)_viewshed.VerticalAngle
            };
            _verticalAngleSlider.TranslatesAutoresizingMaskIntoConstraints = false;
            formContainer.AddArrangedSubview(getRowStackView(new UIView[] { verticalLabel, _verticalAngleSlider }));

            UILabel minLabel = new UILabel();

            minLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            minLabel.Text          = "min";
            _minimumDistanceSlider = new UISlider {
                MinValue = 11, MaxValue = 8999, Value = (float)_viewshed.MinDistance
            };
            _minimumDistanceSlider.TranslatesAutoresizingMaskIntoConstraints = false;
            formContainer.AddArrangedSubview(getRowStackView(new UIView[] { minLabel, _minimumDistanceSlider }));

            UILabel maxLabel = new UILabel();

            maxLabel.TranslatesAutoresizingMaskIntoConstraints = false;
            maxLabel.Text          = "max";
            _maximumDistanceSlider = new UISlider {
                MinValue = 0, MaxValue = 9999, Value = (float)_viewshed.MaxDistance
            };
            _maximumDistanceSlider.TranslatesAutoresizingMaskIntoConstraints = false;
            formContainer.AddArrangedSubview(getRowStackView(new UIView[] { maxLabel, _maximumDistanceSlider }));

            // Subscribe to events.
            _headingSlider.ValueChanged            += HandleSettingsChange;
            _pitchSlider.ValueChanged              += HandleSettingsChange;
            _horizontalAngleSlider.ValueChanged    += HandleSettingsChange;
            _verticalAngleSlider.ValueChanged      += HandleSettingsChange;
            _minimumDistanceSlider.ValueChanged    += HandleSettingsChange;
            _maximumDistanceSlider.ValueChanged    += HandleSettingsChange;
            _analysisVisibilitySwitch.ValueChanged += HandleSettingsChange;
            _frustumVisibilitySwitch.ValueChanged  += HandleSettingsChange;

            // Lay out container and scroll view.
            scrollView.AddSubview(formContainer);

            formContainer.TopAnchor.ConstraintEqualTo(scrollView.TopAnchor).Active           = true;
            formContainer.LeadingAnchor.ConstraintEqualTo(scrollView.LeadingAnchor).Active   = true;
            formContainer.TrailingAnchor.ConstraintEqualTo(scrollView.TrailingAnchor).Active = true;
            formContainer.BottomAnchor.ConstraintEqualTo(scrollView.BottomAnchor).Active     = true;
        }
Exemplo n.º 32
0
        public override void LoadView()
        {
            // Create the views.
            View = new UIView {
                BackgroundColor = UIColor.White
            };

            _staticMapView = new MapView();
            _staticMapView.TranslatesAutoresizingMaskIntoConstraints = false;

            _dynamicMapView = new MapView();
            _dynamicMapView.TranslatesAutoresizingMaskIntoConstraints = false;

            _stackView = new UIStackView(new UIView[] { _staticMapView, _dynamicMapView });
            _stackView.TranslatesAutoresizingMaskIntoConstraints = false;
            _stackView.Distribution = UIStackViewDistribution.FillEqually;

            UIToolbar toolbar = new UIToolbar();

            toolbar.TranslatesAutoresizingMaskIntoConstraints = false;
            toolbar.Items = new[]
            {
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
                new UIBarButtonItem("Zoom", UIBarButtonItemStyle.Plain, OnZoomClick),
                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace)
            };

            UILabel staticLabel = new UILabel
            {
                Text            = "Static",
                BackgroundColor = UIColor.FromWhiteAlpha(0f, .6f),
                TextColor       = UIColor.White,
                TextAlignment   = UITextAlignment.Center,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            UILabel dynamicLabel = new UILabel()
            {
                Text            = "Dynamic",
                BackgroundColor = UIColor.FromWhiteAlpha(0f, .6f),
                TextColor       = UIColor.White,
                TextAlignment   = UITextAlignment.Center,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            // Add the views.
            View.AddSubviews(_stackView, toolbar, staticLabel, dynamicLabel);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[]
            {
                _stackView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _stackView.BottomAnchor.ConstraintEqualTo(toolbar.TopAnchor),
                _stackView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _stackView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),

                toolbar.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                toolbar.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                toolbar.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),

                staticLabel.TopAnchor.ConstraintEqualTo(_staticMapView.TopAnchor),
                staticLabel.HeightAnchor.ConstraintEqualTo(40),
                staticLabel.LeadingAnchor.ConstraintEqualTo(_staticMapView.LeadingAnchor),
                staticLabel.TrailingAnchor.ConstraintEqualTo(_staticMapView.TrailingAnchor),

                dynamicLabel.TopAnchor.ConstraintEqualTo(_dynamicMapView.TopAnchor),
                dynamicLabel.HeightAnchor.ConstraintEqualTo(40),
                dynamicLabel.LeadingAnchor.ConstraintEqualTo(_dynamicMapView.LeadingAnchor),
                dynamicLabel.TrailingAnchor.ConstraintEqualTo(_dynamicMapView.TrailingAnchor)
            });
        }
Exemplo n.º 33
0
        public override void LoadView()
        {
            // Create the views.
            View = new UIView()
            {
                BackgroundColor = UIColor.White
            };

            _myMapView = new MapView();
            _myMapView.TranslatesAutoresizingMaskIntoConstraints = false;

            _openSwitch = new UISwitch()
            {
                Enabled = false
            };
            _openSwitch.On = true;
            _closedSwitch  = new UISwitch()
            {
                Enabled = false
            };
            _closedSwitch.On = true;

            _openLabel   = new UILabel();
            _closedLabel = new UILabel();

            UIStackView openRow = new UIStackView(new UIView[] { _openSwitch, _openLabel })
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                LayoutMarginsRelativeArrangement          = true,
                LayoutMargins = new UIEdgeInsets(5, 5, 5, 5),
                Spacing       = 8,
                Axis          = UILayoutConstraintAxis.Horizontal,
                Distribution  = UIStackViewDistribution.Fill
            };

            UIStackView closedRow = new UIStackView(new UIView[] { _closedSwitch, _closedLabel })
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                LayoutMarginsRelativeArrangement          = true,
                LayoutMargins = new UIEdgeInsets(5, 5, 5, 5),
                Spacing       = 8,
                Axis          = UILayoutConstraintAxis.Horizontal,
                Distribution  = UIStackViewDistribution.Fill
            };

            _scaleLabel = new UILabel
            {
                Text = "Current map scale: 1:",
                AdjustsFontSizeToFitWidth = true,
                TextAlignment             = UITextAlignment.Center,
                BackgroundColor           = UIColor.FromWhiteAlpha(0, .6f),
                TextColor = UIColor.White,
                Lines     = 1,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            // Add the views.
            View.AddSubviews(_myMapView, openRow, closedRow, _scaleLabel);

            // Lay out the views.
            NSLayoutConstraint.ActivateConstraints(new[] {
                _myMapView.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _myMapView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _myMapView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _myMapView.BottomAnchor.ConstraintEqualTo(openRow.TopAnchor),

                openRow.BottomAnchor.ConstraintEqualTo(closedRow.TopAnchor),
                openRow.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                openRow.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),

                closedRow.BottomAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.BottomAnchor),
                closedRow.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                closedRow.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),

                _scaleLabel.TopAnchor.ConstraintEqualTo(View.SafeAreaLayoutGuide.TopAnchor),
                _scaleLabel.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor),
                _scaleLabel.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor),
                _scaleLabel.HeightAnchor.ConstraintEqualTo(40)
            });
        }
Exemplo n.º 34
0
        protected override void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (Element != null)
                {
                    Element.OpenRequested  -= OnOpenRequested;
                    Element.CloseRequested -= OnCloseRequested;
                }

                if (_scrollParent != null)
                {
                    if (_scrollParent is ScrollView scrollView)
                    {
                        scrollView.Scrolled -= OnParentScrolled;
                    }

                    if (_scrollParent is ListView listView)
                    {
                        listView.Scrolled -= OnParentScrolled;
                    }

                    if (_scrollParent is CollectionView collectionView)
                    {
                        collectionView.Scrolled -= OnParentScrolled;
                    }
                }

                if (_tapGestureRecognizer != null)
                {
                    Control.RemoveGestureRecognizer(_tapGestureRecognizer);
                    _tapGestureRecognizer.Dispose();
                    _tapGestureRecognizer = null;
                }

                if (_panGestureRecognizer != null)
                {
                    Control.RemoveGestureRecognizer(_panGestureRecognizer);
                    _panGestureRecognizer.Dispose();
                    _panGestureRecognizer = null;
                }

                if (_contentView != null)
                {
                    _contentView.Dispose();
                    _contentView = null;
                }

                if (_actionView != null)
                {
                    _actionView.Dispose();
                    _actionView = null;
                }

                if (_swipeItemsRect != null)
                {
                    _swipeItemsRect.Clear();
                    _swipeItemsRect = null;
                }
            }

            _isDisposed = true;

            base.Dispose(disposing);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();
            //scrollView = stackView.Superview as UIScrollView;
            //scrollView.KeyboardDismissMode = UIScrollViewKeyboardDismissMode.OnDrag;
            //scrollView.ScrollEnabled = true;
            // Set up Navigation Bar
            var saveButton = new UIBarButtonItem (UIBarButtonSystemItem.Save, save);
            var cancelButton = new UIBarButtonItem (UIBarButtonSystemItem.Cancel, cancel);
            NavigationItem.Title = "New Medication:";
            NavigationItem.RightBarButtonItem = saveButton;
            NavigationItem.HidesBackButton = true;
            NavigationItem.LeftBarButtonItem = cancelButton;

            //NSNotificationCenter.DefaultCenter.AddObserver (this, new ObjCRuntime.Selector("keyboardDidAppear:"), UIKeyboard.DidShowNotification, null);
            //NSNotificationCenter.DefaultCenter.AddObserver (this, new ObjCRuntime.Selector ("keyboardWillDissapear:"), UIKeyboard.WillHideNotification, null);

            // Set up the date formatter
            dateFormat = new NSDateFormatter();
            dateFormat.DateStyle = NSDateFormatterStyle.None;
            dateFormat.TimeStyle = NSDateFormatterStyle.Short;

            // Set up new pet form
            nameField = new UITextField();
            nameField.Text = "Medication Name";
            nameField.BorderStyle = UITextBorderStyle.RoundedRect;
            nameField.ReturnKeyType = UIReturnKeyType.Done;

            medTypeLabel = new UILabel ();
            medTypeLabel.Text = "Type of Medication";
            medTypeButton = new UIButton (UIButtonType.RoundedRect);
            medTypeButton.AddTarget (editMedType, UIControlEvent.TouchUpInside);
            medTypeButton.SetTitle ("Pill", UIControlState.Normal);
            medTypeButton.TitleLabel.Font = medTypeButton.TitleLabel.Font.WithSize (medTypeLabel.Font.PointSize);
            medTypePicker = new UIPickerView ();
            medTypePicker.Delegate = new MedTypePickerDelegate (this);
            medTypePicker.DataSource = new MedTypePickerDataSource ();

            freqLabel = new UILabel ();
            freqLabel.Text = "Frequency";
            freqTextField = new UITextField ();
            freqTextField.Text = "1";
            freqTextField.KeyboardType = UIKeyboardType.NumberPad;
            freqTextField.BorderStyle = UITextBorderStyle.RoundedRect;
            freqTextField.Enabled = false;
            freqTextField.AddTarget (freqTextFieldChanged, UIControlEvent.EditingDidEnd | UIControlEvent.EditingDidEndOnExit);
            freqStepper = new UIStepper ();
            freqStepper.Value = 1;
            freqStepper.MinimumValue = 1;
            freqStepper.Enabled = false;
            freqStepper.AddTarget (freqStepperIncremented, UIControlEvent.ValueChanged);
            UIStackView freqStackView = new UIStackView (new UIView[] { freqTextField, freqStepper });
            freqStackView.Spacing = 8;
            freqStackView.Axis = UILayoutConstraintAxis.Horizontal;
            freqButton = new UIButton (UIButtonType.RoundedRect);
            freqButton.SetTitle ("Daily", UIControlState.Normal);
            freqButton.TitleLabel.Font = freqButton.TitleLabel.Font.WithSize (medTypeLabel.Font.PointSize);
            freqButton.AddTarget (editFrequency, UIControlEvent.TouchUpInside);
            freqPicker = new UIPickerView ();
            freqPicker.Delegate = new MedFreqPickerDelegate (this);
            freqPicker.DataSource = new MedFreqPickerDataSource ();

            timePicker = new UIDatePicker ();
            gregorian = new NSCalendar (NSCalendarType.Gregorian);
            timePicker.Date = gregorian.DateBySettingsHour (9, 0, 0, NSDate.Now, NSCalendarOptions.MatchNextTime);
            timePicker.Mode = UIDatePickerMode.Time;
            timePicker.AddTarget (timePickerChanged, UIControlEvent.AllEvents);

            UILabel timeLabel = new UILabel ();
            timeLabel.Text = "Time";
            timeButtons = new UIButton[1];
            timeDates = new NSDate[1];
            timeDates [0] = gregorian.DateBySettingsHour (9, 0, 0, NSDate.Now, NSCalendarOptions.MatchNextTime);
            timeButtons [0] = new UIButton (UIButtonType.RoundedRect);
            timeButtons [0].SetTitle ("9:00 AM", UIControlState.Normal);
            timeButtons [0].AddTarget (openTimePicker, UIControlEvent.TouchUpInside);
            timeStack = new UIStackView ();
            timeStack.Alignment = UIStackViewAlignment.Leading;
            timeStack.Distribution = UIStackViewDistribution.FillProportionally;
            timeStack.Spacing = 5;
            timeStack.Axis = UILayoutConstraintAxis.Vertical;
            timeStack.AddArrangedSubview (timeLabel);
            foreach (var button in timeButtons) {
                timeStack.AddArrangedSubview (button);
            }
            timeStack.AddArrangedSubview (timePicker);
            timePicker.Hidden = true;

            dayLabel = new UILabel ();
            dayLabel.Text = "Day";
            dayLabel.Hidden = true;
            dayButton = new UIButton (UIButtonType.RoundedRect);
            var day = gregorian.GetComponentFromDate (NSCalendarUnit.Weekday, NSDate.Now);
            dayButton.SetTitle (gregorian.WeekdaySymbols[day], UIControlState.Normal);
            dayButton.AddTarget (openDayPicker, UIControlEvent.TouchUpInside);
            dayButton.Hidden = true;
            dayPicker = new UIDatePicker ();
            dayPicker.Mode = UIDatePickerMode.Date;
            dayPicker.MinimumDate = NSDate.Now;
            dayPicker.MaximumDate = NSDate.Now.AddSeconds (604800);
            dayPicker.AddTarget (dayPickerChanged, UIControlEvent.AllEvents);
            dayPicker.Hidden = true;

            prescriptionLengthLabel = new UILabel ();
            prescriptionLengthLabel.Text = "Prescription Length";
            prescriptionLengthTextField = new UITextField ();
            prescriptionLengthTextField.Text = "20";
            prescriptionLengthTextField.AddTarget (prescriptionTextFieldChanged, UIControlEvent.EditingDidEnd | UIControlEvent.EditingDidEndOnExit);
            prescriptionLengthTextField.KeyboardType = UIKeyboardType.NumberPad;
            prescriptionLengthTextField.BorderStyle = UITextBorderStyle.RoundedRect;
            prescriptionLengthStepper = new UIStepper ();
            prescriptionLengthStepper.Value = 20;
            prescriptionLengthStepper.MinimumValue = 1;
            prescriptionLengthStepper.AddTarget (prescriptionStepperIncremented, UIControlEvent.ValueChanged);
            prescriptionDayLabel = new UILabel ();
            prescriptionDayLabel.Text = "Days";
            UIStackView prescriptionStackView = new UIStackView (new UIView[] {
                prescriptionLengthTextField,
                prescriptionLengthStepper,
                prescriptionDayLabel
            });
            prescriptionStackView.Axis = UILayoutConstraintAxis.Horizontal;
            prescriptionStackView.Alignment = UIStackViewAlignment.Leading;
            prescriptionStackView.Distribution = UIStackViewDistribution.FillProportionally;
            prescriptionStackView.Spacing = 5;

            refillsLabel = new UILabel ();
            refillsLabel.Text = "Refills Remaining";
            refillsTextField = new UITextField ();
            refillsTextField.Text = "0";
            refillsTextField.KeyboardType = UIKeyboardType.NumberPad;
            refillsTextField.BorderStyle = UITextBorderStyle.RoundedRect;
            refillsTextField.AddTarget (refillsTextFieldChanged, UIControlEvent.EditingDidEnd | UIControlEvent.EditingDidEndOnExit);
            refillsStepper = new UIStepper ();
            refillsStepper.Value = 0;
            refillsStepper.MinimumValue = 0;
            refillsStepper.AddTarget (refillsStepperIncremented, UIControlEvent.ValueChanged);
            UIStackView refillsStackView = new UIStackView (new UIView[] { refillsTextField, refillsStepper });
            refillsStackView.Spacing = 5;
            refillsStackView.Alignment = UIStackViewAlignment.Leading;
            refillsStackView.Distribution = UIStackViewDistribution.FillProportionally;
            refillsStackView.Axis = UILayoutConstraintAxis.Horizontal;

            pharmacyTextView = new UITextView ();
            pharmacyTextView.Text = "Pharmacy Address";
            pharmacyTextView.ScrollEnabled = false;
            pharmacyTextView.BackgroundColor = UIColor.LightGray;
            pharmacyTextField = new UITextField ();
            pharmacyTextField.Text = "Pharmacy Address";
            pharmacyTextField.BorderStyle = UITextBorderStyle.RoundedRect;

            // Sets up the stackview
            stackView.Spacing = 5;
            stackView.Alignment = UIStackViewAlignment.Leading;
            stackView.Distribution = UIStackViewDistribution.EqualSpacing;
            stackView.AddArrangedSubview (nameField);
            UIView spaceView = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER));
            spaceView.AddConstraint (NSLayoutConstraint.Create (spaceView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER));
            stackView.AddArrangedSubview (spaceView);
            stackView.AddArrangedSubview (medTypeLabel);
            stackView.AddArrangedSubview (medTypeButton);
            stackView.AddArrangedSubview (medTypePicker);
            medTypePicker.Hidden = true;
            UIView spaceView2 = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER));
            spaceView2.AddConstraint (NSLayoutConstraint.Create (spaceView2, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER));
            stackView.AddArrangedSubview (spaceView2);
            stackView.AddArrangedSubview (freqLabel);
            stackView.AddArrangedSubview (freqStackView);
            stackView.AddArrangedSubview (freqButton);
            stackView.AddArrangedSubview (freqPicker);
            freqPicker.Hidden = true;
            UIView spaceView3 = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER));
            spaceView3.AddConstraint (NSLayoutConstraint.Create (spaceView3, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER));
            stackView.AddArrangedSubview (spaceView3);
            stackView.AddArrangedSubview (timeStack);
            stackView.AddArrangedSubview (dayLabel);
            stackView.AddArrangedSubview (dayButton);
            stackView.AddArrangedSubview (dayPicker);
            UIView spaceView4 = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER));
            spaceView4.AddConstraint (NSLayoutConstraint.Create (spaceView4, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER));
            stackView.AddArrangedSubview (spaceView4);
            stackView.AddArrangedSubview (prescriptionLengthLabel);
            stackView.AddArrangedSubview (prescriptionStackView);
            UIView spaceView5 = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER));
            spaceView5.AddConstraint (NSLayoutConstraint.Create (spaceView5, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER));
            stackView.AddArrangedSubview (spaceView5);
            stackView.AddArrangedSubview (refillsLabel);
            stackView.AddArrangedSubview (refillsStackView);
            UIView spaceView6 = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER));
            spaceView6.AddConstraint (NSLayoutConstraint.Create (spaceView6, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER));
            stackView.AddArrangedSubview (spaceView6);
            stackView.AddArrangedSubview (pharmacyTextField);
            UIView spaceView7 = new UIView (CoreGraphics.CGRect.FromLTRB (0, 0, 50, SECTION_SPACER));
            spaceView7.AddConstraint (NSLayoutConstraint.Create (spaceView7, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, SECTION_SPACER));
            stackView.AddArrangedSubview (spaceView7);
        }