public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			// set the background color of the view to white
			this.View.BackgroundColor = UIColor.Orange;

			this.Title = "Scroll View";

			// create our scroll view
			scrollView = new UIScrollView (
				new CGRect (0, 0, View.Frame.Width
					, View.Frame.Height));
			View.AddSubview (scrollView);

			// create our image view
			imageView = new UIImageView (UIImage.FromFile ("енот2.jpg"));
			scrollView.ContentSize = imageView.Image.Size;
			scrollView.AddSubview (imageView);

			// set allow zooming
			scrollView.MaximumZoomScale = 3f;
			scrollView.MinimumZoomScale = .1f;			
			scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return imageView; };
			//solo tap
			UITapGestureRecognizer solotap = new UITapGestureRecognizer(OnSoloTap) {
				NumberOfTapsRequired = 1 // solo tap
			};
			// Create a new Tap Gesture Recognizer
			UITapGestureRecognizer doubletap = new UITapGestureRecognizer(OnDoubleTap) {
				NumberOfTapsRequired = 2 // double tap
			};
			scrollView.AddGestureRecognizer (solotap);
			scrollView.AddGestureRecognizer(doubletap); // detect when the scrollView is double-tapped
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // set the background color of the view to white
            this.View.BackgroundColor = UIColor.White;

            this.Title = "Scroll View";

            // create our scroll view
            scrollView = new UIScrollView(
                new CGRect(0, 0, View.Frame.Width
                           , View.Frame.Height - NavigationController.NavigationBar.Frame.Height));
            View.AddSubview(scrollView);

            // create our image view
            imageView = new UIImageView(UIImage.FromFile("halloween.jpg"));
            scrollView.ContentSize = imageView.Image.Size;
            scrollView.AddSubview(imageView);

            // set allow zooming
            scrollView.MaximumZoomScale            = 3f;
            scrollView.MinimumZoomScale            = .1f;
            scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return(imageView); };

            // Create a new Tap Gesture Recognizer
            UITapGestureRecognizer doubletap = new UITapGestureRecognizer(OnDoubleTap)
            {
                NumberOfTapsRequired = 2                 // double tap
            };

            scrollView.AddGestureRecognizer(doubletap);             // detect when the scrollView is double-tapped
        }
Example #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            scrollView = new UIScrollView (
                new RectangleF (0, 0, View.Frame.Width,
                    View.Frame.Height));
            View.AddSubview (scrollView);

            imageView = new UIImageView (UIImage.FromBundle ("heinz-map.png"));

            scrollView.ContentSize = imageView.Image.Size;
            scrollView.AddSubview (imageView);
            scrollView.MaximumZoomScale = 0.7f;
            scrollView.MinimumZoomScale = 0.4f;
            scrollView.ContentOffset = new PointF (0, 500);
            scrollView.ZoomScale = 5f;
            scrollView.ViewForZoomingInScrollView += (UIScrollView svm) => {
                return imageView;
            };

            UITapGestureRecognizer doubletap =  new UITapGestureRecognizer(OnDoubleTap) {
                NumberOfTapsRequired = 2 // double tap
            };
            scrollView.AddGestureRecognizer(doubletap);
        }
Example #4
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            scrollview = new UIScrollView(new CoreGraphics.CGRect(0, 0,
                                                                  View.Frame.Width,
                                                                  View.Frame.Height));
            View.AddSubview(scrollview);


            imageview = new UIImageView(UIImage.FromBundle("Imagen.jpg"));
            scrollview.ContentSize = imageview.Image.Size;
            scrollview.AddSubview(imageview);

            scrollview.MaximumZoomScale            = 3f;
            scrollview.MinimumZoomScale            = .1f;
            scrollview.ViewForZoomingInScrollView += (UIScrollView sv) => { return(imageview); };

            UITapGestureRecognizer doubleTap = new UITapGestureRecognizer(OnDoubleTap)
            {
                NumberOfTapsRequired = 2
            };

            scrollview.AddGestureRecognizer(doubleTap);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.Title = "Photo Viewer";
            this.NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem("Back"
                                                                         , UIBarButtonItemStyle.Plain, (sender, args) =>
            {
                NavigationController.PopViewController(true);
            }), true);



            scrollView = new UIScrollView(new CGRect(0, 0, View.Frame.Width, View.Frame.Height - NavigationController.NavigationBar.Frame.Height));
            View.AddSubview(scrollView);

            imageView = new UIImageView(UIImage.FromFile("Company.png"));
            scrollView.ContentSize = imageView.Image.Size;
            scrollView.AddSubview(imageView);

            scrollView.MaximumZoomScale            = 3f;
            scrollView.MinimumZoomScale            = .1f;
            scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return(imageView); };

            UITapGestureRecognizer doubletap = new UITapGestureRecognizer(OnDoubleTap)
            {
                NumberOfTapsRequired = 2                 // double tap
            };

            scrollView.AddGestureRecognizer(doubletap);
        }
        public override void ViewWillAppear(bool animated)
        {
            InvokeOnMainThread(() =>
            {
                base.ViewWillAppear(animated);
                BTProgressHUD.Show("Loading Image", maskType: ProgressHUD.MaskType.Black);
                scrollView = new UIScrollView(new CGRect(0, 0, View.Frame.Width, View.Frame.Height - NavigationController.NavigationBar.Frame.Height));
                View.AddSubview(scrollView);
                image     = ImageClass.FromUrl(filepath);
                imageView = new UIImageView(image);
                scrollView.ContentSize = imageView.Image.Size;
                scrollView.AddSubview(imageView);

                scrollView.MaximumZoomScale            = 3f;
                scrollView.MinimumZoomScale            = .1f;
                scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return(imageView); };

                UITapGestureRecognizer doubletap = new UITapGestureRecognizer(OnDoubleTap)
                {
                    NumberOfTapsRequired = 2 // double tap
                };

                scrollView.AddGestureRecognizer(doubletap); // detect when the scrollView is double-tapped
                scrollView.SetZoomScale(0.25f, true);

                BTProgressHUD.Dismiss();
            });
        }
Example #7
0
        public SWTableViewCell(UITableViewCellStyle style, string reuseIdentifier,
                               UITableView containingTable, IEnumerable <UIButton> rightUtilityButtons,
                               UIView leftView, List <UIView> mainView)
            : base(style, reuseIdentifier)
        {
            scrollViewLeft            = leftView;
            this.rightUtilityButtons  = rightUtilityButtons.ToArray();
            scrollViewButtonViewRight = new SWUtilityButtonView(this.rightUtilityButtons, this);

            containingTableView = containingTable;
            height             = (float)containingTableView.RowHeight;
            scrollViewDelegate = new SWScrollViewDelegate(this);


            // Check if the UITableView will display Indices on the right. If that's the case, add a padding
            if (containingTableView.RespondsToSelector(new Selector("sectionIndexTitlesForTableView:")))
            {
                string[] indices = containingTableView.Source.SectionIndexTitles(containingTableView);
                additionalRightPadding = indices == null || indices.Length == 0 ? 0 : SectionIndexWidth;
            }

            // Set up scroll view that will host our cell content
            cellScrollView               = new UIScrollView(new RectangleF(0, 0, (float)Bounds.Width, height));
            cellScrollView.ContentSize   = new SizeF((float)Bounds.Width + UtilityButtonsPadding, height);
            cellScrollView.ContentOffset = ScrollViewContentOffset;
            cellScrollView.Delegate      = scrollViewDelegate;
            cellScrollView.ShowsHorizontalScrollIndicator = false;
            cellScrollView.ScrollsToTop = false;
            var tapGestureRecognizer = new UITapGestureRecognizer(OnScrollViewPressed);

            cellScrollView.AddGestureRecognizer(tapGestureRecognizer);

            // Set up the views that will hold the utility buttons
            scrollViewLeft.Frame = new RectangleF(ScrollLeftViewWidth, 0, ScrollLeftViewWidth, height);
            cellScrollView.AddSubview(scrollViewLeft);

            scrollViewButtonViewRight.Frame = new RectangleF((float)Bounds.Width, 0, RightUtilityButtonsWidth, height);

            cellScrollView.AddSubview(scrollViewButtonViewRight);


            // Populate the button views with utility buttons
            scrollViewButtonViewRight.PopulateUtilityButtons();
            // Create the content view that will live in our scroll view
            scrollViewContentView = new UIView(new RectangleF(ScrollLeftViewWidth, 0, (float)Bounds.Width, height));
            cellScrollView.AddSubview(scrollViewContentView);
            this.mainView = mainView;
            BuildMainView();

            AddSubview(cellScrollView);
            HideSwipedContent(false);
        }
        public override void ViewDidLoad()
        {
            View.BackgroundColor = UIColor.White;
            PHAsset asset = _imageCache.GetAsset(_image.LocalIdentifier);

            UIImage image = GetImage(asset);

            _imageView = new UIImageView(image)
            {
                MultipleTouchEnabled = true,
                UserInteractionEnabled = true,
                ContentMode = UIViewContentMode.ScaleAspectFit,
                Frame = new CGRect(new CGPoint(0, 0), image.Size),
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
            };

            _scrollView = new UIScrollView
            {
                //				Delegate = new ScrollViewDelegate(this),
                Frame = View.Frame,
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
            };
            _scrollView.ContentSize = image.Size;

            _scrollView.ViewForZoomingInScrollView += ScrollView_ViewForZoomingInScrollView;
            _scrollView.DidZoom += ScrollView_DidZoom;

            _scrollView.AddSubview(_imageView);
            View.AddSubview(_scrollView);

            //			UpdateImage(asset);

            var doubleTapRecognizer = new UITapGestureRecognizer(ScrollViewDoubleTapped)
            {
                NumberOfTapsRequired = 2,
                NumberOfTouchesRequired = 1
            };
            _scrollView.AddGestureRecognizer(doubleTapRecognizer);

            CGRect scrollViewFrame = _scrollView.Frame;
            nfloat scaleWidth = scrollViewFrame.Size.Width / _scrollView.ContentSize.Width;
            nfloat scaleHeight = scrollViewFrame.Size.Height / _scrollView.ContentSize.Height;
            double minScale = Math.Min(scaleWidth, scaleHeight);
            _scrollView.MinimumZoomScale = (nfloat)minScale;

            _scrollView.MaximumZoomScale = 1;
            _scrollView.ZoomScale = (nfloat)minScale;

            //CenterScrollViewContents();
        }
Example #9
0
        public SlidingCell(string resuseIdentifier)
            : base(UITableViewCellStyle.Default, resuseIdentifier)
        {
            scrollView = new UIScrollView();
            scrollView.ShowsHorizontalScrollIndicator = false;
            scrollView.Delegate = new SlidingCellScrollDelegate(this);
            tapGesture = new UITapGestureRecognizer ();
            tapGesture.AddTarget (() => {
                if (scrollView.ContentOffset != PointF.Empty)
                {
                    scrollView.SetContentOffset(PointF.Empty, false);
                    return;
                }

                var table = this.Superview.Superview as UITableView;
                var indexPath = table.IndexPathForCell (this);
                table.Source.RowSelected (table, indexPath);
            });
            scrollView.AddGestureRecognizer (tapGesture);
            ContentView.AddSubview(scrollView);

            scrollViewButtonView = new UIView();
            scrollView.AddSubview(scrollViewButtonView);

            moreButton = UIButton.FromType(UIButtonType.Custom);
            moreButton.BackgroundColor = UIColor.FromRGBA(0.78f, 0.78f, 0.8f, 1.0f);
            moreButton.SetTitle("More", UIControlState.Normal);
            moreButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            scrollViewButtonView.AddSubview(moreButton);

            deleteButton = UIButton.FromType(UIButtonType.Custom);
            deleteButton.BackgroundColor = UIColor.FromRGBA(1.0f, 0.231f, 0.188f, 1.0f);
            deleteButton.SetTitle("Delete", UIControlState.Normal);
            deleteButton.SetTitleColor(UIColor.White, UIControlState.Normal);
            scrollViewButtonView.AddSubview(deleteButton);

            scrollViewContentView = new UIView();
            scrollViewContentView.BackgroundColor = UIColor.White;
            scrollView.AddSubview(scrollViewContentView);

            scrollViewLabel = new UILabel();

            scrollViewContentView.AddSubview(scrollViewLabel);
            statusView = new UIImageView ();
            scrollView.AddSubview(statusView);
        }
Example #10
0
 public void UpdateScrollView(UIScrollView scrollView)
 {
     if (scrollView == null)
     {
         return;
     }
     if (_uiPanGestureRecognizer == null)
     {
         _uiPanGestureRecognizer = new UIPanGestureRecognizer(HandelePanGesture)
         {
             Delegate = this
         };
     }
     else
     {
         _scrollView.RemoveGestureRecognizer(_uiPanGestureRecognizer);
     }
     _scrollView = scrollView;
     _scrollView.AddGestureRecognizer(_uiPanGestureRecognizer);
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            View = new UIScrollView(View.Frame);

            var gradientLayer = new CAGradientLayer();

            gradientLayer.Colors = new [] {
                UIColor.FromRGB(241, 246, 250).CGColor,
                UIColor.FromRGB(222, 231, 240).CGColor
            };
            View.Layer.InsertSublayer(gradientLayer, 0);

            View.BackgroundColor = UIColor.FromRGB(230, 236, 245);

            var endEditingGestureRecognizer = new UITapGestureRecognizer(() => View.EndEditing(true))
            {
                ShouldBegin = IsTouchOutsideOfAnyButton
            };

            View.AddGestureRecognizer(endEditingGestureRecognizer);

            formView = CreateFormView();
                        #if __UNIFIED__
            formView.BackClick += (sender, e) => NavigationController.PopViewController(true);
                        #else
            formView.BackClick += (sender, e) => NavigationController.PopViewControllerAnimated(true);
                        #endif

            scrollView = new UIScrollView
            {
                Frame            = View.Bounds,
                ContentSize      = formView.Bounds.Size,
                AutoresizingMask = UIViewAutoresizing.FlexibleDimensions
            };

            scrollView.AddSubview(formView);

            View.AddSubview(scrollView);
        }
        public SwipeUpScrollViewDelegate(SlidingContentViewController swipeUpScrollViewController, UIScrollView scrollView,
                                         HitTestView hitTestView)
        {
            _slidingContentScrollViewController = swipeUpScrollViewController;
            _scrollView = scrollView;
            _scrollView.ShowsVerticalScrollIndicator   = false;
            _scrollView.ShowsHorizontalScrollIndicator = false;
            _scrollView.ClipsToBounds          = false;
            _scrollView.AlwaysBounceVertical   = true;
            _scrollView.DirectionalLockEnabled = true;

            _hitTestView = hitTestView;

            _scrollView.Scrolled          += (sender, e) => Scrolled();
            _scrollView.DecelerationEnded += (sender, e) => DecelerationEnded();

            var tapGestureRecogniser = new UITapGestureRecognizer();

            tapGestureRecogniser.AddTarget(ScrollViewTapped);
            _scrollView.AddGestureRecognizer(tapGestureRecogniser);
        }
        /// <summary>
        /// Creates a timeline scrollview using the thumbnail and subheading stackviews.
        /// </summary>
        private void CreateThumbnailView()
        {
            _timeLineScrollView = new UIScrollView(new CGRect(Constants.Origin,
                                                              View.Frame.Height - Constants.TimeLineScrollViewHeight - Constants.ResultsToolBarHeight,
                                                              View.Frame.Width, Constants.TimeLineScrollViewHeight))
            {
                ContentSize = new CGSize(InputImageEntries.Count * Constants.TotalThumbnailWidth,
                                         Constants.TimeLineScrollViewHeight),
                BackgroundColor        = Constants.TimeLineScrollViewColour,
                UserInteractionEnabled = true
            };
            View.AddSubview(_timeLineScrollView);
            _timeLineScrollView.AddSubview(_thumbnailStackView);
            _timeLineScrollView.AddSubview(_subHeadingStackView);

            _timeLineScrollView.AddGestureRecognizer(new UITapGestureRecognizer(tap =>
            {
                foreach (var imageView in _timeLineScrollView.Subviews[0].Subviews)
                {
                    var location     = tap.LocationInView(imageView);
                    var hitImageView = imageView.HitTest(location, null);
                    if (hitImageView == null)
                    {
                        continue;
                    }
                    InputImageEntry = InputImageEntries[(int)imageView.Tag];
                    GenerateTitle();
                    ClearBindings();
                    ClearPopover();
                    HighlightThumbnail(imageView.Tag);
                    CalculateScaledDimensions(InputImageEntries[(int)imageView.Tag].Image);
                    UpdateImage();
                    UpdateScrollViewDimensions();
                    UpdateCategoryColors(InputImageEntry);
                    DisplayBoundingBoxes();
                    UpdateSidebarContent();
                }
            }));
            HighlightThumbnail(0);
        }
