Пример #1
0
        public ActionResult Index()
        {
            if (Session["ViewModel"] == null)
            {
                SimpleLogger.SimpleLog.Log($"new login");
                var login = User.Identity.Name;

                SimpleLogger.SimpleLog.Log($"new login {login}");

                var userName = login.Split('\\')[1];

                var model = new TilesModel();

                foreach (SiteConfig cfg in AppConfig.SitesConfigs)
                {
                    if (cfg.CheckAuth(userName))
                    {
                        model.AllowedSiteCollection.Add(cfg);
                    }
                    else
                    {
                        model.DisallowedSiteCollection.Add(cfg);
                    }
                }

                Session["ViewModel"] = model;
            }

            return(View(Session["ViewModel"]));
        }
Пример #2
0
 private void MoveTileToEmptyZone(int index)
 {
     TilesModel.MoveTileToEmptyness(index);
     RefreshView();
     Moves++;
     CheckWinsCondition();
 }
 public ModifiledTileAction(int newTileIndex, int rIndex, int cIndex, TilesModel matrixObject)
 {
     this.oldTileIndex = matrixObject.Matrix[rIndex, cIndex];
     this.newTileIndex = newTileIndex;
     this.rIndex       = rIndex;
     this.cIndex       = cIndex;
     this.matrixObject = matrixObject;
 }
Пример #4
0
 private void CheckWinsCondition()
 {
     if (TilesModel.IsInOrder())
     {
         MessageBox.Show($"Total moves: {Moves}", "Game completed!", MessageBoxButton.OK);
         Rows  = 0;
         Moves = 0;
     }
 }
 public AddDevicesViewModel()
 {
     this.Account = new AccountModel()
     {
         Email = App.SessionAccount
     };
     newTiles         = new TilesModel();
     client           = new FireSharp.FirebaseClient(config);
     AddCommand       = new RelayCommand(o => AddNewDevices(this.Account));
     CloseCommand     = new RelayCommand(o => BackAction());
     MouseDownCommand = new RelayCommand(o => DragWindow());
     ButtonEnable     = "True";
 }
Пример #6
0
        public async void ChangeTilesStatus(AccountModel account, TilesModel data, string FromState)
        {
            try {
                if (Convert.ToInt32(SelectedTilesIndex) > 0)
                {
                    string username = account.Email.Substring(0, account.Email.IndexOf("@"));
                    data        = data ?? new TilesModel();
                    data.Status = FromState.Equals("ON") ? "OFF" : "ON";
                    int index = Convert.ToInt32(SelectedTilesIndex);
                    Tiles[index].Status = data.Status;
                    FirebaseResponse response = await client.UpdateAsync <TilesModel>("/Account/" + username + "/Tiles/" + SelectedTilesIndex + "/", data);

                    TilesModel result = response.ResultAs <TilesModel>() ?? new TilesModel();
                    OnPropertyChanged(nameof(Tiles));
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Пример #7
0
 private void StartNewGame()
 {
     _tilesModel = new TilesModel(Rows);
     Moves       = 0;
     RefreshView();
 }
Пример #8
0
        public void ModifiedTile(int newTileIndex, int rIndex, int cIndex, TilesModel matrixObject)
        {
            var action = new ModifiledTileAction(newTileIndex, rIndex, cIndex, matrixObject);

            HandlePushAction(action);
        }
Пример #9
0
 public TilesViewModel(TilesModel model)
 {
     _model = model;
     Id     = model.ID;
 }