Esempio n. 1
0
		public override void ViewDidLoad()
        {
			base.ViewDidLoad();
			
			AppDelegate.NavigationBar.SetBackButtonOn(this);
			
			// Initialize the alternate list selector
			_listView = new SeriesListViewController(this);
			_listView.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
			_listView.View.Frame = new RectangleF(0, 0, View.Frame.Width, View.Frame.Height);
						
			// Initialize the art gallery (already in background)
			_galleryView = new SeriesGalleryViewController(this, _listView);
			_galleryView.View.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth;
			_galleryView.View.Frame = new RectangleF(0, 0, View.Frame.Width, View.Frame.Height);		
						
			// http://stackoverflow.com/questions/1718495/why-does-viewdidappear-not-get-triggered
			this.View.AddSubview(AppGlobal.CollectionsViewInListMode ? _listView.View : _galleryView.View);
									
			// http://www.grokkingcocoa.com/a-simple-way-to-animate-a-u.html
			// http://ykyuen.wordpress.com/2010/06/11/iphone-adding-image-to-uibarbuttonitem/
			var listViewImage = UIImage.FromBundle("Images/gallery/listView.png");
			var listViewImageHighlighted = UIImage.FromBundle("Images/gallery/listViewHighlighted.png");
						
			_buttonFrame = new RectangleF(0, 0, 29, 30);			
			_buttonListThumb = new UIImageView(listViewImage);
			listViewImage.Dispose();
			_buttonListThumb.Frame = _buttonFrame;
			_buttonListThumb.Hidden = AppGlobal.CollectionsViewInListMode;
			
			var buttonListHighlight = new UIImageView(listViewImageHighlighted);
			listViewImageHighlighted.Dispose();
			buttonListHighlight.Frame = _buttonFrame;			
			
			// Build a thumbnail button for the selected page's piece
			// TODO duplicate with code to select a piece in the list view
			// TODO shouldn't have to size something from a factory method!
			var thumb0 = ImageFactory.LoadRoundedThumbnail(_series.Pieces[_page]);
			var thumb1 = ImageHelper.ImageToFitSize(thumb0, _listViewImageSize);
			thumb0.Dispose();
			_buttonGalleryThumb = new UIImageView(thumb1);
			thumb1.Dispose();
			
			_buttonGalleryThumb.Hidden = !AppGlobal.CollectionsViewInListMode;
			_buttonGalleryThumb.Frame = _buttonFrame;
			
			// Wire up the flip button
			_buttonInner = UIButton.FromType(UIButtonType.Custom);
			_buttonInner.UserInteractionEnabled = true;
			_buttonInner.Bounds = _buttonListThumb.Bounds;
			_buttonInner.AddSubview(_buttonListThumb);			
			_buttonInner.AddSubview(_buttonGalleryThumb);
			_buttonInner.AddTarget(delegate { 
				_buttonInner.InsertSubviewAbove(_buttonListThumb, buttonListHighlight);
				buttonListHighlight.RemoveFromSuperview();
				Flip();
			}, UIControlEvent.TouchUpInside);
			_buttonInner.AddTarget(delegate { 
				_buttonInner.InsertSubviewAbove(_buttonListThumb, buttonListHighlight);
				buttonListHighlight.RemoveFromSuperview();
				Flip();
			}, UIControlEvent.TouchUpOutside);
			_buttonInner.AddTarget(delegate { 
				_buttonInner.InsertSubviewAbove(buttonListHighlight, _buttonListThumb);
				_buttonListThumb.RemoveFromSuperview();
			}, UIControlEvent.TouchDown);
			
			// Wire up the series info button
			var info = UIButton.FromType(UIButtonType.InfoLight);
			info.UserInteractionEnabled = true;
			info.AddTarget((s, a)=> { ShowSeriesDetails(); }, UIControlEvent.TouchUpInside);
			
			_infoButton = new UIBarButtonItem(info);
			_listButton = new UIBarButtonItem(_buttonInner);
			
			LayoutBarButtonItems();
		}
		void SetupPencilUI ()
		{
			pencilButton = AddButton ("pencil", StopPencilButtonAction);
			pencilButton.TitleLabel.TextAlignment = UITextAlignment.Left;
			var bounds = pencilButton.Bounds;
			var dimension = bounds.Height - 16;
			pencilButton.ContentEdgeInsets = new UIEdgeInsets (0, dimension, 0, 0);

			var x = bounds.GetMinX () + 3;
			var y = bounds.GetMinY () + (bounds.Height - dimension) - 7;
			var closeImg = UIImage.FromBundle ("Close");
			var imageView = (closeImg != null) ? new UIImageView (closeImg) : new UIImageView ();
			imageView.Frame = new CGRect (x, y, dimension, dimension);
			imageView.Alpha = 0.7f;
			pencilButton.AddSubview (imageView);
			PencilMode = false;

			NSObject observer = UIApplication.Notifications.ObserveWillEnterForeground ((sender, e) => {
				if (PencilMode
				    && (!LastSeenPencilInteraction.HasValue || (DateTime.Now.Ticks - LastSeenPencilInteraction.Value) > pencilResetInterval))
					StopPencilButtonAction (this, EventArgs.Empty);
			});
			observers.Add (observer);
		}
                public SeriesPrimaryCell( CGRect parentSize, UITableViewCellStyle style, string cellIdentifier, UIImage imagePlaceholder ) : base( style, cellIdentifier )
                {
                    BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color );

                    Image = new UIImageView( );
                    Image.ContentMode = UIViewContentMode.ScaleAspectFit;
                    Image.Layer.AnchorPoint = CGPoint.Empty;

                    // Banner Image
                    Image.Image = imagePlaceholder;
                    Image.SizeToFit( );

                    // resize the image to fit the width of the device
                    nfloat imageAspect = Image.Bounds.Height / Image.Bounds.Width;
                    Image.Frame = new CGRect( 0, 0, parentSize.Width, parentSize.Width * imageAspect );
                    AddSubview( Image );


                    // Create the title
                    Title = new UILabel( );
                    Title.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Bold, ControlStylingConfig.Large_FontSize );
                    Title.Layer.AnchorPoint = CGPoint.Empty;
                    Title.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_ActiveTextColor );
                    Title.BackgroundColor = UIColor.Clear;
                    Title.LineBreakMode = UILineBreakMode.TailTruncation;
                    Title.Text = "PLACEHOLDER PLACEHOLDER";
                    /*Title.SizeToFit( );
                    Title.Frame = new CGRect( 5, Image.Frame.Bottom + 5, parentSize.Width - 10, Title.Frame.Height + 5 );*/
                    AddSubview( Title );

                    // Date & Speaker
                    Date = new UILabel( );
                    Date.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
                    Date.Layer.AnchorPoint = CGPoint.Empty;
                    Date.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor );
                    Date.BackgroundColor = UIColor.Clear;
                    Date.LineBreakMode = UILineBreakMode.TailTruncation;
                    Date.Text = "88/88/8888";
                    /*Date.SizeToFit( );
                    Date.Frame = new CGRect( 5, Title.Frame.Bottom - 5, parentSize.Width, Date.Frame.Height + 5 );*/
                    AddSubview( Date );

                    Speaker = new UILabel( );
                    Speaker.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
                    Speaker.Layer.AnchorPoint = CGPoint.Empty;
                    Speaker.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor );
                    Speaker.BackgroundColor = UIColor.Clear;
                    Speaker.LineBreakMode = UILineBreakMode.TailTruncation;
                    Speaker.Text = "PLACEHOLDER";
                    /*Speaker.SizeToFit( );
                    Speaker.Frame = new CGRect( parentSize.Width - Speaker.Bounds.Width - 5, Title.Frame.Bottom - 5, parentSize.Width, Speaker.Frame.Height + 5 );*/
                    AddSubview( Speaker );


                    // Watch & Take Notes Buttons
                    WatchButton = new UIButton( UIButtonType.Custom );
                    WatchButton.TouchUpInside += (object sender, EventArgs e) => { Parent.WatchButtonClicked( ); };
                    WatchButton.Layer.AnchorPoint = CGPoint.Empty;
                    WatchButton.BackgroundColor = UIColor.Clear;
                    WatchButton.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ).CGColor;
                    WatchButton.Layer.BorderWidth = 1;
                    WatchButton.SizeToFit( );
                    AddSubview( WatchButton );

                    WatchButtonIcon = new UILabel( );
                    WatchButton.AddSubview( WatchButtonIcon );
                    WatchButtonIcon.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( PrivateControlStylingConfig.Icon_Font_Secondary, PrivateNoteConfig.Series_Table_IconSize );
                    WatchButtonIcon.Text = PrivateNoteConfig.Series_Table_Watch_Icon;
                    WatchButtonIcon.SizeToFit( );

                    WatchButtonLabel = new UILabel( );
                    WatchButton.AddSubview( WatchButtonLabel );
                    WatchButtonLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
                    WatchButtonLabel.Text = MessagesStrings.Series_Table_Watch;
                    WatchButtonLabel.SizeToFit( );



                    TakeNotesButton = new UIButton( UIButtonType.Custom );
                    TakeNotesButton.TouchUpInside += (object sender, EventArgs e) => { Parent.TakeNotesButtonClicked( ); };
                    TakeNotesButton.Layer.AnchorPoint = CGPoint.Empty;
                    TakeNotesButton.BackgroundColor = UIColor.Clear;
                    TakeNotesButton.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_BorderColor ).CGColor;
                    TakeNotesButton.Layer.BorderWidth = 1;
                    TakeNotesButton.SizeToFit( );
                    AddSubview( TakeNotesButton );


                    TakeNotesButtonIcon = new UILabel( );
                    TakeNotesButton.AddSubview( TakeNotesButtonIcon );
                    TakeNotesButtonIcon.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( PrivateControlStylingConfig.Icon_Font_Secondary, PrivateNoteConfig.Series_Table_IconSize );
                    TakeNotesButtonIcon.Text = PrivateNoteConfig.Series_Table_TakeNotes_Icon;
                    TakeNotesButtonIcon.SizeToFit( );

                    TakeNotesButtonLabel = new UILabel( );
                    TakeNotesButton.AddSubview( TakeNotesButtonLabel );
                    TakeNotesButtonLabel.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
                    TakeNotesButtonLabel.Text = MessagesStrings.Series_Table_TakeNotes;
                    TakeNotesButtonLabel.SizeToFit( );

                    // bottom banner
                    BottomBanner = new UILabel( );
                    BottomBanner.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
                    BottomBanner.Layer.AnchorPoint = new CGPoint( 0, 0 );
                    BottomBanner.Text = MessagesStrings.Series_Table_PreviousMessages;
                    BottomBanner.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor );
                    BottomBanner.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Table_Footer_Color );
                    BottomBanner.TextAlignment = UITextAlignment.Center;

                    BottomBanner.SizeToFit( );

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

            // Background mask
            BackgroundPanel = new UIView( );
            BackgroundPanel.BackgroundColor = UIColor.Black;
            BackgroundPanel.Layer.Opacity = 0.00f;
            View.AddSubview( BackgroundPanel );

            // Floating "main" UI panel
            MainPanel = new UIView();
            MainPanel.Layer.AnchorPoint = CGPoint.Empty;
            MainPanel.BackgroundColor = Theme.GetColor( Config.Instance.VisualSettings.SidebarBGColor );//Theme.GetColor( Config.Instance.VisualSettings.TopHeaderBGColor );
            MainPanel.Layer.Opacity = 1.00f;
            MainPanel.ClipsToBounds = true;
            View.AddSubview( MainPanel );

            // Scroll view on the right hand side
            ScrollView = new UIScrollViewWrapper( );
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.Parent = this;
            ScrollView.BackgroundColor = Theme.GetColor( Config.Instance.VisualSettings.BackgroundColor );
            MainPanel.AddSubview( ScrollView );

            // setup controls that go on the left side
            AdultChildToggle = new UIToggle( Strings.General_Adult, Strings.General_Child,
                delegate(bool wasLeft)
                {
                    if( wasLeft == true )
                    {
                        SwitchActiveMemberView( AdultPanel );
                    }
                    else
                    {
                        SwitchActiveMemberView( ChildPanel );
                    }
                } );
            Theme.StyleToggle( AdultChildToggle, Config.Instance.VisualSettings.ToggleStyle );
            AdultChildToggle.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.SmallFontSize );
            AdultChildToggle.Layer.AnchorPoint = CGPoint.Empty;
            MainPanel.AddSubview( AdultChildToggle );

            // setup our submit button
            SubmitButton = UIButton.FromType( UIButtonType.System );
            SubmitButton.Layer.AnchorPoint = CGPoint.Empty;
            SubmitButton.Font = FontManager.GetFont( Settings.General_RegularFont, Config.Instance.VisualSettings.SmallFontSize );
            SubmitButton.SetTitle( Strings.General_Save, UIControlState.Normal );
            SubmitButton.BackgroundColor = UIColor.Blue;
            SubmitButton.SizeToFit( );
            Theme.StyleButton( SubmitButton, Config.Instance.VisualSettings.PrimaryButtonStyle );
            SubmitButton.Bounds = new CGRect( 0, 0, SubmitButton.Bounds.Width * 2.00f, SubmitButton.Bounds.Height );
            MainPanel.AddSubview( SubmitButton );
            SubmitButton.TouchUpInside += (object sender, EventArgs e ) =>
            {
                TrySubmitPerson( );
            };

            // setup the button to tap for editing the picture
            EditPictureButton = new UIButton( new CGRect( 0, 0, 112, 112 )  );
            EditPictureButton.Layer.AnchorPoint = CGPoint.Empty;
            EditPictureButton.Font = FontManager.GetFont( Settings.AddPerson_Icon_Font_Primary, Settings.AddPerson_SymbolFontSize );
            EditPictureButton.SetTitleColor( Theme.GetColor( Config.Instance.VisualSettings.PhotoOutlineColor ), UIControlState.Normal );
            EditPictureButton.Layer.BorderColor = Theme.GetColor( Config.Instance.VisualSettings.PhotoOutlineColor ).CGColor;
            EditPictureButton.Layer.CornerRadius = EditPictureButton.Bounds.Width / 2;
            EditPictureButton.Layer.BorderWidth = 4;
            MainPanel.AddSubview( EditPictureButton );

            EditPictureButton.TouchUpInside += (object sender, EventArgs e ) =>
                {
                    Parent.CaptureImage( delegate(NSData imageBuffer )
                        {
                            // if an image was taken, flag this as dirty so
                            // we know to upload it.
                            if( imageBuffer != null )
                            {
                                ProfileImageViewDirty = true;
                                UpdateProfilePic( imageBuffer );
                            }
                        });
                };

            // set the profile image mask so it's circular
            CALayer maskLayer = new CALayer();
            maskLayer.AnchorPoint = new CGPoint( 0, 0 );
            maskLayer.Bounds = EditPictureButton.Layer.Bounds;
            maskLayer.CornerRadius = EditPictureButton.Bounds.Width / 2;
            maskLayer.BackgroundColor = UIColor.Black.CGColor;
            EditPictureButton.Layer.Mask = maskLayer;
            //

            // setup the image that will display (and note it's a child of EditPictureButton)
            ProfileImageView = new UIImageView( );
            ProfileImageView.ContentMode = UIViewContentMode.ScaleAspectFit;

            ProfileImageView.Layer.AnchorPoint = CGPoint.Empty;
            ProfileImageView.Bounds = EditPictureButton.Bounds;
            ProfileImageView.Layer.Position = CGPoint.Empty;
            EditPictureButton.AddSubview( ProfileImageView );

            KeyboardAdjustManager = new KeyboardAdjustManager( MainPanel );

            // setup both types of member view. Adult and Child
            AdultPanel = new AdultMemberPanel( );
            AdultPanel.ViewDidLoad( this );
            ScrollView.AddSubview( AdultPanel.GetRootView( ) );

            ChildPanel = new ChildMemberPanel( );
            ChildPanel.ViewDidLoad( this );
            ScrollView.AddSubview( ChildPanel.GetRootView( ) );

            // add our Close Button
            CloseButton = UIButton.FromType( UIButtonType.System );
            CloseButton.Layer.AnchorPoint = CGPoint.Empty;
            CloseButton.SetTitle( "X", UIControlState.Normal );
            Theme.StyleButton( CloseButton, Config.Instance.VisualSettings.DefaultButtonStyle );
            CloseButton.SizeToFit( );
            CloseButton.BackgroundColor = UIColor.Clear;
            CloseButton.Layer.BorderWidth = 0;
            //CloseButton.Layer.CornerRadius = CloseButton.Bounds.Width / 2;
            MainPanel.AddSubview( CloseButton );
            CloseButton.TouchUpInside += (object sender, EventArgs e ) =>
            {
                ActivePanel.TouchesEnded( );

                if ( ActivePanel.IsInfoDirty( WorkingPerson, WorkingPhoneNumber ) || ProfileImageViewDirty == true )
                {
                    ConfirmCancel( );
                }
                else
                {
                    DismissAnimated( false );
                }
            };

            // default to the adult, and hide the child one
            ActivePanel = AdultPanel;
            ChildPanel.GetRootView( ).Hidden = true;

            View.SetNeedsLayout( );

            ProfileImageView.Image = null;
            EditPictureButton.SetTitle( Settings.AddPerson_NoPhotoSymbol, UIControlState.Normal );

            // remove any existing picture.
            FileCache.Instance.RemoveFile( Settings.AddPerson_PicName );

            // setup the main bounds
            MainPanel.Bounds = new CoreGraphics.CGRect( 0, 0, View.Bounds.Width * .75f, View.Bounds.Height * .75f );

            MainPanel.Layer.CornerRadius = 4;

            // default to hidden until PresentAnimated() is called.
            View.Hidden = true;

            BlockerView = new UIBlockerView( View, View.Bounds.ToRectF( ) );
        }
		public override UIView GetViewForHeader (UITableView tableView, nint section)
		{

			var btn = new UIButton (new CGRect (0, 0, tableView.Frame.Width, CollapsibleListViewCell.HEIGHT));
			btn.TitleEdgeInsets = new UIEdgeInsets (btn.TitleEdgeInsets.Top, CollapsibleListViewCell.ParentItemLeftPadding, btn.TitleEdgeInsets.Bottom, btn.TitleEdgeInsets.Right);
			btn.AutoresizingMask = UIViewAutoresizing.All;


			//set section header right side image
			if (!string.IsNullOrEmpty (Settings [(int)section].SelectedStateIcon) && !string.IsNullOrEmpty (Settings [(int)section].DeselectedStateIcon)) {
				var btnImg = btn.ViewWithTag ((int)section);
				if (btnImg != null) {
					btnImg.RemoveFromSuperview ();
				}
				var img = !Settings [(int)section].IsSelected ? new UIImageView (UIImage.FromBundle (Settings [(int)section].DeselectedStateIcon)) : new UIImageView (UIImage.FromBundle (Settings [(int)section].SelectedStateIcon));
				img.Tag = (int)section;
				img.Frame = new CGRect (
					btn.Frame.Width - CollapsibleListViewCell.HEIGHT - 20, 
					0,
					CollapsibleListViewCell.HEIGHT,
					CollapsibleListViewCell.HEIGHT
				);
				img.ContentMode = UIViewContentMode.Center;
				img.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin;
				//img.BackgroundColor = UIColor.Yellow;
				btn.AddSubview (img);
			}

			//ADD SEPERATOR LINE AT BOTTOM
			var seperatorLine = new UIView (new CGRect (0, CollapsibleListViewCell.HEIGHT - 1, tableView.Frame.Width, 1));
			seperatorLine.BackgroundColor = UIColor.LightGray;
			seperatorLine.Alpha = 0.3f;
			seperatorLine.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;
			btn.AddSubview (seperatorLine);

			btn.SetTitle (Settings [(int)section].Title, UIControlState.Normal);
			btn.Font = UIFont.BoldSystemFontOfSize (CollapsibleListViewCell.FontSize);
			btn.BackgroundColor = UIColor.Clear;
			btn.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
			btn.SetTitleColor (UIColor.DarkGray, UIControlState.Normal);
			btn.TouchUpInside += (sender, e) => {
				//put in your code to toggle your boolean value here
				if (Settings [(int)section].OnClickListener != null) {
					Settings [(int)section].OnClickListener.Invoke (Settings [(int)section]);
				} 

				Settings [(int)section].IsSelected = !Settings [(int)section].IsSelected;

				///reload this section
				tableView.ReloadSections (NSIndexSet.FromIndex (section), UITableViewRowAnimation.Fade);
			};
			return btn;
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad( );

            TraitSize = UIScreen.MainScreen.Bounds.Size;
            CurrentTraitCollection = TraitCollection;

            // if we're on an iphone and they're holding it landscape, force a portrait traitsize
            if ( UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone && IsDeviceLandscape( ) )
            {
                UITraitCollection horzTrait = UITraitCollection.FromHorizontalSizeClass( UIUserInterfaceSizeClass.Compact );
                UITraitCollection vertTrait = UITraitCollection.FromVerticalSizeClass( UIUserInterfaceSizeClass.Regular );
                CurrentTraitCollection = UITraitCollection.FromTraitsFromCollections( new UITraitCollection[] { horzTrait, vertTrait } );

                TraitSize = new CGSize( TraitSize.Height, TraitSize.Width );
            }

            View.Layer.AnchorPoint = CGPoint.Empty;
            View.Bounds = new CGRect( View.Bounds.Left, View.Bounds.Top, TraitSize.Width, TraitSize.Height );

            // create the login controller / profile view controllers
            LoginViewController = new LoginViewController( );
            LoginViewController.Springboard = this;

            ProfileViewController = new ProfileViewController( );
            ProfileViewController.Springboard = this;

            ImageCropViewController = new ImageCropViewController( );
            ImageCropViewController.Springboard = this;

            RegisterViewController = new RegisterViewController( );
            RegisterViewController.Springboard = this;

            OOBEViewController = new OOBEViewController( );
            OOBEViewController.Springboard = this;
            OOBEViewController.View.Layer.Position = CGPoint.Empty;

            SplashViewController = new SplashViewController( );
            SplashViewController.Springboard = this;
            SplashViewController.View.Layer.Position = CGPoint.Empty;


            ScrollView = new UIScrollViewWrapper( );
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.Parent = this;
            View.AddSubview( ScrollView );

            // Instantiate all activities
            float elementWidth = 250;
            float elementHeight = 45;

            NewsElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
            ScrollView.AddSubview( NewsElement );

            MessagesElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
            ScrollView.AddSubview( MessagesElement );

            GiveElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
            ScrollView.AddSubview( GiveElement );

            ConnectElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
            ScrollView.AddSubview( ConnectElement );

            PrayerElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
            ScrollView.AddSubview( PrayerElement );

            MoreElement = new UIView( new CGRect( 0, 0, elementWidth, elementHeight ) );
            ScrollView.AddSubview( MoreElement );
            //

            EditPictureButton = new UIButton( new CGRect( 0, 0, 112, 112 )  );
            ScrollView.AddSubview( EditPictureButton );

            WelcomeField = new UILabel();
            ScrollView.AddSubview( WelcomeField );

            UserNameField = new UILabel();
            ScrollView.AddSubview( UserNameField );


            ViewProfileButton = new UIButton();
            ScrollView.AddSubview( ViewProfileButton );

            ViewProfileLabel = new UILabel();
            ScrollView.AddSubview( ViewProfileLabel );
        

            Elements.Add( new SpringboardElement( this, new NewsTask( "NewsStoryboard_iPhone" )      , NewsElement    , SpringboardConfig.Element_News_Icon    , SpringboardStrings.Element_News_Title ) );
            Elements.Add( new SpringboardElement( this, new NotesTask( "NotesStoryboard_iPhone" )    , MessagesElement, SpringboardConfig.Element_Messages_Icon, SpringboardStrings.Element_Messages_Title ) );
            Elements.Add( new SpringboardElement( this, new GiveTask( "GiveStoryboard_iPhone" )      , GiveElement    , SpringboardConfig.Element_Give_Icon    , SpringboardStrings.Element_Give_Title ) );
            Elements.Add( new SpringboardElement( this, new ConnectTask( "ConnectStoryboard_iPhone" ), ConnectElement , SpringboardConfig.Element_Connect_Icon , SpringboardStrings.Element_Connect_Title ) );
            Elements.Add( new SpringboardElement( this, new PrayerTask( "PrayerStoryboard_iPhone" )  , PrayerElement  , SpringboardConfig.Element_Prayer_Icon  , SpringboardStrings.Element_Prayer_Title ) );
            Elements.Add( new SpringboardElement( this, new AboutTask( "" )                          , MoreElement    , SpringboardConfig.Element_More_Icon    , SpringboardStrings.Element_More_Title ) );

            // add a bottom seperator for the final element
            BottomSeperator = new UIView();
            BottomSeperator.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BG_Layer_Color );
            ScrollView.AddSubview( BottomSeperator );
            BottomSeperator.Frame = new CGRect( 0, 0, View.Frame.Width, 1.0f );


            // set the profile image mask so it's circular
            CALayer maskLayer = new CALayer();
            maskLayer.AnchorPoint = new CGPoint( 0, 0 );
            maskLayer.Bounds = EditPictureButton.Layer.Bounds;
            maskLayer.CornerRadius = EditPictureButton.Bounds.Width / 2;
            maskLayer.BackgroundColor = UIColor.Black.CGColor;
            EditPictureButton.Layer.Mask = maskLayer;
            //

            // setup the campus selector and settings button
            CampusSelectionText = new UILabel();
            ControlStyling.StyleUILabel( CampusSelectionText, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
            CampusSelectionText.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor );
            ScrollView.AddSubview( CampusSelectionText );

            CampusSelectionIcon = new UILabel();
            ControlStyling.StyleUILabel( CampusSelectionIcon, PrivateControlStylingConfig.Icon_Font_Primary, ControlStylingConfig.Small_FontSize );
            CampusSelectionIcon.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor );
            CampusSelectionIcon.Text = PrivateSpringboardConfig.CampusSelectSymbol;
            CampusSelectionIcon.SizeToFit( );
            ScrollView.AddSubview( CampusSelectionIcon );

            CampusSelectionButton = new UIButton();
            ScrollView.AddSubview( CampusSelectionButton );
            CampusSelectionButton.TouchUpInside += SelectCampus;


            // setup the image that will display when the user is logged in
            ProfileImageView = new UIImageView( );
            ProfileImageView.ContentMode = UIViewContentMode.ScaleAspectFit;

            ProfileImageView.Layer.AnchorPoint = CGPoint.Empty;
            ProfileImageView.Bounds = EditPictureButton.Bounds;
            ProfileImageView.Layer.Position = CGPoint.Empty;
            EditPictureButton.AddSubview( ProfileImageView );

            EditPictureButton.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( PrivateControlStylingConfig.Icon_Font_Primary, PrivateSpringboardConfig.ProfileSymbolFontSize );
            EditPictureButton.SetTitleColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ), UIControlState.Normal );
            EditPictureButton.Layer.BorderColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor ).CGColor;
            EditPictureButton.Layer.CornerRadius = EditPictureButton.Bounds.Width / 2;
            EditPictureButton.Layer.BorderWidth = 4;

            WelcomeField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Light, ControlStylingConfig.Large_FontSize );
            WelcomeField.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor );

            UserNameField.Font = Rock.Mobile.PlatformSpecific.iOS.Graphics.FontManager.GetFont( ControlStylingConfig.Font_Bold, ControlStylingConfig.Large_FontSize );
            UserNameField.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_InActiveElementTextColor );

            View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Springboard_BackgroundColor );

            AddChildViewController( NavViewController );
            View.AddSubview( NavViewController.View );

            SetNeedsStatusBarAppearanceUpdate( );

            EditPictureButton.TouchUpInside += (object sender, EventArgs e) => 
                {
                    // don't allow launching a model view controller unless the springboard is open.
                    if ( NavViewController.IsSpringboardOpen( ) )
                    {
                        if( RockMobileUser.Instance.LoggedIn == true )
                        {
                            // they're logged in, so let them set their profile pic
                            ManageProfilePic( );
                        }
                        else
                        {
                            //otherwise this button can double as a login button.
                            PresentModalViewController( LoginViewController );
                        }
                    }
                };
            
            ViewProfileButton.TouchUpInside += (object sender, EventArgs e) => 
                {
                    // don't allow launching a model view controller unless the springboard is open.
                    if ( NavViewController.IsSpringboardOpen( ) )
                    {
                        if( RockMobileUser.Instance.LoggedIn == true )
                        {
                            // Because we aren't syncing RIGHT HERE, Rock data could technically be overwritten.
                            // If WHILE they're running the app, their data is updated in Rock, those changes will
                            // be lost when they submit their profile changes.
                            // But, the odds that Rock data will update WHILE THE APP IS RUNNING, and they then decide to
                            // update their profile without having even backgrounded the app, are extremely low.
                            PresentModalViewController( ProfileViewController );
                        }
                        else
                        {
                            PresentModalViewController( LoginViewController );
                        }
                    }
                };

            // load our objects from disk
            Rock.Mobile.Util.Debug.WriteLine( "Loading objects from device." );
            RockNetworkManager.Instance.LoadObjectsFromDevice( );
            Rock.Mobile.Util.Debug.WriteLine( "Loading objects done." );

            // set the viewing campus now that their profile has loaded (if they have already done the OOBE)
            CampusSelectionText.Text = string.Format( SpringboardStrings.Viewing_Campus, RockGeneralData.Instance.Data.CampusIdToName( RockMobileUser.Instance.ViewingCampus ) ).ToUpper( );
            CampusSelectionText.SizeToFit( );

            // seed the last sync time with now, so that when OnActivated gets called we don't do it again.
            LastRockSync = DateTime.Now;

            // setup the Notification Banner for Taking Notes
            Billboard = new NotificationBillboard( View.Bounds.Width, View.Bounds.Height );
            Billboard.SetLabel( SpringboardStrings.TakeNotesNotificationIcon, 
                                PrivateControlStylingConfig.Icon_Font_Primary,
                                ControlStylingConfig.Small_FontSize,
                                SpringboardStrings.TakeNotesNotificationLabel, 
                                ControlStylingConfig.Font_Light,
                                ControlStylingConfig.Small_FontSize,
                                ControlStylingConfig.TextField_ActiveTextColor, 
                                ControlStylingConfig.Springboard_Element_SelectedColor, 
                delegate 
                {
                    // find the Notes task, activate it, and tell it to jump to the read page.
                    foreach( SpringboardElement element in Elements )
                    {
                        if ( element.Task as NotesTask != null )
                        {
                            ActivateElement( element, true );
                            PerformTaskAction( PrivateGeneralConfig.TaskAction_NotesRead );
                        }
                    }
                } 
            );

            Billboard.Layer.Position = new CGPoint( Billboard.Layer.Position.X, NavViewController.NavigationBar.Frame.Height );


            // only do the OOBE if the user hasn't seen it yet
            if ( RockMobileUser.Instance.OOBEComplete == false )
            //if( RanOOBE == false )
            {
                // sanity check for testers that didn't listen to me and delete / reinstall.
                // This will force them to be logged out so they experience the OOBE properly.
                RockMobileUser.Instance.LogoutAndUnbind( );

                //RanOOBE = true;
                IsOOBERunning = true;
                AddChildViewController( OOBEViewController );
                View.AddSubview( OOBEViewController.View );
            }
            else
            {
                // kick off the splash screen animation
                AddChildViewController( SplashViewController );
                View.AddSubview( SplashViewController.View );
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            BlockerView = new UIBlockerView( View, View.Frame.ToRectF( ) );

            View.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor );

            ScrollView = new UIScrollViewWrapper();
            ScrollView.Parent = this;
            ScrollView.Layer.AnchorPoint = CGPoint.Empty;
            ScrollView.Bounds = View.Bounds;
            View.AddSubview( ScrollView );

            UserNameField = new StyledTextField();
            ScrollView.AddSubview( UserNameField.Background );

            UserNameField.Field.AutocapitalizationType = UITextAutocapitalizationType.None;
            UserNameField.Field.AutocorrectionType = UITextAutocorrectionType.No;
            ControlStyling.StyleTextField( UserNameField.Field, LoginStrings.UsernamePlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
            ControlStyling.StyleBGLayer( UserNameField.Background );
            UserNameField.Field.ShouldReturn += (textField) => 
                {
                    textField.ResignFirstResponder();

                    TryRockBind();
                    return true;
                };

            PasswordField = new StyledTextField();
            ScrollView.AddSubview( PasswordField.Background );
            PasswordField.Field.AutocorrectionType = UITextAutocorrectionType.No;
            PasswordField.Field.SecureTextEntry = true;

            ControlStyling.StyleTextField( PasswordField.Field, LoginStrings.PasswordPlaceholder, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
            ControlStyling.StyleBGLayer( PasswordField.Background );
            PasswordField.Field.ShouldReturn += (textField) => 
                {
                    textField.ResignFirstResponder();

                    TryRockBind();
                    return true;
                };

            // obviously attempt a login if login is pressed
            LoginButton = UIButton.FromType( UIButtonType.System );
            ScrollView.AddSubview( LoginButton );
            ControlStyling.StyleButton( LoginButton, LoginStrings.LoginButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
            LoginButton.SizeToFit( );
            LoginButton.TouchUpInside += (object sender, EventArgs e) => 
                {
                    if( RockMobileUser.Instance.LoggedIn == true )
                    {
                        RockMobileUser.Instance.LogoutAndUnbind( );

                        SetUIState( LoginState.Out );
                    }
                    else
                    {
                        TryRockBind();
                    }
                };

            AdditionalOptions = new UILabel( );
            ScrollView.AddSubview( AdditionalOptions );
            ControlStyling.StyleUILabel( AdditionalOptions, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
            AdditionalOptions.Text = LoginStrings.AdditionalOptions;
            AdditionalOptions.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor );
            AdditionalOptions.SizeToFit( );

            OrSpacerLabel = new UILabel( );
            ScrollView.AddSubview( OrSpacerLabel );
            ControlStyling.StyleUILabel( OrSpacerLabel, ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
            OrSpacerLabel.TextColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.TextField_PlaceholderTextColor );
            OrSpacerLabel.Text = LoginStrings.OrString;
            OrSpacerLabel.SizeToFit( );

            RegisterButton = UIButton.FromType( UIButtonType.System );
            ScrollView.AddSubview( RegisterButton );
            ControlStyling.StyleButton( RegisterButton, LoginStrings.RegisterButton, ControlStylingConfig.Font_Regular, ControlStylingConfig.Medium_FontSize );
            //RegisterButton.BackgroundColor = UIColor.Clear;
            RegisterButton.SizeToFit( );
            RegisterButton.TouchUpInside += (object sender, EventArgs e ) =>
                {
                    Springboard.RegisterNewUser( );
                };

            // setup the result
            LoginResult = new StyledTextField( );
            ScrollView.AddSubview( LoginResult.Background );

            ControlStyling.StyleTextField( LoginResult.Field, "", ControlStylingConfig.Font_Regular, ControlStylingConfig.Small_FontSize );
            ControlStyling.StyleBGLayer( LoginResult.Background );
            LoginResult.Field.UserInteractionEnabled = false;
            LoginResult.Field.TextAlignment = UITextAlignment.Center;

            // setup the facebook button
            FacebookLogin = new UIButton( );
            ScrollView.AddSubview( FacebookLogin );
            string imagePath = NSBundle.MainBundle.BundlePath + "/" + "facebook_login.png";
            FBImageView = new UIImageView( new UIImage( imagePath ) );

            FacebookLogin.SetTitle( "", UIControlState.Normal );
            FacebookLogin.AddSubview( FBImageView );
            FacebookLogin.Layer.CornerRadius = 4;
            FBImageView.Layer.CornerRadius = 4;

            FacebookLogin.TouchUpInside += (object sender, EventArgs e) => 
                {
                    TryFacebookBind();
                };

            // If cancel is pressed, notify the springboard we're done.
            CancelButton = UIButton.FromType( UIButtonType.System );
            ScrollView.AddSubview( CancelButton );
            CancelButton.SetTitleColor( Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.Label_TextColor ), UIControlState.Normal );
            CancelButton.SetTitle( GeneralStrings.Cancel, UIControlState.Normal );
            CancelButton.SizeToFit( );
            CancelButton.TouchUpInside += (object sender, EventArgs e) => 
                {
                    // don't allow canceling while we wait for a web request.
                    if( LoginState.Trying != State )
                    {
                        Springboard.ResignModelViewController( this, null );
                    }
                };
            
            // setup the fake header
            HeaderView = new UIView( );
            View.AddSubview( HeaderView );
            HeaderView.BackgroundColor = Rock.Mobile.UI.Util.GetUIColor( ControlStylingConfig.BackgroundColor );

            imagePath = NSBundle.MainBundle.BundlePath + "/" + PrivatePrimaryNavBarConfig.LogoFile_iOS;
            LogoView = new UIImageView( new UIImage( imagePath ) );
            LogoView.SizeToFit( );
            LogoView.Layer.AnchorPoint = CGPoint.Empty;

            HeaderView.AddSubview( LogoView );
        }
        void SetArrows()
        {
            CleanUpArrows();

            if (Element.ShowArrows)
            {
                var o             = Element.Orientation == CarouselViewOrientation.Horizontal ? "H" : "V";
                var formatOptions = Element.Orientation == CarouselViewOrientation.Horizontal ? NSLayoutFormatOptions.AlignAllCenterY : NSLayoutFormatOptions.AlignAllCenterX;

                prevBtn                 = new UIButton();
                prevBtn.Hidden          = Element.Position == 0 || Element.ItemsSource.GetCount() == 0;
                prevBtn.BackgroundColor = Element.ArrowsBackgroundColor.ToUIColor();
                prevBtn.Alpha           = Element.ArrowsTransparency;
                prevBtn.TranslatesAutoresizingMaskIntoConstraints = false;

                var prevArrow      = new UIImageView();
                var prevArrowImage = new UIImage(Element.Orientation == CarouselViewOrientation.Horizontal ? "Prev.png" : "Up.png");
                prevArrow.Image = prevArrowImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
                prevArrow.TranslatesAutoresizingMaskIntoConstraints = false;
                prevArrow.TintColor = Element.ArrowsTintColor.ToUIColor();
                prevBtn.AddSubview(prevArrow);

                prevBtn.TouchUpInside += PrevBtn_TouchUpInside;

                var prevViewsDictionary = NSDictionary.FromObjectsAndKeys(new NSObject[] { prevBtn, prevArrow }, new NSObject[] { new NSString("superview"), new NSString("prevArrow") });
                prevBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat("[prevArrow(==17)]", 0, new NSDictionary(), prevViewsDictionary));
                prevBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[prevArrow(==17)]", 0, new NSDictionary(), prevViewsDictionary));
                prevBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[prevArrow]-(2)-|", 0, new NSDictionary(), prevViewsDictionary));
                prevBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[superview]-(<=1)-[prevArrow]", formatOptions, new NSDictionary(), prevViewsDictionary));

                pageController.View.AddSubview(prevBtn);

                nextBtn                 = new UIButton();
                nextBtn.Hidden          = Element.Position == Element.ItemsSource.GetCount() - 1 || Element.ItemsSource.GetCount() == 0;
                nextBtn.BackgroundColor = Element.ArrowsBackgroundColor.ToUIColor();
                nextBtn.Alpha           = Element.ArrowsTransparency;
                nextBtn.TranslatesAutoresizingMaskIntoConstraints = false;

                var nextArrow      = new UIImageView();
                var nextArrowImage = new UIImage(Element.Orientation == CarouselViewOrientation.Horizontal ? "Next.png" : "Down.png");
                nextArrow.Image = nextArrowImage.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate);
                nextArrow.TranslatesAutoresizingMaskIntoConstraints = false;
                nextArrow.TintColor = Element.ArrowsTintColor.ToUIColor();
                nextBtn.AddSubview(nextArrow);

                nextBtn.TouchUpInside += NextBtn_TouchUpInside;

                var nextViewsDictionary = NSDictionary.FromObjectsAndKeys(new NSObject[] { nextBtn, nextArrow }, new NSObject[] { new NSString("superview"), new NSString("nextArrow") });
                nextBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat("[nextArrow(==17)]", 0, new NSDictionary(), nextViewsDictionary));
                nextBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[nextArrow(==17)]", 0, new NSDictionary(), nextViewsDictionary));
                nextBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":|-(2)-[nextArrow]", 0, new NSDictionary(), nextViewsDictionary));
                nextBtn.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[superview]-(<=1)-[nextArrow]", formatOptions, new NSDictionary(), nextViewsDictionary));

                pageController.View.AddSubview(nextBtn);

                var btnsDictionary = NSDictionary.FromObjectsAndKeys(new NSObject[] { pageController.View, prevBtn, nextBtn }, new NSObject[] { new NSString("superview"), new NSString("prevBtn"), new NSString("nextBtn") });

                var w = Element.Orientation == CarouselViewOrientation.Horizontal ? 20 : 36;
                var h = Element.Orientation == CarouselViewOrientation.Horizontal ? 36 : 20;

                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[prevBtn(==" + w + ")]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[prevBtn(==" + h + ")]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":|[prevBtn]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[superview]-(<=1)-[prevBtn]", formatOptions, new NSDictionary(), btnsDictionary));

                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[nextBtn(==" + w + ")]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[nextBtn(==" + h + ")]", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[nextBtn]|", 0, new NSDictionary(), btnsDictionary));
                pageController.View.AddConstraints(NSLayoutConstraint.FromVisualFormat(o + ":[superview]-(<=1)-[nextBtn]", formatOptions, new NSDictionary(), btnsDictionary));
            }
        }
                    public PersonEntry( string personName, int personId, bool canCheckin, string roleInFamily, List<Rock.Client.GroupMember> primaryFamilyMembers )
                    {
                        PrimaryFamilyMembers = primaryFamilyMembers;

                        PersonId = personId;

                        CanCheckin = canCheckin;

                        Button = new UIButton( UIButtonType.System );
                        Button.Layer.AnchorPoint = CGPoint.Empty;
                        Button.Layer.CornerRadius = 4;
                        Button.Bounds = new CGRect( 0, 0, PersonEntryWidth, PersonEntryHeight );

                        Name = new UILabel( );
                        Name.Layer.AnchorPoint = CGPoint.Empty;
                        Name.Text = personName;
                        Name.SizeToFit( );
                        Name.TextColor = Theme.GetColor( Config.Instance.VisualSettings.PrimaryButtonStyle.TextColor );
                        Button.AddSubview( Name );

                        AgeLabel = new UILabel( );
                        AgeLabel.Layer.AnchorPoint = CGPoint.Empty;
                        AgeLabel.Text = roleInFamily;
                        AgeLabel.TextColor = Theme.GetColor( Config.Instance.VisualSettings.PrimaryButtonStyle.TextColor );
                        AgeLabel.Font = FontManager.GetFont( Settings.General_LightFont, Config.Instance.VisualSettings.SmallFontSize );
                        AgeLabel.SizeToFit( );
                        Button.AddSubview( AgeLabel );

                        nfloat combinedHeight = Name.Layer.Bounds.Height + AgeLabel.Bounds.Height;
                        nfloat startingY = (PersonEntryHeight - combinedHeight) / 2;

                        Name.Layer.Position = new CGPoint( (PersonEntryWidth - Name.Bounds.Width) / 2, startingY );
                        AgeLabel.Layer.Position = new CGPoint( (PersonEntryWidth - AgeLabel.Bounds.Width) / 2, Name.Frame.Bottom );

                        Button.TouchUpInside += (object sender, EventArgs e) =>
                            {
                                Button.Enabled = false;

                                // are they currently able to check in?
                                if( CanCheckin == true )
                                {
                                    // then remove it.
                                    int pendingRemovals = 0;
                                    foreach( Rock.Client.GroupMember member in primaryFamilyMembers )
                                    {
                                        FamilyManagerApi.RemoveKnownRelationship( member.Person.Id, PersonId, Config.Instance.CanCheckInGroupRole.Id, delegate
                                            {
                                                // once we hear back from all the requests, toggle the button
                                                pendingRemovals++;

                                                if( pendingRemovals == primaryFamilyMembers.Count )
                                                {
                                                    Button.Enabled = true;
                                                    CanCheckin = !CanCheckin;
                                                    UpdateBGColor( );
                                                    Button.SetNeedsDisplay( );
                                                }
                                            });
                                    }
                                }
                                else
                                {
                                    // simply bind them to the first person
                                    FamilyManagerApi.UpdateKnownRelationship( primaryFamilyMembers[ 0 ].Person.Id, PersonId, Config.Instance.CanCheckInGroupRole.Id, delegate
                                        {
                                            Button.Enabled = true;
                                            CanCheckin = !CanCheckin;
                                            UpdateBGColor( );
                                            Button.SetNeedsDisplay( );
                                        });
                                }
                            };

                        UpdateBGColor( );
                    }