Example #14
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // set the background color of the view to white
            this.View.BackgroundColor = UIColor.White;

            this.Title = "Mecut Dosya";

            // create our scroll view
            scrollView = new UIScrollView(
                new RectangleF(0, 0, View.Frame.Width
                               , View.Frame.Height - NavigationController.NavigationBar.Frame.Height));
            View.AddSubview(scrollView);



            string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            string localFilename = "original.jpg";
            string localPath     = Path.Combine(documentsPath, localFilename);



            // create our image view
            imageView = new UIImageView(UIImage.FromFile(localPath));
            scrollView.ContentSize = imageView.Image.Size;
            scrollView.AddSubview(imageView);

            // set allow zooming
            scrollView.MaximumZoomScale            = 3f;
            scrollView.MinimumZoomScale            = .1f;
            scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return(imageView); };

            // configure a double-tap gesture recognizer
            UITapGestureRecognizer doubletap = new UITapGestureRecognizer();

            doubletap.NumberOfTapsRequired = 2;
            doubletap.AddTarget(this, new MonoTouch.ObjCRuntime.Selector("DoubleTapSelector"));
            scrollView.AddGestureRecognizer(doubletap);
        }
        public override void ViewDidLoad()
        {
            try
            {
                //this.NavCtrl.NavigationBar.BarStyle = UIBarStyle.BlackTranslucent;
                //UINavigationBar.Appearance.BackgroundColor = UIColor.Clear;
                //NavCtrl.NavigationBar.BackgroundColor = UIColor.Clear;
                nfloat ScreenHeight = UIScreen.MainScreen.Bounds.Height;
                ScreenHeight = (ScreenHeight - 100) / 3;
                Boolean internetStatus = Reachability.IsHostReachable("https://www.google.com");
                if (internetStatus == false)
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title   = "Sorry",
                        Message = "Not connected to internet.Please connect and retry."
                    };

                    alert.AddButton("OK");
                    alert.Show();
                }
                BTProgressHUD.Dismiss();
                UIImageView backgroud = new UIImageView();
                backgroud.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, ScreenHeight - 20);
                backgroud.Image = new UIImage("proback.png");
                backgroud.UserInteractionEnabled = false;
                btnBack.UserInteractionEnabled   = false;
                //imgProfile.Frame = new CGRect((View.Frame.Width / 2) - 72, 3 * (backgroud.Frame.Height / 3), 144, 152);
                //UITapGestureRecognizer singleTap = new UITapGestureRecognizer();
                //singleTap.CancelsTouchesInView = false;
                //Scroll.AddGestureRecognizer(singleTap);
                //DismissKeyboardOnBackgroundTap();
                NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, KeyBoardDownNotification);
                NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidShowNotification, KeyBoardUpNotification);
                LoggingClass.LogInfo("Entered into Profile View", screenid);
                pickerDataModel = new StatePickerDataModel();
                pickerDataModel.Items.Add("---Select your state---");
                pickerDataModel.Items.Add("AL");
                pickerDataModel.Items.Add("AK");
                pickerDataModel.Items.Add("AZ");
                pickerDataModel.Items.Add("AR");
                pickerDataModel.Items.Add("CA");
                pickerDataModel.Items.Add("CO");
                pickerDataModel.Items.Add("CT");
                pickerDataModel.Items.Add("DE");
                pickerDataModel.Items.Add("FL");
                pickerDataModel.Items.Add("GA");
                pickerDataModel.Items.Add("HI");
                pickerDataModel.Items.Add("ID");
                pickerDataModel.Items.Add("IL");
                pickerDataModel.Items.Add("IN");
                pickerDataModel.Items.Add("IA");
                pickerDataModel.Items.Add("KS");
                pickerDataModel.Items.Add("KY");
                pickerDataModel.Items.Add("LA");
                pickerDataModel.Items.Add("ME");
                pickerDataModel.Items.Add("MD");
                pickerDataModel.Items.Add("MA");
                pickerDataModel.Items.Add("MI");
                pickerDataModel.Items.Add("MN");
                pickerDataModel.Items.Add("MS");
                pickerDataModel.Items.Add("MO");
                pickerDataModel.Items.Add("MT");
                pickerDataModel.Items.Add("NE");
                pickerDataModel.Items.Add("NV");
                pickerDataModel.Items.Add("NH");
                pickerDataModel.Items.Add("NJ");
                pickerDataModel.Items.Add("NM");
                pickerDataModel.Items.Add("NY");
                pickerDataModel.Items.Add("NC");
                pickerDataModel.Items.Add("ND");
                pickerDataModel.Items.Add("OH");
                pickerDataModel.Items.Add("OK");
                pickerDataModel.Items.Add("OR");
                pickerDataModel.Items.Add("PA");
                pickerDataModel.Items.Add("RI");
                pickerDataModel.Items.Add("SC");
                pickerDataModel.Items.Add("SD");
                pickerDataModel.Items.Add("TN");
                pickerDataModel.Items.Add("TX");
                pickerDataModel.Items.Add("UT");
                pickerDataModel.Items.Add("VT");
                pickerDataModel.Items.Add("VA");
                pickerDataModel.Items.Add("WA");
                pickerDataModel.Items.Add("WV");
                pickerDataModel.Items.Add("WI");
                pickerDataModel.Items.Add("WY");

                statePicker.Model = pickerDataModel;
                //statePicker.BackgroundColor = UIColor.Red;
                //statePicker = new UIPickerView(new CGRect(01,01,UIScreen.MainScreen.Bounds.Width,UIScreen.MainScreen.Bounds.Height));
                //	//UIScreen.MainScreen.Bounds.X-UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height, UIScreen.MainScreen.Bounds.Width, 180));
                StoreDataModel = new StorePickerDataModel();
                StoreDataModel.Items.Add("---Select preffered store---");
                StoreDataModel.Items.Add("Wall");
                StoreDataModel.Items.Add("Pt. Pleasant Beach");
                StoreDataModel.Items.Add("All");
                storePicker.Model = StoreDataModel;
                //statePicker.Select(5, 0, true);
                //LoggingClass.UploadErrorLogs();
                if (CurrentUser.RetreiveUserId() == 0)
                {
                    DownloadAsync();
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "This feature is allowed only for VIP Card holders",
                        //Message = "Coming Soon..."
                    };

                    alert.AddButton("OK");
                    alert.AddButton("Log in");
                    alert.AddButton("Know more");
                    alert.Clicked += (senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 1)
                        {
                            CurrentUser.Clear();
                            LoginViewController yourController = new LoginViewController();
                            yourController.nav      = NavCtrl;
                            yourController.RootTabs = CurrentUser.RootTabs;
                            NavCtrl.PushViewController(yourController, false);
                            //NavCtrl.PopViewController(false);
                            //NavCtrl.PopViewController(false);
                        }
                    };
                    alert.Clicked += (senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 2)
                        {
                            UIApplication.SharedApplication.OpenUrl(new NSUrl("https://hangoutz.azurewebsites.net/index.html"));
                        }
                    };
                    alert.Show();
                    btnUpdate.UserInteractionEnabled   = false;
                    txtLastName.UserInteractionEnabled = false;
                    txtPhone.UserInteractionEnabled    = false;
                    txtAddress.UserInteractionEnabled  = false;
                    txtZipCode.UserInteractionEnabled  = false;
                    txtEmail.UserInteractionEnabled    = false;
                    statePicker.UserInteractionEnabled = false;
                    storePicker.UserInteractionEnabled = false;
                    imgProfile.UserInteractionEnabled  = false;
                    btnPicEdit.UserInteractionEnabled  = false;
                }
                else
                {
                    DownloadAsync();
                    cRes = svc.GetCustomerDetails(CurrentUser.RetreiveUserId()).Result;
                    //txtFirstName.Text = cRes.customer.FirstName;
                    name             = cRes.customer.FirstName + " " + cRes.customer.LastName;
                    name             = name.Trim();
                    txtLastName.Text = name;                    //cRes.customer.FirstName+" "+cRes.customer.LastName;
                    //txtCity.Text = cRes.customer.City;
                    txtEmail.Text = cRes.customer.Email;
                    if (cRes.customer.PhoneNumber.Length != 10)
                    {
                        //cRes.customer.PhoneNumber
                        txtPhone.Text = cRes.customer.PhoneNumber;
                    }
                    txtCardnumber.Text = cRes.customer.CardNumber;
                    txtExpirydate.Text = cRes.customer.ExpireDate.ToString("MM-dd-yyyy");
                    txtZipCode.Text    = cRes.customer.Zip;
                    string state = cRes.customer.State;
                    if (pickerDataModel.Items.Contains(state))
                    {
                        int i = pickerDataModel.Items.FindIndex(x => x == state);
                        statePicker.Select(i, 0, false);
                    }
                    int prefStore = cRes.customer.PreferredStore;
                    storePicker.Select(prefStore, 0, false);
                    txtAddress.Text = cRes.customer.Address1 + cRes.customer.Address2 + cRes.customer.City;
                    //txtFirstName.ShouldReturn += (TextField) =>
                    // {
                    //  ((UITextField)TextField).ResignFirstResponder();
                    //  return true;
                    // };
                    txtLastName.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtEmail.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtPhone.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtAddress.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtZipCode.ShouldReturn += (TextField) =>
                    {
                        ((UITextField)TextField).ResignFirstResponder();
                        return(true);
                    };
                    txtZipCode.AccessibilityScroll(UIAccessibilityScrollDirection.Up);
                    btnUpdate.SetTitleColor(UIColor.Purple, UIControlState.Normal);
                    //btnEdit.SetTitleColor(UIColor.Purple, UIControlState.Normal);
                    //btnUpdate.TouchDown += (sender, e) =>
                    //{
                    //	BTProgressHUD.Show("Updating profile..."); //show spinner + text
                    //};
                    //btnUpdate.TouchUpInside += async (sender, e) =>
                    //{
                    //	if (txtPhone.Text.Length > 10 || txtPhone.Text.Length < 10)
                    //	{
                    //		BTProgressHUD.ShowErrorWithStatus("Phone number is invalid");
                    //	}
                    //	else if ((txtEmail.Text.Contains("@")) == false || (txtEmail.Text.Contains(".")) == false)
                    //	{
                    //		BTProgressHUD.ShowErrorWithStatus("Email is invalid");
                    //	}
                    //	else if ((txtZipCode.Text.Length!=5))
                    //	{
                    //		BTProgressHUD.ShowErrorWithStatus("Zipcode is invalid");
                    //	}
                    //	else
                    //	{
                    //		LoggingClass.LogInfo("Update button into Profile View", screenid);
                    //		Customer cust = new Customer();
                    //		cust.CustomerID = CurrentUser.RetreiveUserId();
                    //		cust.Address1 = txtAddress.Text;
                    //		name = txtLastName.Text;
                    //	name = name.Trim();
                    //	try
                    //	{
                    //		string[] str1 = name.Split(' ');
                    //		if (str1.Length == 2)
                    //		{
                    //			cust.FirstName = str1[0];
                    //			cust.LastName = str1[1];
                    //		}
                    //		else
                    //		{
                    //			cust.FirstName = str1[0] + str1[1];
                    //			cust.LastName = str1[2];
                    //		}
                    //	}
                    //	catch (Exception exe)
                    //	{
                    //		LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                    //	}
                    //		cust.Email = txtEmail.Text;
                    //		cust.PhoneNumber = txtPhone.Text;
                    //		cust.State = pickerDataModel.SelectedItem;
                    //		cust.Zip = txtZipCode.Text;
                    //		cust.PreferredStore = StoreDataModel.SelectedItem;
                    //		CurrentUser.PutStore(StoreDataModel.SelectedItem);
                    //		await svc.UpdateCustomer(cust);
                    //		BTProgressHUD.ShowSuccessWithStatus("Profile Updated.");
                    //		//try
                    //		//{
                    //		//	NavCtrl.PopViewController(true);
                    //		//	//NavCtrl.PushViewController(new FirstViewController(handle), false);
                    //		//}
                    //		//catch (Exception exe)
                    //		//{
                    //		//	LoggingClass.LogError(exe.Message, screenid, exe.StackTrace.ToString());
                    //		//}
                    //	}
                    //};
                    btnUpdate.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
                    UIImage imgbtnCam = UIImage.FromFile("cam.png");
                    imgbtnCam = ResizeImage(imgbtnCam, 25, 25);
                    btnPicEdit.SetImage(imgbtnCam, UIControlState.Normal);
                    btnBack.UserInteractionEnabled = false;
                    //btnPicEdit.SetTitle("Edit", UIControlState.Normal);
                    //try
                    //{
                    btnPicEdit.TouchUpInside += (sender, e) =>
                    {
                        try
                        {
                            UIAlertView alert = new UIAlertView()
                            {
                                Title = "Please choose an option to upload profile picture",
                                //Message = "Coming Soon..."
                            };
                            alert.AddButton("Cancel");
                            alert.AddButton("Camera");
                            alert.AddButton("Gallery");
                            alert.Clicked += (senderalert, buttonArgs) =>
                            {
                                if (buttonArgs.ButtonIndex == 1)
                                {
                                    try
                                    {
                                        IsCameraAuthorized();
                                        TweetStation.Camera.TakePicture(this, (obj) =>
                                        {
                                            var photo = obj.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
                                            var meta  = obj.ValueForKey(new NSString("UIImagePickerControllerMediaMetadata")) as NSDictionary;
                                            UploadProfilePic(photo);
                                            //ALAssetsLibrary library = new ALAssetsLibrary();
                                            //library.WriteImageToSavedPhotosAlbum(photo.CGImage, meta, (assetUrl, error) =>
                                            //{
                                            //	UploadProfilePic(assetUrl.ToString());
                                            //	Console.WriteLine("assetUrl:" + assetUrl);
                                            //});
                                            //var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                                        });
                                    }
                                    catch (Exception exe)
                                    {
                                        LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                                    }
                                }
                            };
                            alert.Clicked += (senderalert, buttonArgs) =>
                            {
                                if (buttonArgs.ButtonIndex == 2)
                                {
                                    imagePicker                       = new UIImagePickerController();
                                    imagePicker.SourceType            = UIImagePickerControllerSourceType.PhotoLibrary;
                                    imagePicker.MediaTypes            = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
                                    imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
                                    imagePicker.Canceled             += Handle_Canceled;
                                    NavCtrl.PresentModalViewController(imagePicker, true);
                                }
                            };
                            alert.Show();
                            //imagePicker = new UIImagePickerController();
                            //imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
                            //imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
                            //imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
                            //imagePicker.Canceled += Handle_Canceled;
                            //NavCtrl.PresentModalViewController(imagePicker, true);
                        }
                        catch (Exception exe)
                        {
                            LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                        }
                    };
                }
                //imgEmail.Image = new UIImage("mail.png");
                //imgAddr.Image = new UIImage("add.png");
                //imgPhone.Image = new UIImage("phone1.png");
                Scroll = new UIScrollView
                {
                    Frame            = new CGRect(0, 0, View.Frame.Width, View.Frame.Height),
                    ContentSize      = new CGSize(View.Frame.Width, View.Frame.Height),
                    BackgroundColor  = UIColor.White,
                    AutoresizingMask = UIViewAutoresizing.FlexibleHeight,
                };

                UIToolbar toolbar = new UIToolbar(new RectangleF(0.0f, 0.0f, Convert.ToSingle(this.View.Frame.Size.Width), 44.0f));
                toolbar.TintColor   = UIColor.White;
                toolbar.BarStyle    = UIBarStyle.Default;
                toolbar.Translucent = true;
                UITapGestureRecognizer taps = new UITapGestureRecognizer();
                taps.CancelsTouchesInView = false;
                taps.AddTarget(() => Scroll.EndEditing(true));
                Scroll.AddGestureRecognizer(taps);
                UIImage imgbtnUpdate = UIImage.FromFile("tick.png");
                imgbtnUpdate = ResizeImage(imgbtnUpdate, 25, 25);
                //var topBtn = new UIBarButtonItem(imgbtnUpdate, UIBarButtonItemStyle.Plain, async delegate
                //{
                btnUpdate.TouchUpInside += async delegate
                {
                    //if (txtPhone.Text.Length!=12)
                    //{
                    //	BTProgressHUD.ShowErrorWithStatus("Phone number is invalid");
                    //}
                    if ((txtEmail.Text.Contains("@")) == false || (txtEmail.Text.Contains(".")) == false)
                    {
                        BTProgressHUD.ShowErrorWithStatus("Email is invalid");
                    }
                    else if ((txtZipCode.Text.Length != 5))
                    {
                        BTProgressHUD.ShowErrorWithStatus("Zipcode is invalid");
                    }
                    else
                    {
                        BTProgressHUD.Show("Updating Profile...");
                        LoggingClass.LogInfo("Update button into Profile View", screenid);
                        Customer cust = new Customer();
                        cust.CustomerID = CurrentUser.RetreiveUserId();
                        cust.Address1   = txtAddress.Text;
                        //cust.FirstName = txtFirstName.Text;
                        name = txtLastName.Text;
                        name = name.Trim();
                        try
                        {
                            string[] str1 = name.Split(' ');
                            if (str1.Length == 2)
                            {
                                cust.FirstName = str1[0];
                                cust.LastName  = str1[1];
                            }
                            else
                            {
                                cust.FirstName = str1[0] + str1[1];
                                cust.LastName  = str1[2];
                            }
                        }
                        catch (Exception exe)
                        {
                            LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                        }
                        cust.Email       = txtEmail.Text;
                        cust.PhoneNumber = txtPhone.Text;

                        if (pickerDataModel.SelectedItem == "---Select your state---")
                        {
                            if (pickerDataModel.Items.Contains(cRes.customer.State))
                            {
                                int i = pickerDataModel.Items.FindIndex(x => x == cRes.customer.State);
                                statePicker.Select(i, 0, false);
                            }
                            cust.State = cRes.customer.State;
                        }
                        else
                        {
                            cust.State = pickerDataModel.SelectedItem;
                        }
                        cust.Zip = txtZipCode.Text;
                        if (StoreDataModel.SelectedItem == 0)
                        {
                            cust.PreferredStore = cRes.customer.PreferredStore;
                            storePicker.Select(cRes.customer.PreferredStore, 0, false);
                            CurrentUser.PutStore(cust.PreferredStore);
                        }
                        else
                        {
                            cust.PreferredStore = StoreDataModel.SelectedItem;
                            CurrentUser.PutStore(cust.PreferredStore);
                        }
                        await svc.UpdateCustomer(cust);

                        BTProgressHUD.ShowSuccessWithStatus("Profile Updated.");
                    }
                };
                imgProfile.ClipsToBounds   = true;
                imgProfile.BackgroundColor = UIColor.White;
                //NavigationController.NavigationBar.TopItem.SetRightBarButtonItem(topBtn, true);
                btnBack.BackgroundColor = UIColor.FromRGB(93, 93, 93);
                Scroll.AddSubview(backgroud);
                Scroll.AddSubview(btnBack);
                //Scroll.AddSubview(imgAddr);
                //Scroll.AddSubview(imgPhone);
                //Scroll.AddSubview(imgEmail);
                Scroll.AddSubview(txtEmail);
                Scroll.AddSubview(statePicker);
                Scroll.AddSubview(storePicker);
                Scroll.AddSubview(txtPhone);
                Scroll.AddSubview(txtZipCode);
                //Scroll.AddSubview(txtFirstName);
                Scroll.AddSubview(txtLastName);
                Scroll.AddSubview(txtAddress);
                Scroll.AddSubview(imgProfile);
                Scroll.AddSubview(btnPicEdit);
                Scroll.AddSubview(lblEmail);
                Scroll.AddSubview(lblState);
                Scroll.AddSubview(lblMobile);
                Scroll.AddSubview(lblAddress);
                Scroll.AddSubview(lblZipcode);
                //Scroll.AddSubview(lblFirstname);
                Scroll.AddSubview(lblLastname);
                Scroll.AddSubview(btnUpdate);
                Scroll.AddSubview(lblStorePi);
                Scroll.AddSubview(lblExpiryDate);
                Scroll.AddSubview(txtExpirydate);
                Scroll.AddSubview(lblcardnumber);
                Scroll.AddSubview(txtCardnumber);

                //View.AddSubview(Scroll);

                for (int i = 0; i < Scroll.Subviews.Length; i++)
                {
                    nfloat n = Scroll.Subviews[i].Frame.Size.Height;
                    h = h + n;
                }
                //Console.WriteLine(h);
                Scroll.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width, h - 200);
                View = (Scroll);
            }
            catch (Exception ex)
            {
                LoggingClass.LogError(ex.ToString(), screenid, ex.StackTrace);
            }
        }
        public FeedCellBuilder(UIView contentView)
        {
            _contentView = contentView;

            _moreButton       = new UIButton();
            _moreButton.Frame = new CGRect(_contentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal);
            //_moreButton.BackgroundColor = UIColor.Black;
            _contentView.AddSubview(_moreButton);

            _avatarImage = new UIImageView(new CGRect(leftMargin, 20, 30, 30));
            _contentView.AddSubview(_avatarImage);

            var authorX = _avatarImage.Frame.Right + 10;

            _author      = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _moreButton.Frame.Left - authorX, 18));
            _author.Font = Constants.Semibold14;
            //_author.BackgroundColor = UIColor.Yellow;
            _author.LineBreakMode = UILineBreakMode.TailTruncation;
            _author.TextColor     = Constants.R15G24B30;
            _contentView.AddSubview(_author);

            _timestamp      = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _moreButton.Frame.Left - authorX, 16));
            _timestamp.Font = Constants.Regular12;
            //_timestamp.BackgroundColor = UIColor.Green;
            _timestamp.LineBreakMode = UILineBreakMode.TailTruncation;
            _timestamp.TextColor     = Constants.R151G155B158;
            _contentView.AddSubview(_timestamp);

            _photoScroll = new UIScrollView();
            _photoScroll.ShowsHorizontalScrollIndicator = false;
            _photoScroll.Bounces       = false;
            _photoScroll.PagingEnabled = true;
            contentView.AddSubview(_photoScroll);

            _likes                        = new UILabel();
            _likes.Font                   = Constants.Semibold14;
            _likes.LineBreakMode          = UILineBreakMode.TailTruncation;
            _likes.TextColor              = Constants.R15G24B30;
            _likes.UserInteractionEnabled = true;
            _contentView.AddSubview(_likes);

            _flags      = new UILabel();
            _flags.Font = Constants.Semibold14;
            //_flags.BackgroundColor = UIColor.Orange;
            _flags.LineBreakMode          = UILineBreakMode.TailTruncation;
            _flags.TextColor              = Constants.R15G24B30;
            _flags.UserInteractionEnabled = true;
            _contentView.AddSubview(_flags);

            _rewards      = new UILabel();
            _rewards.Font = Constants.Semibold14;
            //_rewards.BackgroundColor = UIColor.Orange;
            _rewards.LineBreakMode          = UILineBreakMode.TailTruncation;
            _rewards.TextColor              = Constants.R15G24B30;
            _rewards.UserInteractionEnabled = true;
            _contentView.AddSubview(_rewards);

            _like             = new UIImageView();
            _like.ContentMode = UIViewContentMode.Center;
            _contentView.AddSubview(_like);

            _verticalSeparator = new UIView();
            _verticalSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_verticalSeparator);

            _topSeparator = new UIView();
            _topSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_topSeparator);

            var _noLinkAttribute = new UIStringAttributes
            {
                Font            = Constants.Regular14,
                ForegroundColor = Constants.R151G155B158,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString("...", _noLinkAttribute));

            _attributedLabel = new TTTAttributedLabel();
            _attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;
            var prop = new NSDictionary();

            _attributedLabel.LinkAttributes       = prop;
            _attributedLabel.ActiveLinkAttributes = prop;
            _attributedLabel.Font  = Constants.Regular14;
            _attributedLabel.Lines = 3;
            _attributedLabel.UserInteractionEnabled = true;
            _attributedLabel.Enabled = true;
            _attributedLabel.AttributedTruncationToken = at;
            //_attributedLabel.BackgroundColor = UIColor.Blue;
            _contentView.AddSubview(_attributedLabel);

            _comments      = new UILabel();
            _comments.Font = Constants.Regular14;
            //_comments.BackgroundColor = UIColor.DarkGray;
            _comments.LineBreakMode          = UILineBreakMode.TailTruncation;
            _comments.TextColor              = Constants.R151G155B158;
            _comments.UserInteractionEnabled = true;
            _comments.TextAlignment          = UITextAlignment.Center;
            _contentView.AddSubview(_comments);

            _bottomSeparator = new UIView();
            _bottomSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_bottomSeparator);

            _profileTapView = new UIView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width / 2, likeButtonWidthConst));
            _profileTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_profileTapView);

            _likersTapView = new UIView();
            _likersTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_likersTapView);

            likersY            = underPhotoPanelHeight / 2 - likersImageSide / 2;
            likersCornerRadius = likersImageSide / 2;

            var liketap = new UITapGestureRecognizer(LikeTap);

            _like.AddGestureRecognizer(liketap);

            UITapGestureRecognizer tap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Preview, _currentPost);
            });

            _photoScroll.AddGestureRecognizer(tap);

            var profileTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });
            var headerTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });

            _profileTapView.AddGestureRecognizer(headerTap);
            _rewards.AddGestureRecognizer(profileTap);

            var commentTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Comments, _currentPost);
            });

            _comments.AddGestureRecognizer(commentTap);

            var netVotesTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Voters, _currentPost);
            });

            _likersTapView.AddGestureRecognizer(netVotesTap);

            var flagersTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Flagers, _currentPost);
            });

            _flags.AddGestureRecognizer(flagersTap);

            _moreButton.TouchDown += FlagButton_TouchDown;
        }
