Exemplo n.º 1
0
        public DrawViewModel InitiateDraw()
        {
            var result = new DrawViewModel();

            result.Members      = (List <MemberViewModel>)_memberService.GetMembers();
            result.TotalMembers = result.Members.Count();
            result.TotalDraws   = _ctx.Draws.Count();

            return(result);
        }
Exemplo n.º 2
0
 public override void Dispose()
 {
     DrawViewModel.Dispose();
     DrawViewModel = null;
     ServerService.instance.socket.Off("game-drawer");
     ServerService.instance.socket.Off("game-timer");
     ServerService.instance.socket.Off("game-over");
     ServerService.instance.socket.Off("game-points");
     ServerService.instance.socket.Off("game-guessLeft");
     ServerService.instance.socket.Off("game-clear");
     ServerService.instance.socket.Off("gameplay");
 }
Exemplo n.º 3
0
        private Boolean IsGameCreationIncorrect()
        {
            List <string> clues = new List <string>();

            foreach (var hint in Hints)
            {
                clues.Add(hint.Hint.Trim());
            }

            string solution = (ObjectName == null) ? Solution : ObjectName;

            if (solution == null && SelectedCreationType == CreationType.Assisted2)
            {
                ShowMessageBox("Generate an image first");
                return(true);
            }

            if (string.IsNullOrEmpty(solution) || Regex.IsMatch(solution.ToString().Trim(), "[^a-zA-Z ]"))
            {
                ShowMessageBox("Word or solution should be alphabetic");
                return(true);
            }
            solution = solution.Trim();

            if (clues.Count == 1 && string.IsNullOrEmpty(clues[0]))
            {
                ShowMessageBox("Atleast one hint needs to be provided");
                return(true);
            }

            foreach (var clue in clues)
            {
                if (string.IsNullOrEmpty(clue) || Regex.IsMatch(clue.ToString(), "[^a-zA-Z ]"))
                {
                    ShowMessageBox("Hints should be alphabetic");
                    return(true);
                }
            }

            JArray drawing = (DrawViewModel.GetDrawing().Count == 0) ? GeneratedImageStrokes : DrawViewModel.GetDrawing();

            if (SelectedCreationType != CreationType.Assisted1 && (drawing == null || drawing.Count <= 0))
            {
                ShowMessageBox("A drawing should be provided");
                return(true);
            }
            return(false);
        }
Exemplo n.º 4
0
        public DrawPage()
        {
            InitializeComponent();
            Loaded += (s, e) => SetCanvasSize();

            var strokeService             = new InkStrokesService(inkCanvas.InkPresenter.StrokeContainer);
            var selectionRectangleService = new InkSelectionRectangleService(inkCanvas, selectionCanvas, strokeService);

            ViewModel = new DrawViewModel(
                strokeService,
                new InkLassoSelectionService(inkCanvas, selectionCanvas, strokeService, selectionRectangleService),
                new InkPointerDeviceService(inkCanvas),
                new InkCopyPasteService(strokeService),
                new InkUndoRedoService(inkCanvas, strokeService),
                new InkFileService(inkCanvas, strokeService),
                new InkZoomService(canvasScroll));
        }
Exemplo n.º 5
0
 public GameViewModel(string mode)
 {
     if (DrawViewModel != null)
     {
         DrawViewModel.Dispose();
         DrawViewModel = null;
     }
     DrawViewModel          = new DessinViewModel();
     _points                = new ObservableCollection <PointsDisplay>();
     _myPoints              = "0";
     Mode                   = mode;
     DrawViewModel.IsDrawer = false;
     _guessLeft             = "0";
     ServerService.instance.socket.On("game-drawer", data => processRole((JObject)data));
     ServerService.instance.socket.On("game-timer", data => processTime((JObject)data));
     ServerService.instance.socket.On("game-over", data => processEndGame((JObject)data));
     ServerService.instance.socket.On("game-points", data => processPoints((JObject)data));
     ServerService.instance.socket.On("game-guessLeft", data => processGuess((JObject)data));
     ServerService.instance.socket.On("game-clear", processClear);
 }
Exemplo n.º 6
0
        public IActionResult Draw()
        {
            if (!_repo.IsDrawn())
            {
                var drawRan = RunDraw();
                if (!drawRan)
                {
                    return(RedirectToAction("Error"));
                }
            }

            var draw = new DrawViewModel
            {
                countries = _repo.GetCountryList(),
                people    = _repo.GetPeopleList(),
                timeStamp = _repo.GetTimestamp()
            };

            return(View(draw));
        }
Exemplo n.º 7
0
        private async Task <HttpResponseMessage> CreateManual()
        {
            JArray        drawing = DrawViewModel.GetDrawing();
            List <string> clues   = new List <string>();

            foreach (var hint in Hints)
            {
                clues.Add(hint.Hint.Trim());
            }

            var newGame = new JObject(new JProperty("solution", Solution.Trim()),
                                      new JProperty("clues", clues.ToArray()),
                                      new JProperty("difficulty", SelectedDifficulty.ToLower()),
                                      new JProperty("drawing", drawing),
                                      new JProperty("displayMode", SelectedDisplayMode.ToLower()),
                                      new JProperty("side", SelectedPanoramicMode.ToLower()));

            var content = new StringContent(newGame.ToString(), Encoding.UTF8, "application/json");

            return(await ServerService.instance.client.PostAsync(Constants.SERVER_PATH + Constants.GAMECREATOR_PATH, content));
        }
