예제 #1
0
        private async Task LoadGameMap()
        {
            try
            {
                if (this._selectedGameId == 0)
                {
                    return;
                }
                codeCore.Visible = true;
                var index = 0;
                RemoveItems();
                var result = await _gameServiceRepository.GetGameMap(new Request <int>(this._selectedGameId).SetToken());
                await ReadGameInfo();
                await LoadPlayedGameList();

                var name = "";
                foreach (var item in result)
                {
                    UserControl ctrl;
                    switch (item.ControllerType)
                    {
                    case Enums.ControllerType.VerticalLine:
                        ctrl = new UCVerticalLine();
                        name = "ucVerticalLine_";
                        break;

                    case Enums.ControllerType.HorizontalLine:
                        ctrl = new UCHorizontalLine();
                        name = "ucHorizontalLine_";
                        break;

                    case Enums.ControllerType.Charactor:
                        ctrl       = new UCCharactor();
                        name       = "ucChar_";
                        _charactor = ctrl;
                        X          = item.PointX;
                        Y          = item.PointY;
                        break;

                    case Enums.ControllerType.Target:
                        ctrl = new UCTarget();
                        name = "ucTarget_";
                        break;

                    default:
                        continue;
                    }

                    ctrl.Name     = $"{name}{index}";
                    ctrl.Location = new Point(item.PointX, item.PointY);
                    ctrl.Size     = new Size(item.Width, item.Height);
                    Controls.Add(ctrl);
                    index++;
                }
            }
            catch (Exception ex)
            {
                new ExceptionHandler(ex);
            }
        }
예제 #2
0
        private async void btnLoadGame_Click(object sender, EventArgs e)
        {
            var result = new List <GameMapModel>();

            try
            {
                result = await _gameServiceRepository.GetGameMap(new Request <int>(_selectedGame).SetToken());
            }
            catch (Exception ex)
            {
                Helper.Error(ex: ex);
                return;
            }
            RemoveItems();
            var name = string.Empty;

            foreach (var item in result)
            {
                UserControl ctrl;
                switch (item.ControllerType)
                {
                case Enums.ControllerType.VerticalLine:
                    ctrl = new UCVerticalLine();
                    name = "ucVerticalLine_";
                    break;

                case Enums.ControllerType.HorizontalLine:
                    ctrl = new UCHorizontalLine();
                    name = "ucHorizontalLine_";
                    break;

                case Enums.ControllerType.Charactor:
                    ctrl = new UCCharactor();
                    name = "ucChar_";
                    break;

                case Enums.ControllerType.Target:
                    ctrl = new UCTarget();
                    name = "ucTarget_";
                    break;

                default:
                    continue;
                }
                ctrl.Name        = $"{name}{index}";
                ctrl.MouseEnter += control_MouseEnter;
                ctrl.MouseLeave += control_MouseLeave;
                ctrl.MouseDown  += control_MouseDown;
                ctrl.MouseMove  += control_MouseMove;
                ctrl.MouseUp    += control_MouseUp;
                ctrl.KeyDown    += control_keyDown;
                ctrl.MouseClick += CtrlOnMouseClick;
                ctrl.Location    = new Point(item.PointX, item.PointY);
                ctrl.Size        = new Size(item.Width, item.Height);
                Controls.Add(ctrl);
                index++;
            }
        }
예제 #3
0
        private async void btnLoadGame_Click(object sender, EventArgs e)
        {
            RemoveItems();
            var gameItem = (System.Collections.Generic.KeyValuePair <int, string>)cmbGames.SelectedItem;

            _xhrRequester = new HttpRequester($"game/{gameItem.Key}/map");
            var result = await _xhrRequester.Get <List <GameMap> >("");

            var name = "";

            foreach (var item in result)
            {
                UserControl ctrl;
                switch (item.ControllerType)
                {
                case Enums.ControllerType.VerticalLine:
                    ctrl = new UCVerticalLine();
                    name = "ucVerticalLine_";
                    break;

                case Enums.ControllerType.HorizontalLine:
                    ctrl = new UCHorizontalLine();
                    name = "ucHorizontalLine_";
                    break;

                case Enums.ControllerType.Charactor:
                    ctrl = new UCCharactor();
                    name = "ucChar_";
                    break;

                case Enums.ControllerType.Target:
                    ctrl = new UCTarget();
                    name = "ucTarget_";
                    break;

                default:
                    continue;
                }
                ctrl.Name        = $"{name}{index}";
                ctrl.MouseEnter += control_MouseEnter;
                ctrl.MouseLeave += control_MouseLeave;
                ctrl.MouseDown  += control_MouseDown;
                ctrl.MouseMove  += control_MouseMove;
                ctrl.MouseUp    += control_MouseUp;
                ctrl.KeyDown    += control_keyDown;
                ctrl.MouseClick += CtrlOnMouseClick;
                ctrl.Location    = new Point(item.PointX, item.PointY);
                ctrl.Size        = new Size(item.Width, item.Hight);
                Controls.Add(ctrl);
                index++;
            }
        }
예제 #4
0
        private void btnVerticalLine_Click(object sender, EventArgs e)
        {
            var ctrl = new UCVerticalLine();

            ctrl.Location    = new Point(50, 50);
            ctrl.Name        = "ucVerticalLine_" + index;
            ctrl.MouseEnter += control_MouseEnter;
            ctrl.MouseLeave += control_MouseLeave;
            ctrl.MouseDown  += control_MouseDown;
            ctrl.MouseMove  += control_MouseMove;
            ctrl.MouseUp    += control_MouseUp;
            ctrl.KeyDown    += control_keyDown;
            ctrl.MouseClick += CtrlOnMouseClick;
            Controls.Add(ctrl);
            index++;
        }