public async Task <ActionResult <UserColorModel> > PostFromHex(ColorFromHexModel colorFromHexModel) { string hex = colorFromHexModel.Hex; hex = hex.TrimStart('#'); if (hex.Length == 6) { hex = "FF" + hex; } System.Drawing.Color c = System.Drawing.Color.FromArgb(Int32.Parse(hex, System.Globalization.NumberStyles.HexNumber)); UserColor newColor = new UserColor { Name = colorFromHexModel.Name, Alpha = c.A, Red = c.R, Green = c.G, Blue = c.B }; _context.UserColors.Add(newColor); await _context.SaveChangesAsync(); return(CreatedAtAction("GetUserColor", new { id = newColor.Id }, newColor)); }
public List <UserInfo> FindAllUsers() { List <UserInfo> allUsers = new List <UserInfo>(); List <Dictionary <string, string> > result = Crud.SelectQuery("SELECT user.*, colors.color as color_name, colors.id AS color_id " + "FROM user LEFT JOIN colors ON user.color = colors.id"); if (result != null) { foreach (var userProperties in result) { UserInfo userInfo = new UserInfo(); //userInfo.Parse(userProperties); userInfo.Name = userProperties["username"]; userInfo.Active = bool.Parse(userProperties["active"]); userInfo.Role = int.Parse(userProperties["role"]); userInfo.Id = int.Parse(userProperties["id"]); UserColor userColor = new UserColor(); userColor.Id = int.Parse(userProperties["color_id"]); userColor.Name = userProperties["color_name"]; userInfo.Color = userColor; allUsers.Add(userInfo); } return(allUsers); } LOG.Info("no results returned with FindAllUsers()"); return(null); }
public CircleBuilder(Graphics fg, System.Drawing.Rectangle rec, UserColor color, Timer timerCustom) { formGraphics = fg; ThisObject = rec; ObjectColor = color; timer = timerCustom; _cbInstance = this; }
public static void Print(string message, UserColor color) { ConsoleColor oldColor = Console.ForegroundColor; Console.ForegroundColor = (ConsoleColor)color; Console.WriteLine(message); Console.ForegroundColor = oldColor; }
public async Task <ActionResult <UserColorModel> > PostUserColor(UserColorModel userColorModel) { UserColor userColor = userColorModel.ToEntity(); _context.UserColors.Add(userColor); await _context.SaveChangesAsync(); return(CreatedAtAction("GetUserColor", new { id = userColor.Id }, userColor)); }
private void OnColorListChanged(UserColor color) { Brush brush = null; if (color.RGB.ToColor(ref brush)) { this.MainText.Text = $"#{color.RGB}".ToUpper(); this.MainColor.Fill = brush; } }
public User(Guid id, string userName, string displayName, MailAddress mailAddress, UserColor color) { this.Id = id; this.userName = userName; this.displayName = displayName; this.mailAddress = mailAddress; this.color = color; this.AddDomainEvent(new UserAddedEvent(this.Id, this.userName, this.displayName, this.mailAddress.Address, this.color)); }
public async void SaveColorToServer(UserColor c) { try { var saveResult = await _colorsRepo.Post(c, "UserColors"); } catch { } }
public static UserColorModel ToModel(this UserColor color) { return(new UserColorModel { Id = color.Id, Name = color.Name, Alpha = color.Alpha, Red = color.Red, Green = color.Green, Blue = color.Blue, }); }
private void SendMessageExecute(object sender) { _chatService.AddMessage(new ChatMessageEntity() { IdChatGroup = SelectedChatGroup.Entity.ChatGroupId, DateSend = DateTime.Now, Message = SendMessageTo, IdUser = base.GameArea.AppUserId, Color = UserColor.ToString() }); SendMessageTo = string.Empty; }
/// <summary> /// Create board(squares and checkers). /// </summary> /// <param name="userColor"></param> public void PrepareBoard(UserColor userColor) { for (int i = 0; i < _boardSize; i++) { for (int j = 0; j < _boardSize; j++) { var position = new Position(i, j); var id = j * _boardSize + i; SquareColor squareColor = (i + j) % 2 == 0 ? SquareColor.White : SquareColor.Black; Square square = new Square(id, position, squareColor); _boardSquares[i, j] = square; _squaresData[square.Id] = square; } } int c = 0, index = 0; while (c < 2) { if (_boardSquares[index / _boardSize, index % _boardSize].Color == SquareColor.Black) { var checkerColor = userColor == UserColor.White ? CheckerColor.Black : CheckerColor.White; Checker checker = new Checker(index, _squaresData[index], checkerColor); _checkersData[index] = checker; _squaresData[index].SetChecker(checker); c++; } index++; } c = 0; index = _boardSize * _boardSize - 1; while (c < 2) { if (_boardSquares[index / _boardSize, index % _boardSize].Color == SquareColor.Black) { var checkerColor = userColor == UserColor.White ? CheckerColor.White : CheckerColor.Black; Checker checker = new Checker(index, _squaresData[index], checkerColor); checker.IsSuperChecker = true; _checkersData[index] = checker; _squaresData[index].SetChecker(checker); c++; } index--; } BoardController.Instance.OnBoardPrepared(_squaresData.Values.ToList(), _checkersData.Values.ToList()); }
/// <remark> /// Should only be used when build from the repository. /// Creating this object with the protected constructor and pppulating it through reflection (like Entity Framework) /// could fix this issue, but that's not a priority for me, right now. /// </remark> public User(Guid id, string userName, string displayName, MailAddress mailAddress, UserColor color, IEnumerable <IDomainEvent> domainEvents) { this.Id = id; this.userName = userName; this.displayName = displayName; this.mailAddress = mailAddress; this.color = color; if (domainEvents == null) { return; } foreach (var @event in domainEvents) { this.AddDomainEvent(@event); } }
async void _onSave() { var c = Brush.Color; var uc = new UserColor { Red = c.R, Green = c.G, Blue = c.B, ColorName = ColorName, SubmitterName = FirstName }; _colorService.SaveColorToServer(uc); await Task.Delay(10000); StartAttract(); }
public List <UserColor> FindUserColors() { List <UserColor> allColors = new List <UserColor>(); List <Dictionary <string, string> > result = Crud.SelectQuery("SELECT * FROM colors"); if (result != null) { foreach (var color in result) { UserColor userColor = new UserColor(); userColor.Id = int.Parse(color["id"]); userColor.Name = color["color"]; allColors.Add(userColor); } return(allColors); } LOG.Info("no results returned with FindUserColors()"); return(null); }
protected void ReadCharacterInfo(NoxBinaryReader rdr) { long finish = rdr.ReadInt64() + rdr.BaseStream.Position; rdr.ReadBytes(6); //UNKNOWN header seems to always = 0c 00 02 00 00 00 SavePath = rdr.ReadString(System.Type.GetType("System.Int16")); rdr.ReadByte(); //terminating null not included in length //the time this file was written FileTime = new DateTime( rdr.ReadInt16(), //year rdr.ReadInt32() & 0xFFFF, //month --skip the next 16bytes //rdr.ReadInt16(),//day of the week (not needed) rdr.ReadInt16(), //day rdr.ReadInt16(), //hour rdr.ReadInt16(), //minute rdr.ReadInt16(), //seconds rdr.ReadInt16() //milliseconds ); //these colors are RGB HairColor = rdr.ReadColor(); SkinColor = rdr.ReadColor(); MustacheColor = rdr.ReadColor(); BeardColor = rdr.ReadColor(); SideburnsColor = rdr.ReadColor(); PantsColor = rdr.ReadUserColor(); ShirtColor = rdr.ReadUserColor(); ShirtTrimColor = rdr.ReadUserColor(); ShoesColor = rdr.ReadUserColor(); ShoesTrimColor = rdr.ReadUserColor(); Name = rdr.ReadUnicodeString(); Class = (CharacterClass)rdr.ReadByte(); rdr.ReadBytes(2); //UNKNOWN: always 00 0A? LastMapPlayed = rdr.ReadString(); rdr.ReadByte(); //null terminator not included in string length System.Diagnostics.Debug.Assert(rdr.BaseStream.Position == finish, "Bad CharacterInfo length"); }
public async Task <IActionResult> PutUserColor(int id, UserColorModel userColorModel) { if (id != userColorModel.Id) { return(BadRequest()); } UserColor color = _context.UserColors.Find(id); if (!UserColorExists(id)) { return(BadRequest()); } color.Name = userColorModel.Name; color.Red = userColorModel.Red; color.Green = userColorModel.Green; color.Blue = userColorModel.Blue; color.Alpha = userColorModel.Alpha; _context.Entry(color).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserColorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private UserColor FromHex(string name, string hex) { hex = hex.TrimStart('#'); if (hex.Length == 6) { hex = "FF" + hex; } System.Drawing.Color c = System.Drawing.Color.FromArgb(Int32.Parse(hex, System.Globalization.NumberStyles.HexNumber)); UserColor newColor = new UserColor { Name = name, Alpha = c.A, Red = c.R, Green = c.G, Blue = c.B }; return(newColor); }
/// <summary> /// Called after click on black/white color buttons. /// </summary> /// <param name="userColor"></param> public void SetColorPlayer(UserColor userColor) { if (_isRandomColor) { return; } BlockRaycastImage.enabled = true; GameControllerComponent.CurrentUserColor = userColor; if (userColor == UserColor.White) { _choosenCheckerColor = CheckerColor.White; } else { _choosenCheckerColor = CheckerColor.Black; } SetMaterialToShadowChecker(userColor); StartNewGame(); }
public void TestUpdateUserInfo() { //prepare UserModel dut = new UserModel(crud); UserInfo userInfo = new UserInfo(); UserColor userColor = new UserColor(); userColor.Id = 3; userColor.Name = "DarkGreen"; userInfo.Id = 7; userInfo.Name = "testNaam"; userInfo.Active = false; userInfo.Role = 5; userInfo.Color = userColor; //test bool result = dut.UpdateUserInfo(userInfo); //validate Assert.IsNotNull(result); Assert.IsTrue(result); }
public void WriteUserColor(UserColor color) { Write((byte) (color.Code - 1)); }
protected void ReadCharacterInfo(NoxBinaryReader rdr) { long finish = rdr.ReadInt64() + rdr.BaseStream.Position; rdr.ReadBytes(6);//UNKNOWN header seems to always = 0c 00 02 00 00 00 SavePath = rdr.ReadString(System.Type.GetType("System.Int16")); rdr.ReadByte();//terminating null not included in length //the time this file was written FileTime = new DateTime( rdr.ReadInt16(),//year rdr.ReadInt32() & 0xFFFF,//month --skip the next 16bytes //rdr.ReadInt16(),//day of the week (not needed) rdr.ReadInt16(),//day rdr.ReadInt16(),//hour rdr.ReadInt16(),//minute rdr.ReadInt16(),//seconds rdr.ReadInt16()//milliseconds ); //these colors are RGB HairColor = rdr.ReadColor(); SkinColor = rdr.ReadColor(); MustacheColor = rdr.ReadColor(); BeardColor = rdr.ReadColor(); SideburnsColor = rdr.ReadColor(); PantsColor = rdr.ReadUserColor(); ShirtColor = rdr.ReadUserColor(); ShirtTrimColor = rdr.ReadUserColor(); ShoesColor = rdr.ReadUserColor(); ShoesTrimColor = rdr.ReadUserColor(); Name = rdr.ReadUnicodeString(); Class = (CharacterClass) rdr.ReadByte(); rdr.ReadBytes(2);//UNKNOWN: always 00 0A? LastMapPlayed = rdr.ReadString(); rdr.ReadByte();//null terminator not included in string length System.Diagnostics.Debug.Assert(rdr.BaseStream.Position == finish, "Bad CharacterInfo length"); }
public UserAddedEvent(Guid id, string userName, string displayName, string mailAddress, UserColor color) { this.Id = id; this.UserName = userName; this.DisplayName = displayName; this.MailAddress = mailAddress; this.Color = color; }
/// <summary> /// Change shadow material depending on color of user checker. /// </summary> private void SetMaterialToShadowChecker(UserColor userColor) { _shadowCheckerMaterial.color = userColor == UserColor.White ? _shadowWhiteColor : _shadowBlackColor; }
public void WriteUserColor(UserColor color) { Write((byte)(color.Code - 1)); }