Esempio n. 10
0
        UIView GetItemView(SerializationModel model, CGRect frame)
        {
            UIButton    button    = new UIButton(frame);
            UIImageView imageView = new UIImageView(new CGRect(0, 5, frame.Width, frame.Height - 20));

            imageView.Alpha           = 1f;
            imageView.Image           = model.Image;
            imageView.BackgroundColor = model.ImageBackgroundColor;
            imageView.ContentMode     = model.ImageAlignment;
            button.AddSubview(imageView);

            UILabel label = new UILabel();

            if (model.Name != "Create New")
            {
                label.Frame           = new CGRect(0, frame.Height - 40, frame.Width, 25);
                label.Alpha           = 0.5f;
                label.BackgroundColor = UIColor.LightGray;
                if (model.IsImageSelected)
                {
                    UIImageView SelectedView = new UIImageView(new CGRect(frame.Width - 25, 10, 20, 20));
                    if (!model.IsItemSelectedToDelete)
                    {
                        SelectedView.Image = UIImage.FromBundle("Images/ImageEditor/NotSelected.png");
                        imageView.Alpha    = 1f;
                    }
                    else
                    {
                        SelectedView.Image = UIImage.FromBundle("Images/ImageEditor/Selected.png");
                        imageView.Alpha    = 0.3f;
                    }
                    SelectedView.BackgroundColor = UIColor.Clear;
                    SelectedView.ContentMode     = UIViewContentMode.ScaleAspectFit;
                    button.AddSubview(SelectedView);
                }
            }
            else
            {
                if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad)
                {
                    label.Frame = new CGRect(0, frame.Height / 2 + 50, frame.Width, 25);
                }
                else
                {
                    label.Frame = new CGRect(0, frame.Height / 2 + 20, frame.Width, 25);
                }
                label.Alpha           = 1f;
                label.BackgroundColor = UIColor.Clear;
                label.TextColor       = UIColor.White;
            }

            label.Font          = UIFont.SystemFontOfSize(18);
            label.TextAlignment = UITextAlignment.Center;
            label.Text          = model.Name;
            button.AddSubview(label);
            UILongPressGestureRecognizer detector = new UILongPressGestureRecognizer((UILongPressGestureRecognizer obj) =>
            {
                OnLongPressed(this, model);
            });

            button.AddGestureRecognizer(detector);
            button.TouchUpInside += (sender, e) =>
            {
                OnItemSelected(this, model);
            };

            return(button);
        }
