public override void ViewDidLoad () { base.ViewDidLoad (); userPro = new UserProcess (); hud = new MTMBProgressHUD (this.View) { LabelText = "Waiting...", RemoveFromSuperViewOnHide = true, DimBackground = true }; this.View.AddSubview (hud); this.NavigationController.NavigationBarHidden = true; this.View.BackgroundColor = UIColor.FromRGB (230, 236, 245); imgView = new UIImageView (new CoreGraphics.CGRect (0, 0, this.View.Frame.Width, this.View.Frame.Height)); imgView.Image = UIImage.FromFile ("System/bg.png"); btnGoMain = new UIButton (UIButtonType.System); btnGoMain.Frame = new CoreGraphics.CGRect (this.View.Frame.Width / 2 - 100, this.View.Frame.Height / 2 + 150, 200, 50); btnGoMain.SetTitle ("开启DIY定制", UIControlState.Normal); btnGoMain.SetTitleColor (UIColor.White, UIControlState.Normal); btnGoMain.Font = UIFont.FromName ("Helvetica-Bold", 30f); btnGoMain.TouchUpInside += btnGoMain_TouchUpInside; btnLogout = new UIButton (UIButtonType.System); btnLogout.SetImage (UIImage.FromFile ("System/椭圆 1.png"), UIControlState.Normal); btnLogout.Frame = new CoreGraphics.CGRect (980, 25, 30, 30); btnLogout.BackgroundColor = UIColor.White; btnLogout.TouchUpInside += BtnLogout_TouchUpInside; this.View.AddSubviews (imgView, btnGoMain, btnLogout); }
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions) { // if (1 == 1) { // UIAlertView alert = new UIAlertView (); // alert.Title = "升级提醒"; // alert.Message="发现有新版本可以更新,请尽快更新,否则影响正常使用"; // alert.AddButton ("进行升级"); // alert.AddButton ("取消"); // alert.Dismissed += Alert_Dismissed; // alert.Show (); // } _window = new UIWindow (UIScreen.MainScreen.Bounds); UINavigationController _nva = new UINavigationController (); _nva.SetNavigationBarHidden (true, false); //自动登录 Sys_User lastLoginUser = new UserProcess ().GetLastLoginUser (); if (lastLoginUser != null) { //系统静态存储 SystemObject.User = lastLoginUser; //更新登录状态到数据库? //跳转到主页面 _nva.PushViewController (new MainController (), true); } else { _nva.PushViewController (new ViewController (), true); } _window.RootViewController = _nva; _window.MakeKeyAndVisible (); return true; }
public override void ViewDidLoad () { base.ViewDidLoad (); //用户相关处理类 userPro = new UserProcess (); //初始化加载控件 hud = new MTMBProgressHUD (this.View) { LabelText = "Loading...", RemoveFromSuperViewOnHide = true, DimBackground = true }; this.View.AddSubview (hud); hud.Show (true); //整体view背景色 this.View.BackgroundColor = UIColor.Gray; // Perform any additional setup after loading the view, typically from a nib. imgView = new UIImageView (new CoreGraphics.CGRect (0, 0, this.View.Frame.Width, this.View.Frame.Height)); imgView.Image = UIImage.FromFile ("Login/Login_background.jpg"); //登录背景 loginView = new UIView (new CoreGraphics.CGRect (550, 250, 350, 300)); loginView.Alpha = (nfloat)0.45; loginView.BackgroundColor = UIColor.FromRGB ((nfloat)249, (nfloat)249, (nfloat)249); //登录标签 lblLogin = new UILabel (new CoreGraphics.CGRect (550, 280, this.loginView.Frame.Width, 30)); lblLogin.Text = "登录"; lblLogin.TextAlignment = UITextAlignment.Center; //用户名 txtLoginName = new UITextField (new CoreGraphics.CGRect (580, 330, this.loginView.Frame.Width - 60, 50)); txtLoginName.BackgroundColor = UIColor.White; txtLoginName.TextColor = UIColor.Gray; txtLoginName.Placeholder = " 用户名"; //密码 txtPassword = new UITextField (new CoreGraphics.CGRect (580, 400, this.loginView.Frame.Width - 60, 50)); txtPassword.BackgroundColor = UIColor.White; txtPassword.TextColor = UIColor.Gray; txtPassword.SecureTextEntry = true; txtPassword.Placeholder = " 密码"; //登录按钮 btnLogin = new UIButton (UIButtonType.System); btnLogin.Frame = new CoreGraphics.CGRect (580, 470, this.loginView.Frame.Width - 60, 50); btnLogin.SetTitle ("开始定制DIY", UIControlState.Normal); btnLogin.SetTitleColor (UIColor.FromRGB (186, 224, 249), UIControlState.Normal); btnLogin.BackgroundColor = UIColor.FromRGB (84, 138, 227); btnLogin.TouchUpInside += BtnLogin_TouchUpInside; //添加控件 this.View.AddSubviews (imgView, loginView, lblLogin, txtLoginName, txtPassword, btnLogin); //键盘事件 UIKeyboard.Notifications.ObserveWillShow ((s, e) => { if (!IskeyboardShow) { CoreGraphics.CGRect kbdFrame = e.FrameEnd; CoreGraphics.CGRect viewFrame = this.View.Frame; viewFrame.Y = viewFrame.Y - kbdFrame.Height + 180; this.View.Frame = viewFrame; IskeyboardShow = true; } }); UIKeyboard.Notifications.ObserveWillHide ((s, e) => { CoreGraphics.CGRect kbdFrame = e.FrameEnd; CoreGraphics.CGRect viewFrame = this.View.Frame; viewFrame.Y = viewFrame.Y + kbdFrame.Height - 180; this.View.Frame = viewFrame; IskeyboardShow = false; }); }
/// <summary> /// Buttons the login touch up inside. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> private void BtnLogin_TouchUpInside (object sender, EventArgs e) { string username = this.txtLoginName.Text; string password = this.txtPassword.Text; if (CheckLogin (username, password)) { //loading // hud = new MTMBProgressHUD (this.View) { // LabelText = "Waiting...", // RemoveFromSuperViewOnHide = true, // DimBackground = true // }; // this.View.AddSubview (hud); //hud.DidHide += HandleDidHide; hud.LabelText = "Waiting..."; hud.Show (true); //用户登录 AccountAPI accountClient = new AccountAPI (); UserLoginStatus res = accountClient.UserLogin (username, password); if (res.LoginStatus.Status) { this.View.EndEditing (true); //系统静态存储 SystemObject.User = res.LoginUser; //添加到本地数据库 res.LoginUser.PassWord = password; UserProcess userPro = new UserProcess (); userPro.UserInsert (res.LoginUser); //跳转到主页面 main = new MainController (); this.NavigationController.PushViewController (main, true); } else { UIAlertView alert = new UIAlertView (); alert = new UIAlertView (); alert.Title = "登录提醒"; alert.Message = "登录失败"; alert.AddButton ("确定"); alert.Show (); } hud.Hide (true); } }