/// <summary> /// Determines whether this instance can draw the specified character. /// </summary> /// <param name="character">The character.</param> /// <param name="drawingBoard">The drawing board.</param> /// <param name="columnOffset">The column offset.</param> /// <param name="rowOffset">The row offset.</param> /// <param name="blender">The blender.</param> /// <param name="hasNonBlanks">if set to <c>true</c> [has non spaces].</param> /// <returns> /// <c>true</c> if this instance can draw the specified character; otherwise, <c>false</c>. /// </returns> private bool CanDraw(FIGcharacter character, DrawingBoard drawingBoard, int columnOffset, int rowOffset, IDrawingElementBlender blender, out bool hasNonBlanks) { hasNonBlanks = false; foreach (var element in GetCharacterDrawingElements(character)) { var column = element.Column + columnOffset; var row = element.Row + rowOffset; if (column < 0 || row < 0) { return(false); } // this relies on the fact that element.DrawingElement is never null var under = drawingBoard[column, row]; if (blender.TryBlend(under, element.DrawingElement) is null) { return(false); } if (!(under is null) && !under.IsBlank && !element.DrawingElement.IsBlank) { hasNonBlanks = true; } } return(true); }
private void InitializeDrawingBoard() { _shapeFactory = new ShapeFactory(); _drawingBoard = new DrawingBoard(_shapeFactory, _kinectSensor.CoordinateMapper); _drawingBoard.PropertyChanged += HandProperties_Changed; }
public void Should_return_a_handler_upon_user_registration() { var db = new DrawingBoard("board"); var handler = db.Register("user"); Assert.IsNotNull(handler); }
void StopDrawing() { if (board != null) { board.StopDrawing(); board = null; } }
/// <summary> /// Draws the specified <see cref="FIGcharacter" /> to <see cref="DrawingBoard" />. /// </summary> /// <param name="character">The character.</param> /// <param name="drawingBoard">The drawing board.</param> /// <param name="columnOffset">The column offset.</param> /// <param name="rowOffset">The row offset.</param> /// <param name="blender">The blender.</param> private void Draw(FIGcharacter character, DrawingBoard drawingBoard, int columnOffset, int rowOffset, IDrawingElementBlender blender) { foreach (var element in GetCharacterDrawingElements(character)) { var column = element.Column + columnOffset; var row = element.Row + rowOffset; drawingBoard[column, row] = blender.TryBlend(drawingBoard[column, row], element.DrawingElement) ?? element.DrawingElement; } }
public void Should_not_send_user_message_to_self() { var db = new DrawingBoard("board"); var handler = db.Register("user"); var client1 = Substitute.For <IWebSocketClient>(); handler.OnOpen(client1); handler.OnMessage("testing"); client1.DidNotReceiveWithAnyArgs().Send(""); }
public void Should_broadcast_user_connection() { var db = new DrawingBoard("board"); var handler = db.Register("user"); var client1 = Substitute.For <IWebSocketClient>(); handler.OnOpen(client1); var handler2 = db.Register("user2"); handler2.OnOpen(Substitute.For <IWebSocketClient>()); client1.Received().Send("User user2 connected to drawing board board"); }
public override List <State> ChildStates(State parentState) { List <State> childStates = new List <State>(); State child = (State)State.DeepClone(parentState); while (FilterUnvisitedCities(child.path, SearchInfo.AllCities).Count != 0) { child.AddCityToPath(GetClosestCity(FilterUnvisitedCities(child.path, SearchInfo.AllCities), SearchInfo.AllCities[child.path[child.path.Count - 1]])); if (SearchInfo.Visualize) { DrawingBoard.DrawPath(child, SearchInfo.AllCities); Thread.Sleep(500); } } return(ReturnBottomChild(child, childStates)); }
public override List <State> ChildStates(State parentState) { GenerateRandomPopulation(); foreach (State s in population) { s.Cost = CalculateAdaptation(s); } for (int i = 0; i < SearchInfo.NumberOfGenerations; i++) { Program.tspWindow.MessageReported("Generation " + i); population = State.Sort(population, 1); if (nextGeneration.Count != 0) { population = nextGeneration; } nextGeneration = new List <State>(); if ((population[0].Cost - population[population.Count - 1].Cost) / population[0].Cost < similarityMargin) { tooSimilar = true; } else { tooSimilar = false; } for (int j = SearchInfo.Population - 1; j < population.Count - 1; j++) { population.RemoveAt(j); } foreach (State p in population) { if (SearchInfo.Visualize) { DrawingBoard.DrawPath(p, SearchInfo.AllCities); Thread.Sleep(100); } } for (int j = 0; j < SearchInfo.Population; j++) { State parent1 = GetRandomParent(population); State parent2 = GetRandomParent(population); nextGeneration.Add(Multiply(parent1, parent2)); } population.AddRange(nextGeneration); } return(population); }
public void Should_broadcast_user_message() { var db = new DrawingBoard("board"); var handler = db.Register("user"); var client1 = Substitute.For <IWebSocketClient>(); handler.OnOpen(client1); var handler2 = db.Register("user2"); handler2.OnOpen(Substitute.For <IWebSocketClient>()); handler2.OnMessage("testing"); client1.Received().Send("User user2 says: testing"); }
/// <summary> /// Adjusts the height of the drawing board. /// Checks that there are enough lines to render /// </summary> private void AdjustDrawingBoardHeight() { var above = Font.Baseline; while (Baseline < above) { DrawingBoard.InsertEmptyRow(0); Baseline++; } var below = Font.Height - Font.Baseline; while (Baseline + below > DrawingBoard.Height) { DrawingBoard.InsertEmptyRow(DrawingBoard.Height - 1); } }
public void Should_broadcast_binary_data_as_is() { var db = new DrawingBoard("board"); var handler = db.Register("user"); var client1 = Substitute.For <IWebSocketClient>(); handler.OnOpen(client1); var handler2 = db.Register("user2"); handler2.OnOpen(Substitute.For <IWebSocketClient>()); handler2.OnData(new byte[] { 99 }); client1.Received().Send(Arg.Is <byte[]>(bytes => bytes.Length == 1 && bytes[0] == 99)); }
private int AdjustCaret(FIGcharacter character, DrawingBoard drawingBoard, int columnOffset, int rowOffset, IDrawingElementBlender blender) { // this is the poor man's fix (again) // character does not have a visual, so we ignore it if (character.Width == 0) { return(columnOffset); } var previousHasNonBlanks = false; for (; ; columnOffset--) { if (!CanDraw(character, drawingBoard, columnOffset - 1, rowOffset, blender, out var hasNonBlanks) || previousHasNonBlanks) { return(columnOffset); } previousHasNonBlanks = hasNonBlanks; } }
private void startNextTurn() { Debug.Log("Starting new turn..."); Assert.IsNull(_currentWordTransaction, "The current transaction should be null before we start a new one."); _currentWordTransaction = _wordBankManager.Bank.BeginWord(new BasicSelector()); _currentWordTransaction.SetPlayerCount(Player.InGame.Count()); TargetUpdateCurrentWord(DrawingPlayer.connectionToClient, CurrentWord); foreach (var player in Player.All) { player.HasGuessed = false; player.TimerHasReachedZero = false; } DrawingBoard.ClearAndReset(); _serverTimeLeft = _timePerTurn.Value; RpcUpdateTimeLeft(_serverTimeLeft, forceUpdate: true); }
void Update() { if (Physics.Raycast(transform.position, transform.forward, out hitInfo, 10, ~ignoreLayers)) { DrawingBoard hitObject = hitInfo.collider.GetComponent <DrawingBoard>(); if (hitObject != null) { board = hitObject; board.MoveMarker(hitInfo.point); if ((Application.isEditor && Input.GetKey(drawButton) || OVRInput.Get(drawButtonVR, hand)) && !board.isDrawing) { board.StartDrawing(); } } else { StopDrawing(); } } else { StopDrawing(); } if (board != null) { if (Application.isEditor && Input.GetKeyDown(drawButton) || OVRInput.GetDown(drawButtonVR, hand)) { board.StartDrawing(); } if (Application.isEditor && Input.GetKeyUp(drawButton) || OVRInput.GetUp(drawButtonVR, hand)) { StopDrawing(); } } }
public TSPGreedyAlgorithm(SearchParameter searchInfo, DrawingBoard drawingBoard) : base(searchInfo, drawingBoard) { }
// ------------------------------------------------------------------------------------ // Initialize Everything Here // ------------------------------------------------------------------------------------ protected override void Initialize() { // Frame rate is 30 fps by default for Windows Phone. TargetElapsedTime = TimeSpan.FromTicks(333333); playerPosition = new Vector2(playDefaultPosX, playDefaultPosY); backgroundPositions = new Vector2[2]; backgrounds = new Texture2D[4]; // Textures backgroundPositions[0].X = 0; backgroundPositions[1].X = 800; //backgroundPositions[2].X = 1600; drawingboard = new DrawingBoard(); particleSystem = new ParticleSystem(); numberSystem = new NumberSystem(); velY = 0; touchState = TouchPanel.GetState(); fontPos.X = 0; fontPos.Y = 0; rand = new Random(); base.Initialize(); }
private void button1_Click(object sender, EventArgs e) { DrawingBoard drbo = new DrawingBoard(); drbo.ShowDialog(); }
/// <summary> /// Constructor to connect to an existing drawingBoard /// </summary> /// <param name="drawingBoard"></param> public ToolBox(DrawingBoard drawingBoard) { InitializeComponent(); Drawingboard = drawingBoard; }
public void SelectionForCurrentBoard(DrawingBoard b) { currentBoardID = b.boardID; }
/// <summary> /// Returns a simple render (which is enough for most of us) /// </summary> /// <returns> /// A <see cref="System.String" /> that represents this instance. /// </returns> public override string ToString() { return(string.Join(Environment.NewLine, DrawingBoard.Render())); }