Exemplo n.º 1
0
        public MainWindow(int boardWidth, int boardHeight, IList <Player> players)
        {
            InitializeComponent();

            Game    = new Game(boardWidth, boardHeight, players);
            BoardVM = new BoardVM(Game);
            InitializeBoard(boardWidth, boardHeight);
            Game.BoardChanged += Board_BoardChangedAsync;
            Game.GameOver     += Board_GameOver;
        }
        public ActionResult AllTasks()
        {
            BoardVM VM      = new BoardVM();
            var     members = m.Find(new Guid(Request.Cookies["MemberGUID"].Value));
            var     q       = from parentTask in t.GetCollections()
                              join childrenTask in t.GetCollections() on parentTask.TaskGUID equals childrenTask.ParentTaskGUID
                              select childrenTask;

            VM.Tasks = q.Where(x => x.EmployeeGUID == members.EmployeeGUID && x.Project.ProjectStatusID == 1 && x.TaskStatusID == 2).ToList();
            return(PartialView(VM));
        }
Exemplo n.º 3
0
        private async void AnalyzeButton_Click(object sender, RoutedEventArgs e)
        {
            if (Game.IsOver)
            {
                return;
            }

            IPositional selectedTile = await AIPlayAsync(showAnalysis : true);

            BoardVM.Select(selectedTile);
        }
        internal BoardManagementPage(BoardVM selectedBoard)
        {
            _viewModel = new BoardManagementPageViewModel(selectedBoard);

            _viewModel.ShowBoardPage            = () => Navigation.PopAsync();
            _viewModel.ShowConfirmDeletePopup   = SetConfirmDeletePopup;
            _viewModel.DisplayExceptionMessage += (exMessage) => DisplayAlert(AppResources.Error, exMessage, AppResources.Ok);

            BindingContext = _viewModel;
            InitializeComponent();
        }
Exemplo n.º 5
0
        public ActionResult EditTaskStatusID(Guid id, int TaskStatusID, int?WorkTime)
        {
            BoardVM VM = new BoardVM();

            VM.Task = t.Find(id);
            VM.Task.TaskStatusID = TaskStatusID;
            if (TaskStatusID == 3)
            {
                VM.Task.EndDate  = DateTime.Now;
                VM.Task.WorkTime = WorkTime;
            }
            t.Update(VM.Task);
            return(Json(true));
        }
Exemplo n.º 6
0
        public BoardVM Get(int id)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            BoardVM board           = db.Boards.Where(b => b.Id == id).Select(b => new BoardVM
            {
                Name  = b.Name,
                Posts = db.Posts.Where(p => p.BoardId == b.Id).Select(p => new PostVM {
                    Id      = p.Id,
                    BoardId = b.Id,
                    Title   = p.Title,
                    Author  = p.User.Username,
                    Posted  = p.Posted
                }).ToList()
            }).FirstOrDefault();

            return(board);
        }
Exemplo n.º 7
0
        internal MainPage(BoardVM board)
        {
            InitializeComponent();

            _viewModel = new MainPageViewModel(board);

            _viewModel.DisplayAddColumn         = SetAddColumnPopup;
            _viewModel.DisplayExceptionMessage  = (exMessage) => DisplayAlert(AppResources.Error, exMessage, AppResources.Ok);
            _viewModel.DisplayAddTask           = SetNewTaskPopup;
            _viewModel.DisplayRenameColumnPopup = SetRenameColumnPopup;
            _viewModel.DisplayTaskPage          = (task) => Navigation.PushAsync(new TaskPage(task));
            _viewModel.DisplayMoveTaskPopup     = SetColumnChoosePopup;
            _viewModel.CloseMoveTaskPopup       = () => MainPopup.IsOpen = false;
            MainPopup.PopupView.HeightRequest   = 150;

            BindingContext = _viewModel;
        }
Exemplo n.º 8
0
        public BoardVM CreateNewBoard(SolidColorBrush whiteColor, SolidColorBrush blackColor)
        {
            BoardVM     board = new BoardVM();
            List <char> files = new List <char>()
            {
                'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'
            };
            List <int> ranks = new List <int>()
            {
                1, 2, 3, 4, 5, 6, 7, 8
            };

            foreach (char file in files)
            {
                foreach (int rank in ranks)
                {
                    SolidColorBrush color = Brushes.Transparent;
                    if (file == 'A' || file == 'C' || file == 'E' || file == 'G')
                    {
                        if (rank % 2 == 0)
                        {
                            color = whiteColor;
                        }
                        else
                        {
                            color = blackColor;
                        }
                    }
                    else
                    {
                        if (rank % 2 == 0)
                        {
                            color = blackColor;
                        }
                        else
                        {
                            color = whiteColor;
                        }
                    }
                    board.AddSquare(new BoardSquareVM(file, rank, color));
                }
            }
            return(board);
        }