Example #17
0
        void Internal_ViewDidLoad(bool v)
        {
            try
            {
                //Getting Screen height and width
                nfloat ScreenHeight = UIScreen.MainScreen.Bounds.Height;
                nfloat ScreenWidth  = UIScreen.MainScreen.Bounds.Width;
                //Caliculating height for profile background image
                nfloat probackimgheight = (ScreenHeight - 100) / 3;
                nfloat imgprofile       = 120;
                nfloat Space            = 30;
                nfloat strtx            = 90;
                NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, KeyBoardDownNotification);
                NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.DidShowNotification, KeyBoardUpNotification);

                pickerDataModel = new StatePickerDataModel();
                //pickerDataModel.Items.Add("Select your state");
                pickerDataModel.Items.Add("AL");
                pickerDataModel.Items.Add("AK");
                pickerDataModel.Items.Add("AZ");
                pickerDataModel.Items.Add("AR");
                pickerDataModel.Items.Add("CA");
                pickerDataModel.Items.Add("CO");
                pickerDataModel.Items.Add("CT");
                pickerDataModel.Items.Add("DE");
                pickerDataModel.Items.Add("FL");
                pickerDataModel.Items.Add("GA");
                pickerDataModel.Items.Add("HI");
                pickerDataModel.Items.Add("ID");
                pickerDataModel.Items.Add("IL");
                pickerDataModel.Items.Add("IN");
                pickerDataModel.Items.Add("IA");
                pickerDataModel.Items.Add("KS");
                pickerDataModel.Items.Add("KY");
                pickerDataModel.Items.Add("LA");
                pickerDataModel.Items.Add("ME");
                pickerDataModel.Items.Add("MD");
                pickerDataModel.Items.Add("MA");
                pickerDataModel.Items.Add("MI");
                pickerDataModel.Items.Add("MN");
                pickerDataModel.Items.Add("MS");
                pickerDataModel.Items.Add("MO");
                pickerDataModel.Items.Add("MT");
                pickerDataModel.Items.Add("NE");
                pickerDataModel.Items.Add("NV");
                pickerDataModel.Items.Add("NH");
                pickerDataModel.Items.Add("NJ");
                pickerDataModel.Items.Add("NM");
                pickerDataModel.Items.Add("NY");
                pickerDataModel.Items.Add("NC");
                pickerDataModel.Items.Add("ND");
                pickerDataModel.Items.Add("OH");
                pickerDataModel.Items.Add("OK");
                pickerDataModel.Items.Add("OR");
                pickerDataModel.Items.Add("PA");
                pickerDataModel.Items.Add("RI");
                pickerDataModel.Items.Add("SC");
                pickerDataModel.Items.Add("SD");
                pickerDataModel.Items.Add("TN");
                pickerDataModel.Items.Add("TX");
                pickerDataModel.Items.Add("UT");
                pickerDataModel.Items.Add("VT");
                pickerDataModel.Items.Add("VA");
                pickerDataModel.Items.Add("WA");
                pickerDataModel.Items.Add("WV");
                pickerDataModel.Items.Add("WI");
                pickerDataModel.Items.Add("WY");

                StoreDataModel = new StorePickerDataModel();
                StoreDataModel.Items.Add("Select your store");
                StoreDataModel.Items.Add("Wall");
                StoreDataModel.Items.Add("Pt. Pleasant Beach");
                StoreDataModel.Items.Add("All");

                BTProgressHUD.Dismiss();

                //Background image controller
                UIImageView backgroud = new UIImageView();
                backgroud.Frame = new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width, probackimgheight - 20);
                backgroud.Image = new UIImage("proback.png");
                backgroud.UserInteractionEnabled = false;

                nfloat x = (ScreenWidth / 2) - (imgprofile / 2);
                x = x - 10;
                nfloat y = ((backgroud.Frame.Height) / 2) - 30;

                UIBotton btnImageBack = new UIBotton
                {
                    UserInteractionEnabled = false,
                    Frame           = new CGRect(x, y + 10, imgprofile + 20, imgprofile + 20),
                    BackgroundColor = UIColor.Black
                };
                imgprofilepic = new UIImageView
                {
                    Frame           = new CGRect(x + 10, y + 20, imgprofile, imgprofile),
                    BackgroundColor = UIColor.White
                };
                imgprofilepic.Image = new UIImage("Images/loadin.png");

                btnChange = new UIButton
                {
                    Frame = new CGRect(x + (imgprofilepic.Frame.Width - 10), y + (imgprofilepic.Frame.Height), 30, 30)
                };

                UIImage imgbtnCam = UIImage.FromFile("edit.png");
                imgbtnCam = ResizeImage(imgbtnCam, 25, 25);
                btnChange.SetImage(imgbtnCam, UIControlState.Normal);
                btnChange.SetBackgroundImage(imgbtnCam, UIControlState.Normal);
                //btnChange.BackgroundColor = UIColor.Blue;
                ScreenWidth  = 25;
                ScreenHeight = UIScreen.MainScreen.Bounds.Width - (strtx + 10);
                y            = y + imgprofilepic.Bounds.Height + 50;

                UILabel lblName = new UILabel
                {
                    Text  = "Name:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                txtName = new UITextField
                {
                    Frame       = new CGRect(strtx, y, ScreenHeight, ScreenWidth),
                    Placeholder = "E.g. John Doe",
                    BorderStyle = UITextBorderStyle.RoundedRect,
                    Font        = UIFont.FromName("HelveticaNeue", 13f)
                                  //UserInteractionEnabled=true
                };
                txtName.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + Space;
                UILabel lblEmail = new UILabel
                {
                    Text  = "Email:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                //y = y + lblEmail.Bounds.Height;
                txtEmail = new UITextField
                {
                    Placeholder  = "E.g. [email protected]",
                    Frame        = new CGRect(strtx, y, ScreenHeight, ScreenWidth),
                    BorderStyle  = UITextBorderStyle.RoundedRect,
                    KeyboardType = UIKeyboardType.EmailAddress,
                    Font         = UIFont.FromName("HelveticaNeue", 13f)
                                   //UserInteractionEnabled=true
                };
                txtEmail.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + Space;
                UILabel lblMobile = new UILabel
                {
                    Text  = "Mobile:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };

                txtFirst3 = new UITextField
                {
                    Placeholder = "123",
                    //Text="123",
                    Frame        = new CGRect(strtx, y, 50, ScreenWidth),
                    BorderStyle  = UITextBorderStyle.RoundedRect,
                    KeyboardType = UIKeyboardType.NumberPad,
                    Font         = UIFont.FromName("HelveticaNeue", 13f)
                                   //UserInteractionEnabled = true
                };
                //strtx = strtx + 10;
                UILabel symIphon1 = new UILabel
                {
                    Text  = "-",
                    Frame = new CGRect(strtx + 50, y, 10, ScreenWidth)
                };
                txtSecond3 = new UITextField
                {
                    Placeholder = "456",
                    //Text="123",
                    Frame        = new CGRect(strtx + 60, y, 50, ScreenWidth),
                    BorderStyle  = UITextBorderStyle.RoundedRect,
                    KeyboardType = UIKeyboardType.NumberPad,
                    Font         = UIFont.FromName("HelveticaNeue", 13f)
                };
                UILabel symIphon2 = new UILabel
                {
                    Text  = "-",
                    Frame = new CGRect(strtx + 110, y, 10, ScreenWidth)
                };
                txtLast4 = new UITextField
                {
                    Placeholder = "7890",
                    //Text="1234",
                    Frame        = new CGRect(strtx + 120, y, UIScreen.MainScreen.Bounds.Width - (strtx + 130), ScreenWidth),
                    BorderStyle  = UITextBorderStyle.RoundedRect,
                    KeyboardType = UIKeyboardType.NumberPad,
                    Font         = UIFont.FromName("HelveticaNeue", 13f)
                                   //UserInteractionEnable
                };
                txtLast4.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                txtFirst3.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                txtSecond3.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + Space;
                UILabel lblAddress = new UILabel
                {
                    Text  = "Address:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                txtAddress = new UITextField
                {
                    Placeholder = "E.g. 1600 Pennsylvania Ave NW",
                    Frame       = new CGRect(strtx, y, ScreenHeight, ScreenWidth),
                    BorderStyle = UITextBorderStyle.RoundedRect,
                    Font        = UIFont.FromName("HelveticaNeue", 13f)
                };
                txtAddress.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + Space;
                UILabel lblState = new UILabel
                {
                    Text  = "State:",
                    Frame = new CGRect(10, y + 25, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                stpicker.Frame = new CGRect(strtx, y, 50, 90);
                //stpicker.BackgroundColor = UIColor.LightGray;
                stpicker.Model = pickerDataModel;
                //stpicker.Hidden = true;

                //
                nfloat  zipx       = strtx + 80;
                UILabel lblZipcode = new UILabel
                {
                    Text  = "Zipcode:",
                    Frame = new CGRect(zipx, y + 25, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                txtZipcode = new UITextField
                {
                    Placeholder            = "E.g. 08632",
                    Frame                  = new CGRect(zipx + 70, y + 25, 80, ScreenWidth),
                    BorderStyle            = UITextBorderStyle.RoundedRect,
                    UserInteractionEnabled = true,
                    KeyboardType           = UIKeyboardType.NumberPad,
                    Font = UIFont.FromName("HelveticaNeue", 13f)
                };
                txtZipcode.ShouldReturn += (TextField) =>
                {
                    ((UITextField)TextField).ResignFirstResponder();
                    return(true);
                };
                y = y + 90;
                //y = y + Space;
                UILabel lblCardExpiry = new UILabel
                {
                    Text  = "Expiry:",
                    Frame = new CGRect(UIScreen.MainScreen.Bounds.Width / 2, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                UILabel lblCardDate = new UILabel
                {
                    Frame = new CGRect((UIScreen.MainScreen.Bounds.Width / 2) + 70, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue", 13f)
                };
                //y = y + Space;
                UILabel lblcardnumber = new UILabel
                {
                    Text  = "Card #:",
                    Frame = new CGRect(10, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                UILabel CardNumer = new UILabel
                {
                    Frame = new CGRect(strtx, y, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue", 13f)
                };
                y = y + Space;
                UILabel lblMystore = new UILabel
                {
                    Text  = "My Store:",
                    Frame = new CGRect(10, y + 25, ScreenHeight, ScreenWidth),
                    Font  = UIFont.FromName("HelveticaNeue-Bold", 16f)
                };
                StorePicker.Frame = new CGRect(strtx, y, UIScreen.MainScreen.Bounds.Width - (strtx + 10), 90);
                //StorePicker.BackgroundColor = UIColor.LightGray;
                StorePicker.Hidden = false;
                y         = y + 90;
                btnUpdate = new UIButton();
                btnUpdate.SetTitle("Update", UIControlState.Normal);
                btnUpdate.Frame = new CGRect(UIScreen.MainScreen.Bounds.Width / 2 - 25, y, 100, 30);
                btnUpdate.SetTitleColor(UIColor.White, UIControlState.Normal);
                btnUpdate.BackgroundColor     = UIColor.Purple;
                btnUpdate.Font                = UIFont.FromName("HelveticaNeue-Bold", 16f);
                btnUpdate.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
                StorePicker.Model             = StoreDataModel;
                Scroll = new UIScrollView
                {
                    Frame            = new CGRect(0, 0, View.Frame.Width, View.Frame.Height),
                    ContentSize      = new CGSize(View.Frame.Width, View.Frame.Height),
                    BackgroundColor  = UIColor.White,
                    AutoresizingMask = UIViewAutoresizing.FlexibleHeight,
                };
                UITapGestureRecognizer taps = new UITapGestureRecognizer();
                taps.CancelsTouchesInView = false;
                taps.AddTarget(() => Scroll.EndEditing(true));

                if (CurrentUser.RetreiveUserId() == 0)
                {
                    Scroll.AddSubview(stpicker);
                    Scroll.AddSubview(StorePicker);
                    StorePicker.UserInteractionEnabled = false;
                    stpicker.UserInteractionEnabled    = false;
                    txtName.UserInteractionEnabled     = false;
                    txtEmail.UserInteractionEnabled    = false;
                    txtFirst3.UserInteractionEnabled   = false;
                    txtSecond3.UserInteractionEnabled  = false;
                    txtLast4.UserInteractionEnabled    = false;
                    txtAddress.UserInteractionEnabled  = false;
                    txtZipcode.UserInteractionEnabled  = false;
                    btnChange.UserInteractionEnabled   = false;
                    btnUpdate.UserInteractionEnabled   = false;
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "This feature is allowed only for VIP Card holders",
                        //Message = "Coming Soon..."
                    };

                    alert.AddButton("OK");
                    alert.AddButton("Log in");
                    alert.AddButton("Know more");
                    alert.Clicked += (senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 1)
                        {
                            CurrentUser.Clear();
                            LoginViewController yourController = new LoginViewController();
                            yourController.nav      = NavCtrl;
                            yourController.RootTabs = CurrentUser.RootTabs;
                            NavCtrl.PushViewController(yourController, false);
                        }
                    };
                    alert.Clicked += (senderalert, buttonArgs) =>
                    {
                        if (buttonArgs.ButtonIndex == 2)
                        {
                            UIApplication.SharedApplication.OpenUrl(new NSUrl("https://hangoutz.azurewebsites.net/index.html"));
                        }
                    };
                    alert.Show();
                }
                else
                {
                    Scroll.AddSubview(stpicker);
                    Scroll.AddSubview(StorePicker);
                    DownloadAsync();
                    cRes = svc.GetCustomerDetails(CurrentUser.RetreiveUserId()).Result;
                    if (cRes.customer.CardNumber != null && cRes.customer.CardNumber != "")
                    {
                        name          = cRes.customer.FirstName + " " + cRes.customer.LastName;
                        name          = name.Trim();
                        txtName.Text  = name;
                        txtEmail.Text = cRes.customer.Email;
                        if (cRes.customer.PhoneNumber != null && cRes.customer.PhoneNumber != "")
                        {
                            //if (cRes.customer.PhoneNumber.Length != 10)
                            //{
                            //Console.WriteLine(cRes.customer.PhoneNumber);
                            txtFirst3.Text = cRes.customer.PhoneNumber.Substring(0, 3);
                            //Console.WriteLine(cRes.customer.PhoneNumber.Substring(0, 3));
                            txtSecond3.Text = cRes.customer.PhoneNumber.Substring(3, 3);
                            //Console.WriteLine(cRes.customer.PhoneNumber.Substring(3, 3));
                            txtLast4.Text = cRes.customer.PhoneNumber.Substring(6);
                            //Console.WriteLine(cRes.customer.PhoneNumber.Substring(6));
                            //}
                        }
                        CardNumer.Text   = cRes.customer.CardNumber;
                        lblCardDate.Text = cRes.customer.ExpireDate.ToString("MM-dd-yyyy");
                        txtZipcode.Text  = cRes.customer.Zip;
                        string state = cRes.customer.State;
                        if (pickerDataModel.Items.Contains(state))
                        {
                            int i = pickerDataModel.Items.FindIndex(n => n == state);
                            stpicker.Select(i, 0, false);
                        }
                        int prefStore = cRes.customer.PreferredStore;
                        StorePicker.Select(prefStore, 0, false);
                        txtAddress.Text = cRes.customer.Address1 + cRes.customer.Address2 + cRes.customer.City;
                        txtZipcode.AccessibilityScroll(UIAccessibilityScrollDirection.Up);
                        btnChange.TouchUpInside += (sender, e) =>
                        {
                            try
                            {
                                UIAlertView alert = new UIAlertView()
                                {
                                    Title = "Please choose an option to upload profile picture",
                                    //Message = "Coming Soon..."
                                };
                                alert.AddButton("Cancel");
                                alert.AddButton("Camera");
                                alert.AddButton("Gallery");
                                alert.Clicked += (senderalert, buttonArgs) =>
                                {
                                    if (buttonArgs.ButtonIndex == 1)
                                    {
                                        try
                                        {
                                            IsCameraAuthorized();
                                            TweetStation.Camera.TakePicture(this, (obj) =>
                                            {
                                                var photo = obj.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
                                                var meta  = obj.ValueForKey(new NSString("UIImagePickerControllerMediaMetadata")) as NSDictionary;
                                                UploadProfilePic(photo);
                                            });
                                        }
                                        catch (Exception exe)
                                        {
                                            LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                                        }
                                    }
                                };
                                alert.Clicked += (senderalert, buttonArgs) =>
                                {
                                    if (buttonArgs.ButtonIndex == 2)
                                    {
                                        imagePicker                       = new UIImagePickerController();
                                        imagePicker.SourceType            = UIImagePickerControllerSourceType.PhotoLibrary;
                                        imagePicker.MediaTypes            = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary);
                                        imagePicker.FinishedPickingMedia += Handle_FinishedPickingMedia;
                                        imagePicker.Canceled             += Handle_Canceled;
                                        NavCtrl.PresentModalViewController(imagePicker, true);
                                    }
                                };
                                alert.Show();
                            }
                            catch (Exception exe)
                            {
                                LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                            }
                        };

                        btnUpdate.TouchUpInside += async delegate
                        {
                            string txtMobilenumber = txtFirst3.Text + txtSecond3.Text + txtLast4.Text;
                            if (txtMobilenumber.Length != 10)
                            {
                                BTProgressHUD.ShowErrorWithStatus("Phone number is invalid", 3000);
                            }
                            if ((txtEmail.Text.Contains("@")) == false || (txtEmail.Text.Contains(".")) == false)
                            {
                                BTProgressHUD.ShowErrorWithStatus("Email is invalid", 3000);
                            }
                            else if ((txtZipcode.Text.Length != 5))
                            {
                                BTProgressHUD.ShowErrorWithStatus("Zipcode is invalid", 3000);
                            }
                            else if (txtFirst3.Text.Length != 3 || txtSecond3.Text.Length != 3 || txtLast4.Text.Length != 4)
                            {
                                BTProgressHUD.ShowErrorWithStatus("Phone number is invalid", 3000);
                            }
                            else
                            {
                                BTProgressHUD.Show("Updating Profile...");
                                LoggingClass.LogInfo("Update button into Profile View", screenid);
                                Customer cust = new Customer();
                                cust.CustomerID = CurrentUser.RetreiveUserId();
                                cust.Address1   = txtAddress.Text;
                                name            = txtName.Text;
                                name            = name.Trim();
                                try
                                {
                                    string[] str1 = name.Split(' ');
                                    if (str1.Length == 2)
                                    {
                                        cust.FirstName = str1[0];
                                        cust.LastName  = str1[1];
                                    }
                                    else
                                    {
                                        cust.FirstName = str1[0] + str1[1];
                                        cust.LastName  = str1[2];
                                    }
                                }
                                catch (Exception exe)
                                {
                                    LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
                                }
                                cust.Email       = txtEmail.Text;
                                cust.PhoneNumber = txtMobilenumber;

                                if (pickerDataModel.SelectedItem == "AL")
                                {
                                    if (pickerDataModel.Items.Contains(cRes.customer.State))
                                    {
                                        int i = pickerDataModel.Items.FindIndex(n => n == cRes.customer.State);
                                        stpicker.Select(i, 0, false);
                                    }
                                    cust.State = cRes.customer.State;
                                }
                                else
                                {
                                    cust.State = pickerDataModel.SelectedItem;
                                }
                                cust.Zip = txtZipcode.Text;
                                if (StoreDataModel.SelectedItem == 0)
                                {
                                    cust.PreferredStore = cRes.customer.PreferredStore;
                                    StorePicker.Select(cRes.customer.PreferredStore, 0, false);
                                    CurrentUser.PutStore(cust.PreferredStore);
                                }
                                else
                                {
                                    cust.PreferredStore = StoreDataModel.SelectedItem;
                                    CurrentUser.PutStore(cust.PreferredStore);
                                }
                                await svc.UpdateCustomer(cust);

                                BTProgressHUD.ShowSuccessWithStatus("Profile Updated.");
                            }
                        };
                    }
                    else
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title   = "Sorry",
                            Message = "Something went wrong. We are on it"
                        };

                        alert.AddButton("OK");
                        alert.Show();
                    }
                }

                Scroll.AddGestureRecognizer(taps);
                Scroll.AddSubview(backgroud);
                Scroll.AddSubview(btnImageBack);
                Scroll.AddSubview(imgprofilepic);
                Scroll.AddSubview(btnChange);
                Scroll.AddSubview(lblName);
                Scroll.AddSubview(txtName);
                Scroll.AddSubview(lblEmail);
                Scroll.AddSubview(txtEmail);
                Scroll.AddSubview(lblMobile);
                Scroll.AddSubview(txtFirst3);
                Scroll.AddSubview(symIphon1);
                Scroll.AddSubview(txtSecond3);
                Scroll.AddSubview(symIphon2);
                Scroll.AddSubview(txtLast4);
                Scroll.AddSubview(lblState);
                //Scroll.AddSubview(stpicker);
                Scroll.AddSubview(lblAddress);
                Scroll.AddSubview(txtAddress);
                Scroll.AddSubview(lblZipcode);
                Scroll.AddSubview(txtZipcode);
                //Scroll.AddSubview(StorePicker);
                Scroll.AddSubview(lblMystore);
                Scroll.AddSubview(lblCardExpiry);
                Scroll.AddSubview(lblCardDate);
                Scroll.AddSubview(lblcardnumber);
                Scroll.AddSubview(CardNumer);
                Scroll.AddSubview(btnUpdate);

                //for (int i = 0; i<Scroll.Subviews.Length ; i++)
                //{
                //	nfloat n = Scroll.Subviews[i].Bounds.Height;// Frame.Size.Height;
                //	h = h + n;
                //}
                //Console.WriteLine(h+"\n"+ScreenHeight);
                h = y + 50;
                Scroll.ContentSize = new CGSize(UIScreen.MainScreen.Bounds.Width, h);
                View = (Scroll);
            }
            catch (Exception e)
            {
                UIAlertView alert = new UIAlertView()
                {
                    Title   = "Sorry",
                    Message = "Something went wrong. We are on it"
                };

                alert.AddButton("OK");
                alert.Show();
                LoggingClass.LogError(e.Message, screenid, e.StackTrace);
                //Console.WriteLine(e.Message + "\n" + e.StackTrace);
            }
        }
Example #18
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var bounds             = View.Bounds;
            var screenBounds       = UIScreen.MainScreen.Bounds;
            var maxScreenDimension = NMath.Max(screenBounds.Width, screenBounds.Height);

            UIViewAutoresizing flexibleDimensions = FlexibleWidth | FlexibleHeight;

            scrollView = new UIScrollView(bounds)
            {
                AutoresizingMask = flexibleDimensions
            };
            View.AddSubview(scrollView);

            var frame = new CGRect(CGPoint.Empty, new CGSize(maxScreenDimension, maxScreenDimension));

            cgView = new StrokeCGView(frame)
            {
                AutoresizingMask = flexibleDimensions
            };

            View.BackgroundColor = UIColor.White;

            canvasContainerView = CanvasContainerView.FromCanvasSize(cgView.Frame.Size);
            canvasContainerView.DocumentView = cgView;
            scrollView.ContentSize           = canvasContainerView.Frame.Size;
            scrollView.ContentOffset         = new CGPoint((canvasContainerView.Frame.Width - scrollView.Bounds.Width) / 2,
                                                           (canvasContainerView.Frame.Height - scrollView.Bounds.Height) / 2);
            scrollView.AddSubview(canvasContainerView);
            scrollView.BackgroundColor  = canvasContainerView.BackgroundColor;
            scrollView.MaximumZoomScale = 3;
            scrollView.MinimumZoomScale = 0.5f;
            scrollView.PanGestureRecognizer.AllowedTouchTypes   = TouchTypes(UITouchType.Direct);
            scrollView.PinchGestureRecognizer.AllowedTouchTypes = TouchTypes(UITouchType.Direct);

            scrollView.Delegate = this;

            // We put our UI elements on top of the scroll view, so we don't want any of the
            // delay or cancel machinery in place.
            scrollView.DelaysContentTouches = false;

            fingerStrokeRecognizer = new StrokeGestureRecognizer(StrokeUpdated)
            {
                Delegate             = this,
                CancelsTouchesInView = false,
                IsForPencil          = false,
                CoordinateSpaceView  = cgView
            };
            scrollView.AddGestureRecognizer(fingerStrokeRecognizer);

            pencilStrokeRecognizer = new StrokeGestureRecognizer(StrokeUpdated)
            {
                Delegate             = this,
                CancelsTouchesInView = false,
                CoordinateSpaceView  = cgView,
                IsForPencil          = true
            };
            scrollView.AddGestureRecognizer(pencilStrokeRecognizer);

            SetupConfigurations();

            var onPhone = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone;

            var ringDiameter   = onPhone ? 66f : 74f;
            var ringImageInset = onPhone ? 12f : 14f;
            var borderWidth    = 1f;
            var ringOutset     = ringDiameter / 2 - (NMath.Floor(NMath.Sqrt((ringDiameter * ringDiameter) / 8) - borderWidth));
            var ringFrame      = new CGRect(-ringOutset, View.Bounds.Height - ringDiameter + ringOutset, ringDiameter, ringDiameter);
            var ringControl    = new RingControl(ringFrame, configurations.Length);

            ringControl.AutoresizingMask = FlexibleRightMargin | FlexibleTopMargin;
            View.AddSubview(ringControl);
            leftRingControl = ringControl;
            string [] imageNames = { "Calligraphy", "Ink", "Debug" };
            for (int index = 0; index < leftRingControl.RingViews.Count; index++)
            {
                var ringView = leftRingControl.RingViews [index];
                ringView.ActionClosure = configurations [index];
                var imageView = new UIImageView(ringView.Bounds.Inset(ringImageInset, ringImageInset));
                imageView.Image            = UIImage.FromBundle(imageNames [index]);
                imageView.AutoresizingMask = FlexibleLeftMargin | FlexibleRightMargin | FlexibleTopMargin | FlexibleBottomMargin;
                ringView.AddSubview(imageView);
            }

            clearButton = AddButton("clear", ClearButtonAction);
            SetupPencilUI();
        }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			var bounds = View.Bounds;
			var screenBounds = UIScreen.MainScreen.Bounds;
			var maxScreenDimension = NMath.Max (screenBounds.Width, screenBounds.Height);

			UIViewAutoresizing flexibleDimensions = FlexibleWidth | FlexibleHeight;

			scrollView = new UIScrollView (bounds) {
				AutoresizingMask = flexibleDimensions
			};
			View.AddSubview (scrollView);

			var frame = new CGRect (CGPoint.Empty, new CGSize (maxScreenDimension, maxScreenDimension));
			cgView = new StrokeCGView (frame) {
				AutoresizingMask = flexibleDimensions
			};

			View.BackgroundColor = UIColor.White;

			canvasContainerView = CanvasContainerView.FromCanvasSize (cgView.Frame.Size);
			canvasContainerView.DocumentView = cgView;
			scrollView.ContentSize = canvasContainerView.Frame.Size;
			scrollView.ContentOffset = new CGPoint ((canvasContainerView.Frame.Width - scrollView.Bounds.Width) / 2,
													(canvasContainerView.Frame.Height - scrollView.Bounds.Height) / 2);
			scrollView.AddSubview (canvasContainerView);
			scrollView.BackgroundColor = canvasContainerView.BackgroundColor;
			scrollView.MaximumZoomScale = 3;
			scrollView.MinimumZoomScale = 0.5f;
			scrollView.PanGestureRecognizer.AllowedTouchTypes = TouchTypes (UITouchType.Direct);
			scrollView.PinchGestureRecognizer.AllowedTouchTypes = TouchTypes (UITouchType.Direct);

			scrollView.Delegate = this;

			// We put our UI elements on top of the scroll view, so we don't want any of the
			// delay or cancel machinery in place.
			scrollView.DelaysContentTouches = false;

			fingerStrokeRecognizer = new StrokeGestureRecognizer (StrokeUpdated) {
				Delegate = this,
				CancelsTouchesInView = false,
				IsForPencil = false,
				CoordinateSpaceView = cgView
			};
			scrollView.AddGestureRecognizer (fingerStrokeRecognizer);

			pencilStrokeRecognizer = new StrokeGestureRecognizer (StrokeUpdated) {
				Delegate = this,
				CancelsTouchesInView = false,
				CoordinateSpaceView = cgView,
				IsForPencil = true
			};
			scrollView.AddGestureRecognizer (pencilStrokeRecognizer);

			SetupConfigurations ();

			var onPhone = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone;

			var ringDiameter = onPhone ? 66f : 74f;
			var ringImageInset = onPhone ? 12f : 14f;
			var borderWidth = 1f;
			var ringOutset = ringDiameter / 2 - (NMath.Floor (NMath.Sqrt ((ringDiameter * ringDiameter) / 8) - borderWidth));
			var ringFrame = new CGRect (-ringOutset, View.Bounds.Height - ringDiameter + ringOutset, ringDiameter, ringDiameter);
			var ringControl = new RingControl (ringFrame, configurations.Length);
			ringControl.AutoresizingMask = FlexibleRightMargin | FlexibleTopMargin;
			View.AddSubview (ringControl);
			leftRingControl = ringControl;
			string [] imageNames = { "Calligraphy", "Ink", "Debug" };
			for (int index = 0; index < leftRingControl.RingViews.Count; index++) {
				var ringView = leftRingControl.RingViews [index];
				ringView.ActionClosure = configurations [index];
				var imageView = new UIImageView (ringView.Bounds.Inset (ringImageInset, ringImageInset));
				imageView.Image = UIImage.FromBundle (imageNames [index]);
				imageView.AutoresizingMask = FlexibleLeftMargin | FlexibleRightMargin | FlexibleTopMargin | FlexibleBottomMargin;
				ringView.AddSubview (imageView);
			}

			clearButton = AddButton ("clear", ClearButtonAction);
			SetupPencilUI ();
		}
Example #20
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

             // set the background color of the view to white
             this.View.BackgroundColor = UIColor.White;

             this.Title = "Mecut Dosya";

             // create our scroll view
             scrollView = new UIScrollView (
            new RectangleF (0, 0, View.Frame.Width
               , View.Frame.Height - NavigationController.NavigationBar.Frame.Height));
             View.AddSubview (scrollView);

             string documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
             string localFilename = "original.jpg";
             string localPath = Path.Combine(documentsPath, localFilename);

             // create our image view
             imageView = new UIImageView (UIImage.FromFile (localPath));
             scrollView.ContentSize = imageView.Image.Size;
             scrollView.AddSubview (imageView);

             // set allow zooming
             scrollView.MaximumZoomScale = 3f;
             scrollView.MinimumZoomScale = .1f;
             scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return imageView; };

             // configure a double-tap gesture recognizer
             UITapGestureRecognizer doubletap = new UITapGestureRecognizer();
             doubletap.NumberOfTapsRequired = 2;
             doubletap.AddTarget (this, new MonoTouch.ObjCRuntime.Selector("DoubleTapSelector"));
             scrollView.AddGestureRecognizer(doubletap);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (Images == null)
            {
                Images = new List<UIImage>();

                foreach (string s in ImagePaths)
                {
                    Images.Add(UIImage.FromBundle(s));
                }
            }

            View.BackgroundColor = UIColor.Black;
            View.AutoresizingMask = UIViewAutoresizing.All;
            totalPage = Images.Count;

            //set View to Full Screen
            WantsFullScreenLayout = true;

            //Add Done button if modal
            if (IsModalView)
            {
                NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, dismissImageViewer);
            }
            //Navigationbar and toolbar styling
            //			NavigationController.NavigationBar.TintColor = UIColor.FromRGB(233, 131, 0);
            NavigationController.NavigationBar.Translucent = true;
            NavigationController.Toolbar.TintColor = UIColor.FromRGB(233, 131, 0);
            NavigationController.Toolbar.Translucent = true;
            NavigationController.SetToolbarHidden(false, false);

            //set X of UIScrollView for UIImageView
            float scrollViewOffset = 0;
            imageSizeWidth = (int)View.Frame.Size.Width;
            imageSizeHeight = (int)View.Frame.Size.Height + 64;

            imageScrollView = new UIScrollView(new RectangleF(0, 0, imageSizeWidth, imageSizeHeight));
            imageScrollView.ContentSize = new SizeF(imageSizeWidth * totalPage, imageSizeHeight);
            imageScrollView.PagingEnabled = true;
            imageScrollView.WeakDelegate = this;
            imageScrollView.AutoresizingMask = UIViewAutoresizing.All;

            //add UIImageViews to UIScrollView
            foreach (UIImage img in Images)
            {
                UIImageView iv = new UIImageView(img);
                iv.AutoresizingMask = UIViewAutoresizing.All;
                iv.ContentMode = UIViewContentMode.ScaleAspectFit;
                iv.Frame = new RectangleF(scrollViewOffset, 0, imageSizeWidth, imageSizeHeight);
                iv.UserInteractionEnabled = true;
                imageScrollView.AddSubview(iv);
                scrollViewOffset += imageSizeWidth;
            }

            View.AddSubview(imageScrollView);

            //set ScrollView to Currentpage
            imageScrollView.ScrollRectToVisible(new RectangleF(CurrentPage * imageSizeWidth, 0, imageSizeWidth, imageSizeHeight), false);

            //show Title with currentpage
            Title = "Afbeelding " + (CurrentPage + 1) + " van " + totalPage;

            //Add UIPageControl to toolbar
            pageControl = new UIPageControl(new RectangleF(0, 0, View.Frame.Size.Width, 40));
            pageControl.Pages = Images.Count;
            pageControl.CurrentPage = CurrentPage;
            pageControl.DefersCurrentPageDisplay = true;
            pageControl.HidesForSinglePage = false;

            UIBarButtonItem[] items = new UIBarButtonItem[]{ new UIBarButtonItem(pageControl) };
            ToolbarItems = items;

            // Detect orientation changes using an observer
            orientationObserver = NSNotificationCenter.DefaultCenter.AddObserver("UIDeviceOrientationDidChangeNotification", handleRotation);

            //Add GestureRecognizer to show/hide navigationbar/toolbar/statusbar
            UITapGestureRecognizer gesture = new UITapGestureRecognizer(this, new MonoTouch.ObjCRuntime.Selector("ViewTapSelector"));
            imageScrollView.AddGestureRecognizer(gesture);
        }
        private void ConfigureUserInterface()
        {
            // Add tap gesture recognizer to controller scroll view to recognize menu item selection
            _gestureRecognizer = new UITapGestureRecognizer(new Action(HandleMenuItemTap));
            _gestureRecognizer.NumberOfTapsRequired    = 1;
            _gestureRecognizer.NumberOfTouchesRequired = 1;
            _menuScrollView.AddGestureRecognizer(_gestureRecognizer);

            _controllerScrollView.Scrolled          += new WeakEventHandler(_controllerScrollView_Scrolled).Handler;
            _controllerScrollView.DecelerationEnded += new WeakEventHandler(_controllerScrollView_DecelerationEnded).Handler;

            // When the user taps the status bar, the scroll view beneath the touch which is closest to the status bar will be scrolled to top,
            // but only if its `scrollsToTop` property is YES, its delegate does not return NO from `shouldScrollViewScrollToTop`, and it is not already at the top.
            // If more than one scroll view is found, none will be scrolled.
            // Disable scrollsToTop for menu and controller scroll views so that iOS finds scroll views within our pages on status bar tap gesture.
            _menuScrollView.ScrollsToTop       = false;
            _controllerScrollView.ScrollsToTop = false;

            // Configure menu scroll view
            if (_configuration.UseMenuLikeSegmentedControl)
            {
                _menuScrollView.ScrollEnabled = false;
                _menuScrollView.ContentSize   = new CGSize(
                    width: this.View.Frame.Width,
                    height: _configuration.MenuHeight);
                _configuration.MenuMargin = 0;
            }
            else
            {
                _menuScrollView.ContentSize = new CGSize(
                    width: (_configuration.MenuItemWidth + _configuration.MenuMargin) * _controllers.Count + _configuration.MenuMargin,
                    height: _configuration.MenuHeight);
            }

            float index = 0;

            foreach (var controller in _controllers)
            {
                if (index == 0)
                {
                    // Add first two controllers to scrollview and as child view controller
                    controller.ViewWillAppear(true);
                    AddPageAtIndex(0);
                    controller.ViewDidAppear(true);
                }

                // Set up menu item for menu scroll view
                var menuItemFrame = new CGRect();

                if (_configuration.UseMenuLikeSegmentedControl)
                {
                    if (MenuItemMargin > 0)
                    {
                        var marginSum     = MenuItemMargin * (_controllers.Count + 1);
                        var menuItemWidth = (this.View.Frame.Width - marginSum) / _controllers.Count;
                        menuItemFrame = new CGRect(
                            x: (MenuItemMargin * (index + 1)) + menuItemWidth * index,
                            y: 0,
                            width: this.View.Frame.Width / _controllers.Count,
                            height: _configuration.MenuHeight);
                    }
                    else
                    {
                        menuItemFrame = new CGRect(
                            x: this.View.Frame.Width / _controllers.Count * index,
                            y: 0,
                            width: this.View.Frame.Width / _controllers.Count,
                            height: _configuration.MenuHeight);
                    }
                }
                else if (_configuration.MenuItemWidthBasedOnTitleTextWidth)
                {
                    var controllerTitle = controller.Title;

                    var titleText     = controllerTitle ?? "Menu " + (index + 1);
                    var itemWidthRect = new NSString(titleText).GetBoundingRect(
                        size: new CGSize(1000, 1000),
                        options: NSStringDrawingOptions.UsesLineFragmentOrigin,
                        attributes: new UIStringAttributes()
                    {
                        Font = _configuration.MenuItemFont
                    },
                        context: null);

                    _totalMenuItemWidthIfDifferentWidths += itemWidthRect.Width;
                    _menuItemWidths.Append(itemWidthRect.Width);
                }
                else
                {
                    if (_configuration.CenterMenuItems && index == 0)
                    {
                        _startingMenuMargin = ((this.View.Frame.Width - ((_controllers.Count * _configuration.MenuItemWidth) + (_controllers.Count - 1) * _configuration.MenuMargin)) / 2) - _configuration.MenuMargin;

                        if (_startingMenuMargin < 0)
                        {
                            _startingMenuMargin = 0;
                        }

                        menuItemFrame = new CGRect(
                            x: _startingMenuMargin + _configuration.MenuMargin,
                            y: 0,
                            width: _configuration.MenuItemWidth,
                            height: _configuration.MenuHeight);
                    }
                    else
                    {
                        menuItemFrame = new CGRect(
                            x: _configuration.MenuItemWidth * index + _configuration.MenuMargin * (index + 1) + _startingMenuMargin,
                            y: 0,
                            width: _configuration.MenuItemWidth,
                            height: _configuration.MenuHeight);
                    }
                }

                var menuItemView = new CAPSMenuItemView()
                {
                    Frame = menuItemFrame
                };
                menuItemView.Configure(this, controller, index);

                // Add menu item view to menu scroll view
                _menuScrollView.Add(menuItemView);
                _menuItems.Add(menuItemView);

                index += 1;
            }

            // Set new content size for menu scroll view if needed
            if (_configuration.MenuItemWidthBasedOnTitleTextWidth)
            {
                _menuScrollView.ContentSize = new CGSize(
                    width: (_totalMenuItemWidthIfDifferentWidths + _configuration.MenuMargin) + _controllers.Count * _configuration.MenuMargin,
                    height: _configuration.MenuHeight);
            }

            // Set selected color for title label of selected menu item
            if (_menuItems.Count > 0)
            {
                if (_menuItems[CurrentPageIndex].TitleLabel != null)
                {
                    _menuItems[CurrentPageIndex].TitleLabel.TextColor = _configuration.SelectedMenuItemLabelColor;
                }
            }

            // Configure selection indicator view
            CGRect selectionIndicatorFrame;

            if (_configuration.UseMenuLikeSegmentedControl)
            {
                selectionIndicatorFrame = new CGRect(
                    x: 0,
                    y: _configuration.MenuHeight - _configuration.SelectionIndicatorHeight,
                    width: this.View.Frame.Width / _controllers.Count,
                    height: _configuration.SelectionIndicatorHeight);
            }
            else if (_configuration.MenuItemWidthBasedOnTitleTextWidth)
            {
                selectionIndicatorFrame = new CGRect(
                    x: _configuration.MenuMargin,
                    y: _configuration.MenuHeight - _configuration.SelectionIndicatorHeight,
                    width: _configuration.MenuItemWidth,
                    height: _configuration.SelectionIndicatorHeight);
            }
            else
            {
                if (_configuration.CenterMenuItems)
                {
                    selectionIndicatorFrame = new CGRect(
                        x: _startingMenuMargin + _configuration.MenuMargin,
                        y: _configuration.MenuHeight - _configuration.SelectionIndicatorHeight,
                        width: _configuration.MenuItemWidth,
                        height: _configuration.SelectionIndicatorHeight);
                }
                else
                {
                    selectionIndicatorFrame = new CGRect(
                        x: _configuration.MenuMargin,
                        y: _configuration.MenuHeight - _configuration.SelectionIndicatorHeight,
                        width: _configuration.MenuItemWidth,
                        height: _configuration.SelectionIndicatorHeight);
                }
            }

            _selectionIndicatorView = new UIView(selectionIndicatorFrame);
            _selectionIndicatorView.BackgroundColor = _configuration.SelectionIndicatorColor;
            _menuScrollView.AddSubview(_selectionIndicatorView);
        }
        protected SliderFeedCollectionViewCell(IntPtr handle) : base(handle)
        {
            _contentView = ContentView;

            _closeButton       = new UIButton();
            _closeButton.Frame = new CGRect(_contentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _closeButton.SetImage(UIImage.FromBundle("ic_close_black"), UIControlState.Normal);
            //_closeButton.BackgroundColor = UIColor.Yellow;
            _contentView.AddSubview(_closeButton);

            _moreButton       = new UIButton();
            _moreButton.Frame = new CGRect(_closeButton.Frame.Left - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal);
            //_moreButton.BackgroundColor = UIColor.Black;
            _contentView.AddSubview(_moreButton);

            _avatarImage       = new UIImageView();
            _avatarImage.Frame = new CGRect(leftMargin, 20, 30, 30);
            _contentView.AddSubview(_avatarImage);

            authorX = _avatarImage.Frame.Right + 10;

            _author      = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _closeButton.Frame.Left - authorX, 18));
            _author.Font = Constants.Semibold14;
            //_author.BackgroundColor = UIColor.Yellow;
            _author.LineBreakMode = UILineBreakMode.TailTruncation;
            _author.TextColor     = Constants.R15G24B30;
            _contentView.AddSubview(_author);

            _timestamp      = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _closeButton.Frame.Left - authorX, 16));
            _timestamp.Font = Constants.Regular12;
            //_timestamp.BackgroundColor = UIColor.Green;
            _timestamp.LineBreakMode = UILineBreakMode.TailTruncation;
            _timestamp.TextColor     = Constants.R151G155B158;
            _contentView.AddSubview(_timestamp);

            _contentScroll       = new UIScrollView();
            _contentScroll.Frame = new CGRect(0, _avatarImage.Frame.Bottom + 20, _contentView.Frame.Width,
                                              _contentView.Frame.Height - (_avatarImage.Frame.Bottom + 20));
            _contentScroll.ShowsVerticalScrollIndicator = false;
            _contentScroll.Bounces = false;
            //_contentScroll.BackgroundColor = UIColor.LightGray;
            _contentView.AddSubview(_contentScroll);

            _photoScroll = new UIScrollView();
            _photoScroll.ShowsHorizontalScrollIndicator = false;
            _photoScroll.Bounces       = false;
            _photoScroll.PagingEnabled = true;
            _contentScroll.AddSubview(_photoScroll);

            _likes                        = new UILabel();
            _likes.Font                   = Constants.Semibold14;
            _likes.LineBreakMode          = UILineBreakMode.TailTruncation;
            _likes.TextColor              = Constants.R15G24B30;
            _likes.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_likes);
            //_likes.BackgroundColor = UIColor.Purple;

            _flags      = new UILabel();
            _flags.Font = Constants.Semibold14;
            //_flags.BackgroundColor = UIColor.Orange;
            _flags.LineBreakMode          = UILineBreakMode.TailTruncation;
            _flags.TextColor              = Constants.R15G24B30;
            _flags.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_flags);

            _rewards      = new UILabel();
            _rewards.Font = Constants.Semibold14;
            //_rewards.BackgroundColor = UIColor.Orange;
            _rewards.LineBreakMode          = UILineBreakMode.TailTruncation;
            _rewards.TextColor              = Constants.R15G24B30;
            _rewards.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_rewards);

            _like             = new UIImageView();
            _like.ContentMode = UIViewContentMode.Center;
            //_like.BackgroundColor = UIColor.Orange;
            _contentScroll.AddSubview(_like);

            _verticalSeparator = new UIView();
            _verticalSeparator.BackgroundColor = Constants.R244G244B246;
            _contentScroll.AddSubview(_verticalSeparator);

            _topSeparator = new UIView();
            _topSeparator.BackgroundColor = Constants.R244G244B246;
            _contentScroll.AddSubview(_topSeparator);

            _comments      = new UILabel();
            _comments.Font = Constants.Regular14;
            //_comments.BackgroundColor = UIColor.DarkGray;
            _comments.LineBreakMode          = UILineBreakMode.TailTruncation;
            _comments.TextColor              = Constants.R151G155B158;
            _comments.UserInteractionEnabled = true;
            _comments.TextAlignment          = UITextAlignment.Center;
            _contentScroll.AddSubview(_comments);

            _bottomSeparator = new UIView();
            _bottomSeparator.BackgroundColor = Constants.R244G244B246;
            _contentScroll.AddSubview(_bottomSeparator);

            _profileTapView = new UIView(new CGRect(0, 0, _contentView.Frame.Width / 2, likeButtonWidthConst));
            _profileTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_profileTapView);

            _likersTapView = new UIView();
            _likersTapView.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_likersTapView);

            likersY            = underPhotoPanelHeight / 2 - likersImageSide / 2;
            likersCornerRadius = likersImageSide / 2;

            var liketap = new UITapGestureRecognizer(LikeTap);

            _like.AddGestureRecognizer(liketap);

            UITapGestureRecognizer tap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Preview, _currentPost);
            });

            _photoScroll.AddGestureRecognizer(tap);

            var profileTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });
            var headerTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });

            _profileTapView.AddGestureRecognizer(headerTap);
            _rewards.AddGestureRecognizer(profileTap);

            var commentTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Comments, _currentPost);
            });

            _comments.AddGestureRecognizer(commentTap);

            var netVotesTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Voters, _currentPost);
            });

            _likersTapView.AddGestureRecognizer(netVotesTap);

            var flagersTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Flagers, _currentPost);
            });

            _flags.AddGestureRecognizer(flagersTap);

            _moreButton.TouchDown  += FlagButton_TouchDown;
            _closeButton.TouchDown += Close_TouchDown;
        }
