public async Task <IActionResult> Add([FromForm] BackEnum model) { if (!ModelState.IsValid) { return(View()); } if (model.Id > 0) { //修改 var backEnum = _backEnum.GetByKey(model.Id); backEnum.ParentId = model.ParentId; backEnum.EnumName = model.EnumName; backEnum.Remark = model.Remark; backEnum.Sort = model.Sort; _backEnum.Update(backEnum); } else { await _backEnum.InsertAsync(model); } var state = await _unitOfWork.SaveAsync(); if (state) { ViewBag.JS = "<script>dialogClose();</script>"; } else { ModelState.AddModelError("", "保存失败,请与技术支持联系!"); } return(View()); }
/// <summary> /// draw card at given position with styles specified /// About Bitmap ref: https://stackoverflow.com/questions/32207313/difference-between-bitmap-fromfilepath-and-new-bitmappath /// </summary> /// <param name="areaParam"></param> /// <param name="horizotalParam"></param> /// <param name="verticalParam"></param> /// <param name="sideParam"></param> /// <returns></returns> public Card CardDraw(string areaParam, int horizotalParam, int verticalParam, int sideParam) { this._area = areaParam; this._position = new Point(horizotalParam, verticalParam); this._side = (BackEnum)sideParam; this.Location = this._position; this.Size = new Size(CARD_WIDTH, CARD_HEIGHT); if ( _side == BackEnum.Back ) { this.Image = (Image)(new Bitmap(Image.FromFile(@"..\..\images\back.png"), new Size(CARD_WIDTH, CARD_HEIGHT))); } else { this.Image = (Image)(new Bitmap(Image.FromFile(@"..\..\images\" + (int)this._face + (SuitEnum)this._suit + ".png"), new Size(CARD_WIDTH, CARD_HEIGHT))); this.MouseDown += card_MouseDown; } return this; }
/// <summary> /// draw card with side(face or back) specified /// </summary> /// <param name="sideParam"></param> /// <returns></returns> public Card CardDraw(int sideParam) { this._side = (BackEnum)sideParam; if (_side == BackEnum.Back) { this.Image = (Image)(new Bitmap(Image.FromFile(@"..\..\images\back.png"), new Size(CARD_WIDTH, CARD_HEIGHT))); // add evet handler //this.Click += card_Click; } else { //this.Image = Image.FromFile(@"..\..\images\"+(int)this._face+(SuitEnum)this._suit+".png"); this.Image = (Image)(new Bitmap(Image.FromFile(@"..\..\images\" + (int)this._face + (SuitEnum)this._suit + ".png"), new Size(CARD_WIDTH, CARD_HEIGHT))); // add event handler this.MouseDown += card_MouseDown; } return this; }