Esempio n. 11
0
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();
            CustomCollectionView.Frame         = new CGRect(0, 70, Frame.Width, Frame.Height - 150);
            CustomCollectionView.DataSource    = ViewModel.ModelCollection;
            CustomCollectionView.ItemSelected += (sender, e) =>
            {
                var model = e as SerializationModel;
                ValidateItem(model);
            };
            CustomCollectionView.LongPressed += (sender, e) =>
            {
                if ((e as SerializationModel).Name != "Create New")
                {
                    Delete.Alpha = 1;
                    EnableSelection();
                }
            };
            this.BackgroundColor = UIColor.FromRGB(242, 242, 242);

            /*------Header Label-------*/

            UILabel label = new UILabel(new CGRect(20, 50, Frame.Width, 25));

            label.BackgroundColor = UIColor.Clear;
            label.Font            = UIFont.SystemFontOfSize(25);
            label.TextAlignment   = UITextAlignment.Left;
            label.TextColor       = UIColor.Gray;
            label.Text            = "Serialization";


            /*------Delete------------*/


            Delete                 = new UIButton(new CGRect(Frame.Width / 2 - 50, Frame.Height - 60, 100, 50));
            Delete.Alpha           = 0;
            Delete.BackgroundColor = UIColor.Clear;
            Delete.TouchUpInside  += (sender, e) =>
            {
                for (int i = 0; i < list.Count; i++)
                {
                    if (ViewModel.ModelCollection.Contains(list[i]))
                    {
                        ViewModel.ModelCollection.Remove(list[i]);
                    }
                }
                foreach (var item1 in ViewModel.ModelCollection)
                {
                    item1.IsImageSelected        = false;
                    item1.IsItemSelectedToDelete = false;
                    list = new List <SerializationModel>();
                }
                CustomCollectionView.DataSource = ViewModel.ModelCollection;
                Delete.Alpha = 0;
            };

            UIImageView DeleteButton = new UIImageView(new CGRect(0, 0, 100, 50));

            DeleteButton.Image       = UIImage.FromBundle("Images/ImageEditor/Delete1.png");
            DeleteButton.ContentMode = UIViewContentMode.ScaleAspectFit;
            Delete.AddSubview(DeleteButton);
            AddSubview(label);
            AddSubview(CustomCollectionView);
            AddSubview(Delete);
        }