Example #24
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var bounds = View.Bounds;
            //var bounds = new CGRect(0, 0, View.Bounds.Width, View.Bounds.Height);
            //var bounds = fingsize;
            var screenBounds = UIScreen.MainScreen.Bounds;
            //var maxScreenDimension = NMath.Max (screenBounds.Width, screenBounds.Height);
            var maxScreenDimension = NMath.Max(screenBounds.Width, screenBounds.Height);

            UIViewAutoresizing flexibleDimensions = FlexibleWidth | FlexibleHeight;

            scrollView = new UIScrollView(bounds)
            {
                AutoresizingMask = flexibleDimensions,
                //BackgroundColor = UIColor.Red
            };

            View.AddSubview(scrollView);

            var frame = new CGRect(CGPoint.Empty, new CGSize(maxScreenDimension, maxScreenDimension));

            //var frame = new CGRect(CGPoint.Empty, new CGSize(800, 800));
            //var frame = bounds;
            cgView = new StrokeCGView(frame)
            {
                AutoresizingMask = flexibleDimensions,
                editing          = MREditing
            };

            View.BackgroundColor = UIColor.White;
            //View.BackgroundColor = UIColor.Clear;
            //View.BackgroundColor = UIColor.FromWhiteAlpha(1.0f, 0.4f);
            //View.Alpha = 1.0f;

            canvasContainerView = CanvasContainerView.FromCanvasSize(cgView.Frame.Size);
            canvasContainerView.DocumentView = cgView;
            scrollView.ContentSize           = canvasContainerView.Frame.Size;
            scrollView.ContentOffset         = new CGPoint((canvasContainerView.Frame.Width - scrollView.Bounds.Width) / 2,
                                                           (canvasContainerView.Frame.Height - scrollView.Bounds.Height) / 2);
            //scrollView.ContentOffset = new CGPoint(0, 0);
            scrollView.AddSubview(canvasContainerView);
            scrollView.BackgroundColor = canvasContainerView.BackgroundColor;

            //scrollView.BackgroundColor = UIColor.Clear;
            //scrollView.BackgroundColor = UIColor.FromWhiteAlpha(1.0f, 0.4f);
            //scrollView.Alpha = 1.0f;

            scrollView.MaximumZoomScale = 3;
            scrollView.MinimumZoomScale = 0.5f;
            scrollView.PanGestureRecognizer.AllowedTouchTypes   = TouchTypes(UITouchType.Direct);
            scrollView.PinchGestureRecognizer.AllowedTouchTypes = TouchTypes(UITouchType.Direct);

            scrollView.Delegate = this;



            if (MREditing)
            {
                filename = MREditName + "_" + "edit" + "_" + DateTime.Now.ToString("s").Replace(":", "_") + ".jpg";
                //var img = UIImage.FromFile("dynapadscreenshot.png");

                UIImage img = new UIImage();
                switch (MREditType)
                {
                case "jpg":
                case "gif":
                case "png":
                    img = FromUrl(MREditPath);
                    break;

                case "pdf":
                case "doc":
                case "docx":
                    var dps = new DynaPadService.DynaPadService();
                    //img = dps.ConvertToJPG(CommonFunctions.GetUserConfig(), MREditPath);
                    break;

                default:
                    img = FromUrl(MREditPath);
                    break;
                }

                var imgView = new UIImageView(bounds);
                imgView.Image       = img;
                imgView.ContentMode = UIViewContentMode.ScaleAspectFit;                 // or ScaleAspectFill
                //imgView.BackgroundColor = UIColor.Green;
                //imgView.Opaque = false;
                //canvasContainerView.BackgroundColor = UIColor.Clear;
                //canvasContainerView.Opaque = false;
                canvasContainerView.AddSubview(imgView);
                canvasContainerView.SendSubviewToBack(imgView);
                //imgView.Alpha = 0.5f;
                //scrollView.AddSubview(imgView);
                //scrollView.SendSubviewToBack(imgView);
                //View.AddSubview(imgView);
                //View.SendSubviewToBack(imgView);
            }



            // We put our UI elements on top of the scroll view, so we don't want any of the
            // delay or cancel machinery in place.
            scrollView.DelaysContentTouches = false;

            fingerStrokeRecognizer = new StrokeGestureRecognizer(StrokeUpdated)
            {
                Delegate             = this,
                CancelsTouchesInView = false,
                IsForPencil          = false,
                CoordinateSpaceView  = cgView
            };
            scrollView.AddGestureRecognizer(fingerStrokeRecognizer);

            pencilStrokeRecognizer = new StrokeGestureRecognizer(StrokeUpdated)
            {
                Delegate             = this,
                CancelsTouchesInView = false,
                CoordinateSpaceView  = cgView,
                IsForPencil          = true
            };
            scrollView.AddGestureRecognizer(pencilStrokeRecognizer);

            SetupConfigurations();

            var onPhone = UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone;

            var ringDiameter   = onPhone ? 66f : 74f;
            var ringImageInset = onPhone ? 12f : 14f;
            var borderWidth    = 1f;
            var ringOutset     = ringDiameter / 2 - (NMath.Floor(NMath.Sqrt((ringDiameter * ringDiameter) / 8) - borderWidth));
            //var ringFrame = new CGRect (-ringOutset, View.Bounds.Height - ringDiameter + ringOutset, ringDiameter, ringDiameter);
            //var ringFrame = new CGRect(ringOutset, 800 - ringDiameter - ringOutset, ringDiameter, ringDiameter);
            var ringFrame   = new CGRect(ringOutset, View.Bounds.Height - ringDiameter + ringOutset - 50, ringDiameter, ringDiameter);
            var ringControl = new RingControl(ringFrame, configurations.Length);

            ringControl.AutoresizingMask = FlexibleRightMargin | FlexibleTopMargin;
            View.AddSubview(ringControl);
            leftRingControl = ringControl;
            string [] imageNames = { "Calligraphy", "Ink", "Debug" };
            for (int index = 0; index < leftRingControl.RingViews.Count; index++)
            {
                var ringView = leftRingControl.RingViews [index];
                ringView.ActionClosure = configurations [index];
                var imageView = new UIImageView(ringView.Bounds.Inset(ringImageInset, ringImageInset));
                imageView.Image            = UIImage.FromBundle(imageNames [index]);
                imageView.AutoresizingMask = FlexibleLeftMargin | FlexibleRightMargin | FlexibleTopMargin | FlexibleBottomMargin;
                ringView.AddSubview(imageView);
            }

            closeButton = AddButton("close", CloseButtonAction);
            clearButton = AddButton("clear", ClearButtonAction);
            saveButton  = AddButton("save", SaveButtonAction);
            SetupPencilUI();

            //cgView.SetNeedsDisplay();
            //scrollView.SetNeedsDisplay();
            //canvasContainerView.SetNeedsDisplay();
            //cgView.

            //new UIAlertView("Touched", "ass", null, "OK", null).Show ();
            //PresentViewController(CommonFunctions.AlertPrompt("File Edit", "Saving this edit will not overwrite the original file", true, null, false, null), true, null);
        }