Exemplo n.º 8
0
        public ActionResult GenerateDraw(DrawViewModel drawFormViewModel)
        {
            if (ModelState.IsValid)
            {
                var file = this.drawService.GenerateDrawFromCommands(drawFormViewModel);

                if (file.Errors != null && file.Errors.Any())
                {
                    var errors = string.Join("<br>", file.Errors);
                    ModelState.AddModelError("File Validation", errors);

                    return(View("Index", drawFormViewModel));
                }

                if (file.FileContent != null)
                {
                    return(File(file.FileContent, "text/plain", "output.txt"));
                }
            }

            return(View("Index", drawFormViewModel));
        }
        public IHttpActionResult postUser(DrawViewModel model)
        {
            db.openConnection();
            DataTable dt = null;

            try
            {
                if (model.actionUser.ToLower() == "draw_automatic_user_team")
                {
                    paramName  = new string[] { "pIdCamp" };
                    paramValue = new string[] { Convert.ToString(model.championshipID) };
                    dt         = db.executePROC("spAutomaticDrawOfTimes", paramName, paramValue);

                    if (dt.Rows[0]["msgRetornoSorteioAutomaticoTimes"].ToString() == String.Empty)
                    {
                        model.returnMessage = "ModeratorSuccessfully";
                    }
                    else
                    {
                        model.returnMessage = dt.Rows[0]["msgRetornoSorteioAutomaticoTimes"].ToString();
                    }

                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser.ToLower() == "cancel_draw_user_team")
                {
                    paramName  = new string[] { "pIdCamp" };
                    paramValue = new string[] { Convert.ToString(model.championshipID) };
                    dt         = db.executePROC("spCancelDrawOfTimes", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser.ToLower() == "assume_draw_user_team")
                {
                    paramName  = new string[] { "pIdCamp" };
                    paramValue = new string[] { Convert.ToString(model.championshipID) };
                    dt         = db.executePROC("spAssumeDrawOfTimesByDrawLeague", paramName, paramValue);

                    if (dt.Rows[0]["msgRetornoSorteioAssumirTimesLiga"].ToString() == String.Empty)
                    {
                        model.returnMessage = "ModeratorSuccessfully";
                    }
                    else
                    {
                        model.returnMessage = dt.Rows[0]["msgRetornoSorteioAssumirTimesLiga"].ToString();
                    }

                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser.ToLower() == "draw_automatic_match_table")
                {
                    paramName  = new string[] { "pIdCamp" };
                    paramValue = new string[] { Convert.ToString(model.championshipID) };
                    dt         = db.executePROC("spAutomaticDrawOfTables", paramName, paramValue);

                    if (dt.Rows[0]["msgRetornoSorteioAutomaticoTabelas"].ToString() == String.Empty)
                    {
                        model.returnMessage = "ModeratorSuccessfully";
                    }
                    else
                    {
                        model.returnMessage = dt.Rows[0]["msgRetornoSorteioAutomaticoTabelas"].ToString();
                    }

                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser.ToLower() == "cancel_draw_match_table")
                {
                    paramName  = new string[] { "pIdCamp" };
                    paramValue = new string[] { Convert.ToString(model.championshipID) };
                    dt         = db.executePROC("spCancelDrawOfJogos", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser.ToLower() == "draw_automatic_group_table")
                {
                    paramName  = new string[] { "pIdCamp" };
                    paramValue = new string[] { Convert.ToString(model.championshipID) };
                    dt         = db.executePROC("spAutomaticDrawOfGroupForPots", paramName, paramValue);

                    if (dt.Rows[0]["msgRetornoSorteioAutomaticoGruposPorPotes"].ToString() == String.Empty)
                    {
                        model.returnMessage = "ModeratorSuccessfully";
                    }
                    else
                    {
                        model.returnMessage = dt.Rows[0]["msgRetornoSorteioAutomaticoGruposPorPotes"].ToString();
                    }

                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else if (model.actionUser.ToLower() == "cancel_draw_group_table")
                {
                    paramName  = new string[] { "pIdCamp" };
                    paramValue = new string[] { Convert.ToString(model.championshipID) };
                    dt         = db.executePROC("spCancelDrawOfGrupos", paramName, paramValue);

                    model.returnMessage = "ModeratorSuccessfully";
                    return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
                }
                else
                {
                    return(StatusCode(HttpStatusCode.NotAcceptable));
                }
            }
            catch (Exception ex)
            {
                model.returnMessage = "error_" + ex.Message;
                return(CreatedAtRoute("DefaultApi", new { id = 0 }, model));
            }
            finally
            {
                db.closeConnection();
                dt = null;
            }
        }
        public DrawResultDTO Execute(DrawViewModel drawViewModel)
        {
            var commandsToExecute = this.getCommandsToDrawCommand.Execute(drawViewModel.DrawCommands.InputStream);

            return(this.ExecuteCommands(commandsToExecute.DrawCommands, commandsToExecute.CommandsWithErrors));
        }
Exemplo n.º 11
0
 public DrawResultDTO GenerateDrawFromCommands(DrawViewModel drawViewModel)
 {
     return(this.generateDrawInvoker.Execute(drawViewModel));
 }
Exemplo n.º 12
0
 public DrawView()
 {
     InitializeComponent();
     viewModel   = new DrawViewModel();
     DataContext = viewModel;
 }
Exemplo n.º 13
0
 public MainWindow()
 {
     InitializeComponent();
     _viewModel       = new DrawViewModel();
     this.DataContext = _viewModel;
 }