Esempio n. 12
0
        private void UpdateImage(string imageName, int widthRequest, int heightRequest, UIButton targetButton)
        {
            var assembly = typeof(App).GetTypeInfo().Assembly;
            UIImage image = null;
            if (imageName != null)
            {
                try
                {
                    image = UIImage.FromResource(assembly, imageName);
                }
                catch (Exception)
                {
                    var path = PCLStorage.FileSystem.Current.LocalStorage.Path;
                    var iPath = PCLStorage.PortablePath.Combine(path, imageName);
                    image = UIImage.FromFile(iPath);
                }
            }

            var imageView = new UIImageView();

            var widthCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, widthRequest);
            var heightCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1, heightRequest);

            imageView.AddConstraint(widthCt);
            imageView.AddConstraint(heightCt);
            imageView.TranslatesAutoresizingMaskIntoConstraints = false;
            imageView.Image = image;
            imageView.ContentMode = UIViewContentMode.ScaleAspectFit;

            targetButton.AddSubview(imageView);

            switch (ImageButton.Orientation)
            {
                case TextAligment.Left:
                    {
                        targetButton.TitleEdgeInsets = new UIEdgeInsets(0, 20, 0, 0);
                        targetButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Left;
                    }
                    break;
                case TextAligment.Top:
                    {
                        targetButton.TitleEdgeInsets = new UIEdgeInsets(5, 0, 0, 0);
                        targetButton.VerticalAlignment = UIControlContentVerticalAlignment.Top;
                    }
                    break;
                case TextAligment.Right:
                    {
                        var yCenterCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.CenterY, 1, 0);
                        var xLeftCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Left, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.Left, 1, 0);

                        targetButton.AddConstraint(yCenterCt);
                        targetButton.AddConstraint(xLeftCt);

                        targetButton.TitleEdgeInsets = new UIEdgeInsets(0, 0, 0, 20);
                        targetButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
                    }
                    break;
                case TextAligment.Bottom:
                    {
                        var xCenterCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.CenterX, 1, 0);
                        var yTopCt = NSLayoutConstraint.Create(imageView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, targetButton, NSLayoutAttribute.Top, 1, 0);

                        targetButton.AddConstraint(xCenterCt);
                        targetButton.AddConstraint(yTopCt);

                        targetButton.TitleEdgeInsets = new UIEdgeInsets(0, 0, 5, 0);
                        targetButton.VerticalAlignment = UIControlContentVerticalAlignment.Bottom;
                    }
                    break;
                default:
                    throw new InvalidOperationException();
            }
        }