Example #25
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            if (gvc != null) {
                this.ThumbChanged += (object sender, ThumbChangedEventArgs e) => gvc.ChangeThumb ();
            }

            myBounds = new RectangleF (0, 0, UIScreen.MainScreen.Bounds.Width, UIScreen.MainScreen.Bounds.Height);

            scrollView = new UIScrollView (myBounds);

            var documentsDirectory = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            var gallerydirectory = Path.Combine (documentsDirectory, "gallery");
            string imagefilename = go.imageFileName;
            string path = Path.Combine (gallerydirectory, imagefilename);
            UIImage image = UIImage.FromFile (path);
            var CanvasSize = image.Size;
            RectangleF Canvas = new RectangleF (new PointF (0, 0), CanvasSize);
            //Canvas = new RectangleF (Canvas.X, Canvas.Y, Canvas.Width, Canvas.Height + myBounds.Y);

            //			string thumbfilename = AppDelegate.dao.GetThumbfilenameForIndex (index);
            //			string path = Path.Combine (gallerydirectory, thumbfilename);
            //			Console.WriteLine ("path:" + path);
            //			UIImage currentImage = UIImage.FromFile (path);
            //			SizeF dim = currentImage.Size;

            //create new view if none is availble fr recycling
            //			if (iv == null) {
            iv = new UIImageView(Canvas){
                ContentMode = UIViewContentMode.ScaleAspectFill
            };
            //			}
            iv.Image = image;

            tgv = new TagGraphicsView (go, Canvas);

            scrollView.ContentSize = Canvas.Size;

            scrollView.MaximumZoomScale = 3f;
            scrollView.MinimumZoomScale = 0.3f;

            blend = new UIView (Canvas);
            blend.Frame = Canvas;
            blend.Opaque = true;
            blend.BackgroundColor = UIColor.Clear;
            blend.AddSubview(iv);
            blend.AddSubview(tgv);

            scrollView.AddSubview (blend);

            scrollView.ViewForZoomingInScrollView += (UIScrollView sv) => blend;
            scrollView.SetZoomScale (0.3f, true);
            scrollView.UserInteractionEnabled = true;
            scrollView.AlwaysBounceHorizontal = true;
            scrollView.AlwaysBounceVertical = true;
            Add(scrollView);

            doubletap = new UITapGestureRecognizer (AddTag);
            doubletap.NumberOfTapsRequired = 2;
            scrollView.AddGestureRecognizer (doubletap);

            AddLongPress ();

            CreateEditBarButton ();

            ExtractNewThumbnail();

            //			CreateSlideDownMenu ();

            //			UIButton backbutton = new UIButton(new RectangleF(10,25,48,32));
            //			backbutton.SetImage (backarrow.MakeBackArrow(), UIControlState.Normal);
            //			backbutton.TouchUpInside += (object sender, EventArgs e) => DismissViewControllerAsync (true);
            //			Add (backbutton);

            CreateMenuOptions ();
        }
