Пример #1
0
		public override void ViewDidLoad()
		{
			try
			{
				LoggingClass.loginview = true;
				nfloat starty = 70;
				nfloat width = UIScreen.MainScreen.Bounds.Width;
				width = width / 2 - 15;
				if (Reachability.IsHostReachable("https://www.apple.com") == false)
				{
					UIAlertView alert = new UIAlertView()
					{
						Title = "Sorry",
						Message = "Not connected to internet,Connect and re try it."
					};

					alert.AddButton("OK");
					alert.Show();
				}
				if (CurrentUser.GetCardNumber() != null)
				{
					PreInfo(CurrentUser.GetCardNumber());
				}
				CGSize sTemp = new CGSize(View.Frame.Width-10, 100);
				try
				{
					EmailVerification(true);
				}
				catch (Exception exe)
				{
					LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
				}
				 CurrentUser.RootTabs = RootTabs;
				CurrentUser.window = _window;
				MobileBarcodeScanner scanner = new MobileBarcodeScanner();
				nfloat h = 31.0f;
				nfloat w = View.Bounds.Width;
				nfloat imageheight = screenheight/5;
				nfloat imagewidth = UIScreen.MainScreen.Bounds.Width;
				var imgLogo = new UIImageView();
				imgLogo.Frame = new CGRect(((imagewidth/2)-(imageheight/2)), starty, imageheight, imageheight);
				imgLogo.Image = UIImage.FromFile("Images/lg.png");
				y = starty + imageheight;
				lblIns = new UILabel();
				lblIns.Text = "Please scan your VIP card barcode by touching below card:";
				lblIns.LineBreakMode = UILineBreakMode.WordWrap;
				lblIns.Lines = 0;
				sTemp = lblIns.SizeThatFits(sTemp);
				lblIns.Frame = new CGRect(0, y, View.Frame.Width-10, sTemp.Height);
				lblIns.TextAlignment = UITextAlignment.Center;
				lblIns.TextColor = UIColor.Black;
				//Console.WriteLine(y+"\n"+sTemp.Height);

				y = y+sTemp.Height;
				lblInfo = new UILabel();
				lblInfo.Frame = new CGRect(20, y, View.Frame.Width-10, h);
				lblInfo.LineBreakMode = UILineBreakMode.WordWrap;
				lblInfo.Lines = 0;
				lblInfo.TextAlignment = UITextAlignment.Center;
				lblInfo.TextColor = UIColor.Black;

				lblContactus = new UILabel();
				lblContactus.TextColor = UIColor.Red;
				lblContactus.TextAlignment = UITextAlignment.Center;
				lblContactus.Hidden = true;

				nfloat hei = 180 + lblIns.Frame.Height + 10;
				btnCardScanner= new UIButton();
				if (screenheight <= 568)
				{
					btnCardScanner.Frame = new CGRect((View.Frame.Width / 2) - 100, y, 200, 122);
				}
				else
				{
					btnCardScanner.Frame = new CGRect((View.Frame.Width / 2) - 100, y, 200, 152);
				}
				btnCardScanner.SetBackgroundImage(new UIImage("card-icon.png"), UIControlState.Normal);

				//height setting for button
				start = hei + btnCardScanner.Frame.Height + 10;
				//Console.WriteLine(hei);
				//Console.WriteLine(btnCardScanner.Frame.Height);
				//Console.WriteLine(start);
				//Console.WriteLine(View.Frame.Height);
				//568
				//Scanning Button Click event
				btnCardScanner.TouchUpInside += async (sender, e) =>
				{
					
					try
					{
						scanner.UseCustomOverlay = false;
						var result = await scanner.Scan();

						if (result != null)
						{
							LoggingClass.LogInfo("User tried to login with" + result.Text, screenid);
							PreInfo(result.Text);
                            //EmailVerification();
						}
					}
					catch (Exception exe)
					{
						LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
					}
				};
				y = y + 200;
				//nfloat strtguest = strtbtn + btnLogin.Frame.Height + 10;
				UILabel lblGuest = new UILabel();
				lblGuest.Frame = new CGRect(20, View.Frame.Height - 50, View.Frame.Width, h);
				lblGuest.Text = "Not a VIP Member?";
				lblGuest.TextAlignment = UITextAlignment.Left;
				lblGuest.Font = UIFont.ItalicSystemFontOfSize(17);
				lblGuest.TextColor = UIColor.Black;

				btnGuestLogin = new UIButton(new CGRect(180, View.Frame.Height - 50, 120, 30));
				btnGuestLogin.SetTitle("Guest Log In", UIControlState.Normal);
				btnGuestLogin.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				btnGuestLogin.SetTitleColor(UIColor.White, UIControlState.Normal);
				btnGuestLogin.BackgroundColor = UIColor.Purple;
				//btnGuestLogin.SetImage(UIImage.FromFile ("Images/gl.png"), UIControlState.Normal);

				btnLogin = new UIButton(new CGRect(180, strtbtn, 120, 30));
				btnLogin.SetTitle("Log In", UIControlState.Normal);
				btnLogin.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				btnLogin.SetTitleColor(UIColor.White, UIControlState.Normal);
				btnLogin.BackgroundColor = UIColor.Purple;

				btnResend = new UIButton(new CGRect(30, strtbtn, 120, 30));
				btnResend.SetTitle("Resend Email", UIControlState.Normal);
				btnResend.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				btnResend.SetTitleColor(UIColor.White, UIControlState.Normal);
				btnResend.BackgroundColor = UIColor.Purple;

				BtnTest1 = new UIButton(new CGRect(200, strtbtn, 100, 30));
				BtnTest1.SetTitle("Continue", UIControlState.Normal);
				BtnTest1.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				BtnTest1.SetTitleColor(UIColor.White, UIControlState.Normal);
				BtnTest1.BackgroundColor = UIColor.Purple;

				BtnTest2 = new UIButton(new CGRect(30, strtbtn, 140, 30));
				BtnTest2.SetTitle("Update E-Mail Id", UIControlState.Normal);
				BtnTest2.HorizontalAlignment = UIControlContentHorizontalAlignment.Center;
				BtnTest2.SetTitleColor(UIColor.White, UIControlState.Normal);
				BtnTest2.BackgroundColor = UIColor.Purple;

				btnVerify = new UIButton(new CGRect(24, imageheight + 270, 240, 20));
				btnVerify.SetTitle("Verify", UIControlState.Normal);
				btnVerify.HorizontalAlignment = UIControlContentHorizontalAlignment.Right;
				btnVerify.SetTitleColor(UIColor.Purple, UIControlState.Normal);
				btnGuestLogin.TouchDown += async (sender, e) =>
				   {
					   CurrentUser.Store("0", "Guest");
					   if (RootTabs == null || _window == null)
					   {
						   _window = CurrentUser.window;
						   RootTabs = CurrentUser.RootTabs;
						   nav = new UINavigationController(RootTabs);
						   //AddNavigationButtons(nav);
						   _window.RootViewController = nav;
						   //nav.DismissViewController(true);
					   }
					   nav = new UINavigationController(RootTabs);
					   AddNavigationButtons(nav);
					   CurrentUser.RootTabs = RootTabs;
					   _window.RootViewController = nav;
					   CurrentUser.window = _window;
					   await svc.InsertUpdateGuest("Didn't get the token");

					   //this.NavigationController.PopToRootViewController (true);

				   };
				View.AddSubview(BtnTest1);
				View.AddSubview(BtnTest2);
				View.AddSubview(btnResend);
				View.AddSubview(btnLogin);
				View.AddSubview(imgLogo);
				View.AddSubview(btnGuestLogin);
				View.AddSubview(lblIns);
				View.AddSubview(btnCardScanner);
				View.AddSubview(lblInfo);
				View.AddSubview(lblGuest);
				View.AddSubview(lblContactus);
				View.BackgroundColor = UIColor.White;

			}
			catch (Exception exe)
			{
				LoggingClass.LogError(exe.Message, screenid, exe.StackTrace);
			}

		}