Exemplo n.º 9
0
        private async Task <IPositional> AIPlayAsync(bool showAnalysis = false)
        {
            Player player = Game.Manager.CurrentPlayer;

            if (player is null)
            {
                throw new InvalidOperationException($"{nameof(player)} is null.");
            }

            if (player.AI is null)
            {
                throw new InvalidOperationException($"{nameof(player.AI)} is null.");
            }

            BoardBorder.IsEnabled = false;

            var            sw     = Stopwatch.StartNew();
            AnalysisResult result = await Task.Run(() => player.AI.Analyze(Game));

            sw.Stop();
            if (sw.ElapsedMilliseconds < 500)
            {
                var delay = 500 - sw.ElapsedMilliseconds;
                await Task.Delay((int)delay);
            }

            if (showAnalysis)
            {
                BoardVM.ClearHighlightedTiles();
                BoardVM.Highlight(result.PossibleChoices);
                BoardVM.Highlight(Game.LastMove);
            }

            BoardBorder.IsEnabled = true;

            return(result.SelectedChoice);
        }
        public JsonResult AddBoard(BoardVM row)
        {
            ///Set time
            var today = preUni.getCurrentTime();

            using (Db db = new Db())
            {
                #region Create boardNumber
                string branchCode;
                //Get branchCode
                if (row.BranchName == "ALL")
                {
                    branchCode = "00";
                }
                else
                {
                    branchCode = db.Users.FirstOrDefault(x => x.BranchName == row.BranchName).BranchCode.ToString("D2");
                }

                Guid id = Guid.NewGuid();

                string boardNumber;
                if (db.Boards.Any(x => x.BoardNumber == row.BoardNumber))
                {
                    boardNumber = row.BoardNumber;
                }
                else
                {
                    boardNumber = today.Date.ToString("Mdd") + branchCode + id.ToString().Split('-')[1];
                }
                #endregion

                #region imageUpload
                //set dir
                var TempDir = new DirectoryInfo(string.Format("{0}Images\\Board\\Temp", Server.MapPath(@"\")));
                var SaveDir = new DirectoryInfo(string.Format("{0}Images\\Board\\Original", Server.MapPath(@"\")));

                try
                {
                    var picList = Directory.EnumerateFiles(TempDir.ToString(), "*.*", SearchOption.AllDirectories);

                    //.GetFiles(TempDir, "*.jpg|*.png|*.jpeg|*.gif|);

                    int fileNumber = Directory.EnumerateFiles(SaveDir.ToString(), row.BoardNumber + "_*.*", SearchOption.AllDirectories).Count();
                    // Copy picture files.
                    foreach (string file in picList)
                    {
                        string ext         = file.Substring(file.LastIndexOf('.'));
                        string preFilename = file.Substring(file.LastIndexOf('\\') + 1);

                        fileNumber++;
                        string fileName = boardNumber + "_" + fileNumber + ext;
                        // Use the Path.Combine method to safely append the file name to the path.
                        // Will overwrite if the destination file already exists.
                        //File = /images/board/Images/{boardNumber}_{1,2,3...}
                        System.IO.File.Copy(Path.Combine(file), Path.Combine(SaveDir.ToString(), fileName), true);

                        //change href in Contensts image tags
                        string HtmlTempDir = @"/images/Board/Temp/" + preFilename;
                        string HtmlSaveDir = @"/images/Board/Original/" + fileName;
                        //change href in Contensts image tags
                        row.Contents = row.Contents.Replace(HtmlTempDir, HtmlSaveDir);
                    }

                    foreach (string f in picList)
                    {
                        System.IO.File.Delete(f);
                    }
                }
                catch (DirectoryNotFoundException dirNotFound)
                {
                    Console.WriteLine(dirNotFound.Message);
                }
                #endregion

                BoardDTO boardDTO;
                //If boardNumber exist, Edit Board
                if (db.Boards.Any(x => x.BoardNumber == row.BoardNumber))
                {
                    boardDTO            = db.Boards.Where(x => x.BoardNumber == row.BoardNumber).FirstOrDefault();
                    boardDTO.LastUserId = User.Identity.Name;
                    boardDTO.Category   = row.Category;
                    boardDTO.BranchCode = Int32.Parse(branchCode);
                    boardDTO.ModifiedAt = today;
                    boardDTO.Title      = row.Title;
                    boardDTO.Contents   = row.Contents;
                    preUni.logging(User.Identity.Name, "Edit Board : " + row.BoardNumber);
                }
                else
                {
                    boardDTO = new BoardDTO
                    {
                        UserId      = User.Identity.Name,
                        LastUserId  = User.Identity.Name,
                        BoardNumber = boardNumber,
                        Category    = row.Category,
                        BranchCode  = Int32.Parse(branchCode),
                        CreateAt    = today,
                        ModifiedAt  = today,
                        Title       = row.Title,
                        Contents    = row.Contents
                    };
                    db.Boards.Add(boardDTO);
                    preUni.logging(User.Identity.Name, "Write Board : " + row.BoardNumber);
                }
                db.SaveChanges();

                var boardVM = db.Boards.ToArray().Where(x => x.BoardId == boardDTO.BoardId).Select(x => new BoardVM(x)).FirstOrDefault();

                boardVM.BranchName = row.BranchName;
                if (boardDTO.BranchCode == 0)
                {
                    boardVM.BranchState = "ALL";
                }
                else
                {
                    boardVM.BranchState = db.Users.Where(x => x.BranchCode == boardDTO.BranchCode).FirstOrDefault().State;
                }
                boardVM.UserState = db.Users.Find(User.Identity.Name).BranchCode;

                var json = JsonConvert.SerializeObject(boardVM);
                preUni.logging(User.Identity.Name, "Write board contents : " + boardVM.BoardNumber);
                return(Json(boardVM));
            };
        }
Exemplo n.º 11
0
 public IActionResult Put(int id, BoardVM boardVM)
 {
     _repository.Update(id, boardVM);
     return(Ok("Updated Succesfully"));
 }
Exemplo n.º 12
0
 public IActionResult Insert(BoardVM boardVM)
 {
     _repository.Insert(boardVM);
     return(Ok("Insert Succesfully"));
 }