Esempio n. 13
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (Control != null && Element != null)
            {
                Control.BorderStyle = UITextBorderStyle.None;

                formControl = (Element as CoreUnderlineEntry);
                if ((Control != null) & (formControl != null))
                {
                    var returnType = formControl.ReturnKeyType;

                    if (this.Element.Keyboard == Keyboard.Numeric || this.Element.Keyboard == Keyboard.Telephone)
                    {
                        this.AddAccessoryButton(returnType);
                    }
                    else
                    {
                        Control.ReturnKeyType = returnType.GetValueFromDescription();
                    }
                }

                ((UITextField)Control).ShouldReturn = (textField) =>
                {
                    formControl?.NextFocus?.Invoke();
                    return(true);
                };

                controlColor = formControl.EntryColor.ToCGColor();

                var    ctrl                      = (UITextField)Control;
                var    fontSize                  = ctrl.Font.PointSize;
                var    iconHeight                = fontSize + 9; // UIScreen.MainScreen.Bounds.Height * .03;
                var    passwordIconAdder         = 2;
                var    passwordIconPaddingHeight = 2;
                var    passwordIconHeight        = iconHeight + passwordIconAdder;
                var    passwordIconPaddingWidth  = 10;
                var    iconPadding               = passwordIconAdder / 2 + passwordIconPaddingHeight;
                nfloat iconFrameHeight           = 0;
                nfloat iconPasswordFrameHeight   = 0;

                if (formControl.Icon != null)
                {
                    if (formControl.Icon.IndexOf(".png", StringComparison.InvariantCultureIgnoreCase) == -1)
                    {
                        formControl.Icon = formControl.Icon + ".png";
                    }

                    imgView       = new UIImageView(new CGRect(0, 0, (iconHeight), (iconHeight)));
                    imgView.Image = new UIImage(formControl.Icon).ChangeImageColor(formControl.PlaceholderColor.ToUIColor());

                    Resize(imgView, fontSize, fontSize);

                    var paddingView = new UIView(new CGRect(0, 0, (iconHeight + 4), (iconHeight + iconPadding)));
                    iconFrameHeight = paddingView.Frame.Height;

                    paddingView.AddSubview(imgView);
                    ctrl.LeftViewMode = UITextFieldViewMode.Always;
                    ctrl.LeftView     = paddingView;
                }
                if (formControl.IsPassword &&
                    formControl.PasswordRevealEnabled &&
                    !string.IsNullOrEmpty(formControl.PasswordRevealIcon) &&
                    !string.IsNullOrEmpty(formControl.PasswordHideIcon)
                    )
                {
                    imgView       = new UIImageView(new CGRect(0, 0, (passwordIconHeight + 10), (passwordIconHeight + 10)));
                    imgView.Image = new UIImage(formControl.PasswordRevealIcon).ChangeImageColor(formControl.EntryColor.ToUIColor());

                    Resize(imgView, passwordIconHeight + passwordIconPaddingWidth, passwordIconHeight);

                    var paddingView = new UIView(new CGRect(0, 0, (passwordIconHeight + passwordIconPaddingWidth), (passwordIconHeight + passwordIconPaddingHeight + 10)));
                    iconPasswordFrameHeight = paddingView.Frame.Height;

                    var btn = new UIButton(paddingView.Frame);
                    btn.AddSubview(imgView);
                    btn.TouchUpInside += (ee, aa) =>
                    {
                        formControl.IsPassword = !formControl.IsPassword;
                        var fileName = formControl.IsPassword ? formControl.PasswordRevealIcon : formControl.PasswordHideIcon;
                        imgView.Image = new UIImage(fileName).ChangeImageColor(formControl.EntryColor.ToUIColor());
                    };
                    paddingView.AddSubview(btn);
                    ctrl.RightViewMode = UITextFieldViewMode.Always;
                    ctrl.RightView     = paddingView;
                    ctrl.RightView.UserInteractionEnabled = true;

                    Control.SpellCheckingType      = UITextSpellCheckingType.No;        // No Spellchecking
                    Control.AutocorrectionType     = UITextAutocorrectionType.No;       // No Autocorrection
                    Control.AutocapitalizationType = UITextAutocapitalizationType.None; // No Autocapitalization
                }

                if (!formControl.PasswordRevealEnabled && formControl.ClearEntryEnabled)
                {
                    ((UITextField)Control).ClearButtonMode = UITextFieldViewMode.WhileEditing;
                }

                if (iconFrameHeight != 0 && iconPasswordFrameHeight != 0)
                {
                    formControl.HeightRequest = iconFrameHeight > iconPasswordFrameHeight ? iconFrameHeight : iconPasswordFrameHeight;
                }
            }
        }