Example #26
0
        protected SliderFeedCollectionViewCell(IntPtr handle) : base(handle)
        {
            _contentView = ContentView;

            _closeButton       = new UIButton();
            _closeButton.Frame = new CGRect(_contentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _closeButton.SetImage(UIImage.FromBundle("ic_close_black"), UIControlState.Normal);
            //_closeButton.BackgroundColor = UIColor.Yellow;
            _contentView.AddSubview(_closeButton);

            _moreButton       = new UIButton();
            _moreButton.Frame = new CGRect(_closeButton.Frame.Left - moreButtonWidth, 0, moreButtonWidth, likeButtonWidthConst);
            _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal);
            //_moreButton.BackgroundColor = UIColor.Black;
            _contentView.AddSubview(_moreButton);

            _avatarImage       = new UIImageView();
            _avatarImage.Frame = new CGRect(leftMargin, 20, 30, 30);
            _contentView.AddSubview(_avatarImage);

            authorX = _avatarImage.Frame.Right + 10;

            _author      = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _closeButton.Frame.Left - authorX, 18));
            _author.Font = Constants.Semibold14;
            //_author.BackgroundColor = UIColor.Yellow;
            _author.LineBreakMode = UILineBreakMode.TailTruncation;
            _author.TextColor     = Constants.R15G24B30;
            _contentView.AddSubview(_author);

            _timestamp      = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _closeButton.Frame.Left - authorX, 16));
            _timestamp.Font = Constants.Regular12;
            //_timestamp.BackgroundColor = UIColor.Green;
            _timestamp.LineBreakMode = UILineBreakMode.TailTruncation;
            _timestamp.TextColor     = Constants.R151G155B158;
            _contentView.AddSubview(_timestamp);

            _contentScroll       = new UIScrollView();
            _contentScroll.Frame = new CGRect(0, _avatarImage.Frame.Bottom + 20, _contentView.Frame.Width,
                                              _contentView.Frame.Height - (_avatarImage.Frame.Bottom + 20));
            _contentScroll.ShowsVerticalScrollIndicator = false;
            _contentScroll.Bounces = false;
            //_contentScroll.BackgroundColor = UIColor.LightGray;
            _contentView.AddSubview(_contentScroll);

            _photoScroll = new UIScrollView();
            _photoScroll.ShowsHorizontalScrollIndicator = false;
            _photoScroll.Bounces       = false;
            _photoScroll.PagingEnabled = true;
            _photoScroll.Scrolled     += (sender, e) =>
            {
                var pageWidth = _photoScroll.Frame.Size.Width;
                _pageControl.CurrentPage = (int)Math.Floor((_photoScroll.ContentOffset.X - pageWidth / 2) / pageWidth) + 1;
            };
            _photoScroll.Layer.CornerRadius = 10;
            _contentScroll.AddSubview(_photoScroll);

            _pageControl        = new UIPageControl();
            _pageControl.Hidden = true;
            _pageControl.UserInteractionEnabled = false;
            _contentScroll.AddSubview(_pageControl);

            _likes                        = new UILabel();
            _likes.Font                   = Constants.Semibold14;
            _likes.LineBreakMode          = UILineBreakMode.TailTruncation;
            _likes.TextColor              = Constants.R15G24B30;
            _likes.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_likes);
            //_likes.BackgroundColor = UIColor.Purple;

            _flags      = new UILabel();
            _flags.Font = Constants.Semibold14;
            //_flags.BackgroundColor = UIColor.Orange;
            _flags.LineBreakMode          = UILineBreakMode.TailTruncation;
            _flags.TextColor              = Constants.R15G24B30;
            _flags.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_flags);

            _rewards      = new UILabel();
            _rewards.Font = Constants.Semibold14;
            //_rewards.BackgroundColor = UIColor.Orange;
            _rewards.LineBreakMode          = UILineBreakMode.TailTruncation;
            _rewards.TextColor              = Constants.R15G24B30;
            _rewards.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_rewards);

            _like             = new UIImageView();
            _like.ContentMode = UIViewContentMode.Center;
            //_like.BackgroundColor = UIColor.Orange;
            _contentScroll.AddSubview(_like);

            _verticalSeparator = new UIView();
            _verticalSeparator.BackgroundColor = Constants.R244G244B246;
            _contentScroll.AddSubview(_verticalSeparator);

            _topSeparator = new UIView();
            _topSeparator.BackgroundColor = Constants.R244G244B246;
            _contentScroll.AddSubview(_topSeparator);

            _comments      = new UILabel();
            _comments.Font = Constants.Regular14;
            //_comments.BackgroundColor = UIColor.DarkGray;
            _comments.LineBreakMode          = UILineBreakMode.TailTruncation;
            _comments.TextColor              = Constants.R151G155B158;
            _comments.UserInteractionEnabled = true;
            _comments.TextAlignment          = UITextAlignment.Center;
            _contentScroll.AddSubview(_comments);

            _bottomSeparator = new UIView();
            _bottomSeparator.BackgroundColor = Constants.R244G244B246;
            _contentScroll.AddSubview(_bottomSeparator);

            _profileTapView = new UIView(new CGRect(0, 0, _contentView.Frame.Width / 2, likeButtonWidthConst));
            _profileTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_profileTapView);

            _likersTapView = new UIView();
            _likersTapView.UserInteractionEnabled = true;
            _contentScroll.AddSubview(_likersTapView);

            likersY            = underPhotoPanelHeight / 2 - likersImageSide / 2;
            likersCornerRadius = likersImageSide / 2;

            var liketap = new UITapGestureRecognizer(LikeTap);

            _like.AddGestureRecognizer(liketap);

            _sliderView          = new SliderView(_contentScroll.Frame.Width);
            _sliderView.LikeTap += () =>
            {
                LikeTap();
            };
            BaseViewController.SliderAction += (isOpening) =>
            {
                if (_sliderView.Superview != null && !isOpening)
                {
                    _sliderView.Close();
                }
            };

            var likelongtap = new UILongPressGestureRecognizer((UILongPressGestureRecognizer obj) =>
            {
                if (AppSettings.User.IsAuthenticated && !_currentPost.Vote)
                {
                    if (obj.State == UIGestureRecognizerState.Began)
                    {
                        if (!BasePostPresenter.IsEnableVote)
                        {
                            return;
                        }
                        BaseViewController.IsSliderOpen = true;
                        _sliderView.Show(_contentScroll);
                    }
                }
            });

            _like.AddGestureRecognizer(likelongtap);

            UITapGestureRecognizer tap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Preview, _currentPost);
            });

            _photoScroll.AddGestureRecognizer(tap);

            var profileTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });
            var headerTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });

            _profileTapView.AddGestureRecognizer(headerTap);
            _rewards.AddGestureRecognizer(profileTap);

            var commentTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Comments, _currentPost);
            });

            _comments.AddGestureRecognizer(commentTap);

            var netVotesTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Voters, _currentPost);
            });

            _likersTapView.AddGestureRecognizer(netVotesTap);

            var flagersTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Flagers, _currentPost);
            });

            _flags.AddGestureRecognizer(flagersTap);

            _moreButton.TouchDown  += FlagButton_TouchDown;
            _closeButton.TouchDown += Close_TouchDown;
        }
        public SWTableViewCell(UITableViewCellStyle style, string reuseIdentifier,
            UITableView containingTable, IEnumerable<UIButton> rightUtilityButtons,
            UIView leftView, List<UIView> mainView)
            : base(style, reuseIdentifier)
        {
            scrollViewLeft = leftView;
            this.rightUtilityButtons = rightUtilityButtons.ToArray();
            scrollViewButtonViewRight = new SWUtilityButtonView(this.rightUtilityButtons, this);

            containingTableView = containingTable;
            height = (float)containingTableView.RowHeight;
            scrollViewDelegate = new SWScrollViewDelegate(this);

            // Check if the UITableView will display Indices on the right. If that's the case, add a padding
            if (containingTableView.RespondsToSelector(new Selector("sectionIndexTitlesForTableView:"))) {
                string[] indices = containingTableView.Source.SectionIndexTitles(containingTableView);
                additionalRightPadding = indices == null || indices.Length == 0 ? 0 : SectionIndexWidth;
            }

            // Set up scroll view that will host our cell content
            cellScrollView = new UIScrollView(new RectangleF(0, 0, (float)Bounds.Width, height));
            cellScrollView.ContentSize = new SizeF((float)Bounds.Width + UtilityButtonsPadding, height);
            cellScrollView.ContentOffset = ScrollViewContentOffset;
            cellScrollView.Delegate = scrollViewDelegate;
            cellScrollView.ShowsHorizontalScrollIndicator = false;
            cellScrollView.ScrollsToTop = false;
            var tapGestureRecognizer = new UITapGestureRecognizer(OnScrollViewPressed);
            cellScrollView.AddGestureRecognizer(tapGestureRecognizer);

            // Set up the views that will hold the utility buttons
            scrollViewLeft.Frame = new RectangleF(ScrollLeftViewWidth, 0, ScrollLeftViewWidth, height);
            cellScrollView.AddSubview(scrollViewLeft);

            scrollViewButtonViewRight.Frame = new RectangleF((float)Bounds.Width, 0, RightUtilityButtonsWidth, height);

            cellScrollView.AddSubview(scrollViewButtonViewRight);

            // Populate the button views with utility buttons
            scrollViewButtonViewRight.PopulateUtilityButtons();
            // Create the content view that will live in our scroll view
            scrollViewContentView = new UIView(new RectangleF(ScrollLeftViewWidth, 0, (float)Bounds.Width, height));
            cellScrollView.AddSubview(scrollViewContentView);
            this.mainView = mainView;
            BuildMainView();

            AddSubview(cellScrollView);
            HideSwipedContent(false);
        }
        public FeedCellBuilder(UIView contentView)
        {
            _contentView = contentView;

            _moreButton       = new UIButton();
            _moreButton.Frame = new CGRect(_contentView.Frame.Width - moreButtonWidth, 0, moreButtonWidth, 60);
            _moreButton.SetImage(UIImage.FromBundle("ic_more"), UIControlState.Normal);
            //_moreButton.BackgroundColor = UIColor.Black;
            _contentView.AddSubview(_moreButton);

            _avatarImage = new UIImageView(new CGRect(leftMargin, 15, 30, 30));
            _contentView.AddSubview(_avatarImage);

            var authorX = _avatarImage.Frame.Right + 10;

            _author      = new UILabel(new CGRect(authorX, _avatarImage.Frame.Top - 2, _moreButton.Frame.Left - authorX, 18));
            _author.Font = Constants.Semibold14;
            //_author.BackgroundColor = UIColor.Yellow;
            _author.LineBreakMode = UILineBreakMode.TailTruncation;
            _author.TextColor     = Constants.R15G24B30;
            _contentView.AddSubview(_author);

            _timestamp      = new UILabel(new CGRect(authorX, _author.Frame.Bottom, _moreButton.Frame.Left - authorX, 16));
            _timestamp.Font = Constants.Regular12;
            //_timestamp.BackgroundColor = UIColor.Green;
            _timestamp.LineBreakMode = UILineBreakMode.TailTruncation;
            _timestamp.TextColor     = Constants.R151G155B158;
            _contentView.AddSubview(_timestamp);

            _photoScroll = new UIScrollView();
            _photoScroll.BackgroundColor = Constants.R244G244B246;
            _photoScroll.ShowsHorizontalScrollIndicator = false;
            _photoScroll.Bounces       = false;
            _photoScroll.PagingEnabled = true;
            _photoScroll.Scrolled     += (sender, e) =>
            {
                var pageWidth = _photoScroll.Frame.Size.Width;
                _pageControl.CurrentPage = (int)Math.Floor((_photoScroll.ContentOffset.X - pageWidth / 2) / pageWidth) + 1;
            };
            contentView.AddSubview(_photoScroll);

            _pageControl        = new UIPageControl();
            _pageControl.Hidden = true;
            _pageControl.UserInteractionEnabled = false;
            contentView.AddSubview(_pageControl);

            _likes                        = new UILabel();
            _likes.Font                   = Constants.Semibold14;
            _likes.LineBreakMode          = UILineBreakMode.TailTruncation;
            _likes.TextColor              = Constants.R15G24B30;
            _likes.UserInteractionEnabled = true;
            _contentView.AddSubview(_likes);

            _flags      = new UILabel();
            _flags.Font = Constants.Semibold14;
            //_flags.BackgroundColor = UIColor.Orange;
            _flags.LineBreakMode          = UILineBreakMode.TailTruncation;
            _flags.TextColor              = Constants.R15G24B30;
            _flags.UserInteractionEnabled = true;
            _contentView.AddSubview(_flags);

            _rewards      = new UILabel();
            _rewards.Font = Constants.Semibold14;
            //_rewards.BackgroundColor = UIColor.Orange;
            _rewards.LineBreakMode          = UILineBreakMode.TailTruncation;
            _rewards.TextColor              = Constants.R15G24B30;
            _rewards.UserInteractionEnabled = true;
            _contentView.AddSubview(_rewards);

            _like             = new UIImageView();
            _like.ContentMode = UIViewContentMode.Center;
            _contentView.AddSubview(_like);

            _verticalSeparator = new UIView();
            _verticalSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_verticalSeparator);

            _topSeparator = new UIView();
            _topSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_topSeparator);

            var _noLinkAttribute = new UIStringAttributes
            {
                Font            = Constants.Regular14,
                ForegroundColor = Constants.R151G155B158,
            };

            var at = new NSMutableAttributedString();

            at.Append(new NSAttributedString("...", _noLinkAttribute));

            _attributedLabel = new TTTAttributedLabel();
            _attributedLabel.EnabledTextCheckingTypes = NSTextCheckingType.Link;
            var prop = new NSDictionary();

            _attributedLabel.LinkAttributes       = prop;
            _attributedLabel.ActiveLinkAttributes = prop;
            _attributedLabel.Font  = Constants.Regular14;
            _attributedLabel.Lines = 3;
            _attributedLabel.UserInteractionEnabled = true;
            _attributedLabel.Enabled = true;
            _attributedLabel.AttributedTruncationToken = at;
            //_attributedLabel.BackgroundColor = UIColor.Blue;
            _contentView.AddSubview(_attributedLabel);

            _comments      = new UILabel();
            _comments.Font = Constants.Regular14;
            //_comments.BackgroundColor = UIColor.DarkGray;
            _comments.LineBreakMode          = UILineBreakMode.TailTruncation;
            _comments.TextColor              = Constants.R151G155B158;
            _comments.UserInteractionEnabled = true;
            _comments.TextAlignment          = UITextAlignment.Center;
            _contentView.AddSubview(_comments);

            _bottomSeparator = new UIView();
            _bottomSeparator.BackgroundColor = Constants.R244G244B246;
            _contentView.AddSubview(_bottomSeparator);

            _profileTapView = new UIView(new CGRect(0, 0, UIScreen.MainScreen.Bounds.Width / 2, likeButtonWidthConst));
            _profileTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_profileTapView);

            _likersTapView = new UIView();
            _likersTapView.UserInteractionEnabled = true;
            _contentView.AddSubview(_likersTapView);

            likersY            = underPhotoPanelHeight / 2 - likersImageSide / 2;
            likersCornerRadius = likersImageSide / 2;

            var liketap = new UITapGestureRecognizer(LikeTap);

            _like.AddGestureRecognizer(liketap);

            _sliderView          = new SliderView(UIScreen.MainScreen.Bounds.Width);
            _sliderView.LikeTap += () =>
            {
                LikeTap();
            };
            BaseViewController.SliderAction += (isSliderOpening) =>
            {
                if (_sliderView.Superview != null && !isSliderOpening)
                {
                    _sliderView.Close();
                }
            };

            var likelongtap = new UILongPressGestureRecognizer((UILongPressGestureRecognizer obj) =>
            {
                if (AppSettings.User.HasPostingPermission && !_currentPost.Vote)
                {
                    if (obj.State == UIGestureRecognizerState.Began)
                    {
                        if (!BasePostPresenter.IsEnableVote || BaseViewController.IsSliderOpen)
                        {
                            return;
                        }
                        BaseViewController.IsSliderOpen = true;
                        _sliderView.Show(_contentView);
                    }
                }
            });

            _like.AddGestureRecognizer(likelongtap);

            UITapGestureRecognizer tap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Preview, _currentPost);
            });

            _photoScroll.AddGestureRecognizer(tap);

            var profileTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });
            var headerTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Profile, _currentPost);
            });

            _profileTapView.AddGestureRecognizer(headerTap);
            _rewards.AddGestureRecognizer(profileTap);

            var commentTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Comments, _currentPost);
            });

            _comments.AddGestureRecognizer(commentTap);

            var netVotesTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Voters, _currentPost);
            });

            _likersTapView.AddGestureRecognizer(netVotesTap);

            var flagersTap = new UITapGestureRecognizer(() =>
            {
                CellAction?.Invoke(ActionType.Flagers, _currentPost);
            });

            _flags.AddGestureRecognizer(flagersTap);

            _moreButton.TouchDown += FlagButton_TouchDown;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.View.BackgroundColor = UIColor.Clear;

            _colorBarView = new UIImageView(new RectangleF(10f, 10f, 300f, 30f))
            {
                Image = new UIImage("*****@*****.**")
            };

            this.View.AddSubview(_colorBarView);

            _paletteView = new UIScrollView(new RectangleF(0, 50f, 320f, this.View.Frame.Height - 120f))
            {
                BackgroundColor        = UIColor.Clear,
                Bounces                = true,
                AlwaysBounceHorizontal = true,
                AlwaysBounceVertical   = false,
                PagingEnabled          = true
            };

            this.View.AddSubview(_paletteView);

            var layer = new CALayer
            {
                Frame         = new RectangleF(130f, 16f, 100f, 40f),
                CornerRadius  = 6f,
                ShadowColor   = UIColor.Black.CGColor,
                ShadowOffset  = new SizeF(0f, 2f),
                ShadowOpacity = 0.8f
            };

            _paletteView.Layer.AddSublayer(layer);

            var index = 0;

            for (var i = 0; i < 12; i++)
            {
                var colorCount = DisplayHelper.Is4InchDisplay() ? 32 : 24;

                for (var j = 0; j < colorCount && index < _colors.Count; j++)
                {
                    var colorIndex = index++;
                    layer = new CALayer
                    {
                        Name            = $"Color_{colorIndex}",
                        CornerRadius    = 6f,
                        BackgroundColor = _colors[colorIndex].CGColor
                    };

                    var column = j % 4;
                    var row    = j / 4;
                    layer.Frame = new RectangleF(i * 320 + 8 + (column * 78), 8 + row * 48, 70f, 40f);
                    LayerHelper.SetupShadow(layer);
                    _paletteView.Layer.AddSublayer(layer);
                }
            }

            _paletteView.ContentSize = new SizeF(3840f, 296f);

            var colorRecognizer = new UITapGestureRecognizer(ColorGridTapped);

            _paletteView.AddGestureRecognizer(colorRecognizer);

            _colorBarView.UserInteractionEnabled = true;
            var barRecognizer = new UITapGestureRecognizer(ColorBarTapped);

            _colorBarView.AddGestureRecognizer(barRecognizer);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            UIGestureRecognizer gesture = new UITapGestureRecognizer ();
            gesture.AddTarget (this, new Selector ("MySelector"));

            RectangleF rect = View.Frame;

            tabsView = new UIScrollView(new RectangleF(0, rect.Bottom - pagerSource.tabHeight, rect.Width, pagerSource.tabHeight));
            tabsView.AddGestureRecognizer (gesture);
            tabsView.BackgroundColor = UIColor.LightGray;
            tabsView.ShowsHorizontalScrollIndicator = false;
            tabsView.ShowsVerticalScrollIndicator = false;
            tabsView.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin;
            View.Add (tabsView);

            reloadData ();

            SelectTabAtIndex (0);
        }