Beispiel #1
0
        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;
                }
            }
        }
Beispiel #3
0
        public MainPage()
        {
            this.InitializeComponent();
            DataContext = _vm = new MainPageVm();

            this.NavigationCacheMode = NavigationCacheMode.Required;
        }
Beispiel #4
0
        public MainPage()
        {
            InitializeComponent();
            MainPageVm vm = (MainPageVm)BindingContext;

            RestaurantsListView.ItemsSource = vm.Restaurants;
            ((NavigationPage)Application.Current.MainPage).BarBackgroundColor = Color.Black;
        }
Beispiel #5
0
        public void ChangeSign()
        {
            var vm = new MainPageVm();

            vm.NumberTapHandler("1");
            vm.NumberTapHandler("2");
            vm.NumberTapHandler("3");
            vm.SignTapHandler();
            Assert.AreEqual("-123", vm.StringValue);
        }
Beispiel #6
0
        public void CheckMultiply()
        {
            var vm = new MainPageVm();

            vm.NumberTapHandler("6");
            vm.MultiplyTapHandler();
            vm.NumberTapHandler("7");
            vm.EqualsTapHandler();
            Assert.AreEqual("42", vm.StringValue);
        }
Beispiel #7
0
        public void DivideByZero()
        {
            var vm = new MainPageVm();

            vm.NumberTapHandler("7");
            vm.DivideTapHandler();
            vm.NumberTapHandler("0");
            vm.EqualsTapHandler();
            Assert.AreEqual(MainPageVm.ErrorState, vm.StringValue);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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();
 }
Beispiel #11
0
        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;
 }
Beispiel #14
0
        public MainPage()
        {
            InitializeComponent();

            BindingContext = new MainPageVm(Navigation);
        }
Beispiel #15
0
 public MainPage()
 {
     this.InitializeComponent();
     //textBox.Text = "hej!";
     DataContext = _vm = new MainPageVm();
 }
Beispiel #16
0
 public MainPage()
 {
     this.InitializeComponent();
     DataContext = new MainPageVm();
 }