public MainPage() { AppLog.Write(); this.InitializeComponent(); DataContext = new MainPageVm(); }
/// <summary> /// Method that logs a user into the system /// </summary> /// <param name="username">A username string that is passed to this method</param> /// <param name="password">A password string that is passed to this method</param> public static async void Login(string username, string password) { foreach (Account account in _accountList.AccountList) { if (username == account.UserName && password == account.PassWord) { _account = new Account(account.UserName, account.PassWord, account.DisplayName); SetDisplayNameForUI = _account.DisplayName; AccountDetail = new AccountDetails(); _accountDetails = await AccountDetail.LoadUserDetailsFile(username); SetProfileImagePathForUI = _accountDetails.ProfilePicturePath; MainPageVm?.CallForAccountStatus(); StoreVm?.OnAccountChanged(); GameTemplateVm?.OnAccountChanged(); if (AccountDetail.AccountShoppingCart != null) { if (AccountDetail.AccountShoppingCart.Count > 0) { ShoppingCart.Instance.AddGame(AccountDetail?.AccountShoppingCart); } } else { AccountDetail.AccountShoppingCart = new ObservableCollection <Game>(); } MainPageVm?.RefreshPurchaseSelectedGame(); break; } } }
public MainPage() { this.InitializeComponent(); DataContext = _vm = new MainPageVm(); this.NavigationCacheMode = NavigationCacheMode.Required; }
public MainPage() { InitializeComponent(); MainPageVm vm = (MainPageVm)BindingContext; RestaurantsListView.ItemsSource = vm.Restaurants; ((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.Black; }
public void ChangeSign() { var vm = new MainPageVm(); vm.NumberTapHandler("1"); vm.NumberTapHandler("2"); vm.NumberTapHandler("3"); vm.SignTapHandler(); Assert.AreEqual("-123", vm.StringValue); }
public void CheckMultiply() { var vm = new MainPageVm(); vm.NumberTapHandler("6"); vm.MultiplyTapHandler(); vm.NumberTapHandler("7"); vm.EqualsTapHandler(); Assert.AreEqual("42", vm.StringValue); }
public void DivideByZero() { var vm = new MainPageVm(); vm.NumberTapHandler("7"); vm.DivideTapHandler(); vm.NumberTapHandler("0"); vm.EqualsTapHandler(); Assert.AreEqual(MainPageVm.ErrorState, vm.StringValue); }
public void CheckInput() { var vm = new MainPageVm(); vm.NumberTapHandler("1"); vm.NumberTapHandler("2"); vm.NumberTapHandler("3"); vm.DecimalTapHandler(); vm.NumberTapHandler("4"); vm.NumberTapHandler("5"); Assert.AreEqual("123.45", vm.StringValue); }
public void CheckSubtract() { var vm = new MainPageVm(); vm.NumberTapHandler("8"); vm.NumberTapHandler("2"); vm.SubtractTapHandler(); vm.NumberTapHandler("4"); vm.NumberTapHandler("0"); vm.EqualsTapHandler(); Assert.AreEqual("42", vm.StringValue); }
/// <summary> /// Creates an account in the system and writes the account to the files /// </summary> /// <param name="account">An account object that is passed</param> /// <param name="pfpPath">A string that is passed that links an image to the account</param> public static void CreateAccount(Account account, string pfpPath) { _accountList.AccountList.Add(account); SetDisplayNameForUI = _account.DisplayName; AccountDetail = new AccountDetails(); _accountDetails.DisplayName = account.DisplayName; _accountDetails.UserName = account.UserName; _accountDetails.ProfilePicturePath = pfpPath; SetProfileImagePathForUI = _accountDetails.ProfilePicturePath; _joinDateBeforeFormat = DateTime.Now; _accountDetails.JoinDate = _joinDateBeforeFormat.Date.ToShortDateString(); _accountDetails.CreateUserDetailsFile(_accountDetails, account.UserName); MainPageVm?.CallForAccountStatus(); StoreVm?.OnAccountChanged(); GameTemplateVm?.OnAccountChanged(); }
public void CheckAdd() { var vm = new MainPageVm(); vm.NumberTapHandler("2"); vm.NumberTapHandler("8"); vm.DecimalTapHandler(); vm.NumberTapHandler("4"); vm.AddTapHandler(); vm.NumberTapHandler("1"); vm.NumberTapHandler("3"); vm.DecimalTapHandler(); vm.NumberTapHandler("6"); vm.EqualsTapHandler(); Assert.AreEqual("42", vm.StringValue); }
/// <summary> /// Logs a user off the system and sets objects to null /// </summary> public static void LogOff() { _accountDetails.CreateUserDetailsFile(_accountDetails, _account.UserName); //Bellow needs implementing without errors /*foreach (Game game in AccountDetail.AccountShoppingCart.Games) * { * ShoppingCart.Instance.RemoveGame(game); * }*/ _account = null; _displaynameForUI = null; _accountDetails = null; SetProfileImagePathForUI = null; MainPageVm?.CallForAccountStatus(); StoreVm?.OnAccountChanged(); GameTemplateVm?.OnAccountChanged(); ShoppingCart.Instance.ClearShoppingCart(); MainPageVm?.RefreshPurchaseSelectedGame(); }
public CategoryPage() { this.InitializeComponent(); pageVm = new MainPageVm(); DataContext = pageVm; }
public MainPage() { InitializeComponent(); BindingContext = new MainPageVm(Navigation); }
public MainPage() { this.InitializeComponent(); //textBox.Text = "hej!"; DataContext = _vm = new MainPageVm(); }
public MainPage() { this.InitializeComponent(); DataContext = new MainPageVm(); }