Esempio n. 14
0
        public Connectors()
        {
            HeaderBar.BackgroundColor = UIColor.FromRGB(245, 245, 245);
            var label = new UILabel();

            label.Text            = "Connector Types: ";
            label.TextColor       = UIColor.Black;
            label.BackgroundColor = UIColor.Clear;
            label.TextAlignment   = UITextAlignment.Center;
            label.Frame           = new CGRect(20, 0, 180, 60);
            HeaderBar.AddSubview(label);

            straight = AddButton(220, "Images/Diagram/CSStraight.png");
            straight.TouchUpInside += Straight_TouchUpInside;
            HeaderBar.AddSubview(straight);

            curve = AddButton(280, "Images/Diagram/CSCurve.png");
            curve.TouchUpInside += Curve_TouchUpInside;;
            HeaderBar.AddSubview(curve);

            ortho = AddButton(340, "Images/Diagram/CSOrtho.png");
            ortho.TouchUpInside  += Ortho_TouchUpInside;
            ortho.BackgroundColor = UIColor.FromRGB(30, 144, 255);
            HeaderBar.AddSubview(ortho);

            selectionPicker1 = new UIPickerView();
            this.OptionView  = new UIView();

            PickerModel model = new PickerModel(verticalOrientationlist);

            selectionPicker1.Model = model;

            connectorStyle               = new UILabel();
            connectorStyle.Text          = "Connector Style";
            connectorStyle.TextColor     = UIColor.Black;
            connectorStyle.TextAlignment = UITextAlignment.Left;

            connectorSize               = new UILabel();
            connectorSize.Text          = "Connector Size";
            connectorSize.TextColor     = UIColor.Black;
            connectorSize.TextAlignment = UITextAlignment.Left;

            //Represent the vertical button
            connectorStyleButton = new UIButton();
            connectorStyleButton.SetTitle("Default", UIControlState.Normal);
            connectorStyleButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            connectorStyleButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
            connectorStyleButton.Layer.CornerRadius  = 8;
            connectorStyleButton.Layer.BorderWidth   = 2;
            connectorStyleButton.TouchUpInside      += ShowPicker1;
            connectorStyleButton.BackgroundColor     = UIColor.LightGray;
            connectorStyleButton.Layer.BorderColor   = UIColor.FromRGB(246, 246, 246).CGColor;

            plus = new UIButton();
            plus.BackgroundColor    = UIColor.White;
            plus.Layer.CornerRadius = 8;
            plus.Layer.BorderWidth  = 0.5f;
            plus.TouchUpInside     += Plus_TouchUpInside;
            plusimg       = new UIImageView();
            plusimg.Image = UIImage.FromBundle("Images/Diagram/CSplus.png");
            plus.AddSubview(plusimg);

            minus = new UIButton();
            minus.BackgroundColor    = UIColor.White;
            minus.Layer.CornerRadius = 8;
            minus.Layer.BorderWidth  = 0.5f;
            minus.TouchUpInside     += Minus_TouchUpInside;
            minusimg       = new UIImageView();
            minusimg.Image = UIImage.FromBundle("Images/Diagram/CSsub.png");
            minus.AddSubview(minusimg);

            sizeindicator                 = new UILabel();
            sizeindicator.Text            = width.ToString();
            sizeindicator.BackgroundColor = UIColor.Clear;
            sizeindicator.TextColor       = UIColor.Black;
            sizeindicator.TextAlignment   = UITextAlignment.Center;

            //Represent the button
            doneButton.SetTitle("Done\t", UIControlState.Normal);
            doneButton.SetTitleColor(UIColor.Black, UIControlState.Normal);
            doneButton.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
            doneButton.TouchUpInside      += HidePicker;
            doneButton.Hidden          = true;
            doneButton.BackgroundColor = UIColor.FromRGB(246, 246, 246);
            selectionPicker1.ShowSelectionIndicator = true;
            selectionPicker1.Hidden = true;

            Node node1  = new Node();
            Node node2  = new Node();
            Node node3  = new Node();
            Node node4  = new Node();
            Node node5  = new Node();
            Node node6  = new Node();
            Node node7  = new Node();
            Node node8  = new Node();
            Node node9  = new Node();
            Node node10 = new Node();
            Node node11 = new Node();

            diagram.IsReadOnly = true;

            node1  = AddNode(456, 180, "CEO", UIColor.FromRGB(201, 32, 61));
            node2  = AddNode(286, 396, "Manager", UIColor.FromRGB(23, 132, 206));
            node3  = AddNode(646, 396, "Manager", UIColor.FromRGB(23, 132, 206));
            node4  = AddNode(204, 612, "Team Lead", UIColor.FromRGB(4, 142, 135));
            node5  = AddNode(384, 612, "Team Lead", UIColor.FromRGB(4, 142, 135));
            node6  = AddNode(564, 612, "Team Lead", UIColor.FromRGB(4, 142, 135));
            node7  = AddNode(744, 612, "Team Lead", UIColor.FromRGB(4, 142, 135));
            node8  = AddNode(108, 828, "Trainee", UIColor.FromRGB(206, 98, 9));
            node9  = AddNode(324, 828, "Trainee", UIColor.FromRGB(206, 98, 9));
            node10 = AddNode(648, 828, "Trainee", UIColor.FromRGB(206, 98, 9));
            node11 = AddNode(864, 828, "Trainee", UIColor.FromRGB(206, 98, 9));


            diagram.AddNode(node1);
            diagram.AddNode(node2);
            diagram.AddNode(node3);
            diagram.AddNode(node4);
            diagram.AddNode(node5);
            diagram.AddNode(node6);
            diagram.AddNode(node7);
            diagram.AddNode(node8);
            diagram.AddNode(node9);
            diagram.AddNode(node10);
            diagram.AddNode(node11);
            diagram.AddConnector(AddConnector(node1, node2));
            diagram.AddConnector(AddConnector(node1, node3));
            diagram.AddConnector(AddConnector(node2, node4));
            diagram.AddConnector(AddConnector(node2, node5));
            diagram.AddConnector(AddConnector(node3, node6));
            diagram.AddConnector(AddConnector(node3, node7));
            diagram.AddConnector(AddConnector(node4, node8));
            diagram.AddConnector(AddConnector(node4, node9));
            diagram.AddConnector(AddConnector(node7, node10));
            diagram.AddConnector(AddConnector(node7, node11));
            diagram.Loaded += Diagram_Loaded;
            this.AddSubview(diagram);
            HeaderBar.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, 60);
            this.AddSubview(HeaderBar);
            model.PickerChanged += SelectedIndexChanged;
        }