private void Fill() { while (true) { var rect = Rectangles.FirstOrDefault(x => !x.Completed); if (rect == null) { return; } var others = Rectangles.Where(x => x.ID != rect.ID).ToList(); var topRight = rect.TopRight(others); if (topRight == null) { continue; } var top = topRight.Item2; var left = topRight.Item1; var colidingRight = others.Where(x => x.Left > left && x.Top >= top && x.Bottom < top); var leftMost = colidingRight.OrderBy(x => x.Left).First(); var right = leftMost.Left; var colidingBottom = others.Where(x => x.Top < top && ((x.Left <right && x.Left> left) || (x.Right <right && x.Right> left) || (right <x.Right && right> x.Left) || (left <x.Right && left> x.Left))); var highest = colidingBottom.OrderByDescending(x => x.Top).First(); var bottom = highest.Top; Rectangles.Add(new Rectangle(left, bottom, right, top)); } }
public void RectangleArea() { Rectangles rec = new Rectangles(12, 2); var value = rec.GetArea(); Assert.AreEqual(24, value); }
/// <summary> /// Removes rectangle object from scene /// </summary> /// <param name="rectangle">Rectangle object</param> public void RemoveRectangle(RectangleObject rectangle) { if (Rectangles.Contains(rectangle)) { Rectangles.Remove(rectangle); } }
public void Recreate() { Center = LayouterSettings.StartPoint; NeedingShiftToCenter = LayouterSettings.NeedingShiftToCenter; Spiral = new ArchimedeanSpiral(LayouterSettings); Rectangles.Clear(); }
public void AddRectangle(FilmRectangle rect) { rect.Color = Color; rect.HatchSpacing = HatchSpacing; rect.HatchAngle = HatchAngle; Rectangles.Add(rect); }
public void CalulateAsync() { Stopwatch.Start(); this.IsCalulating = true; //Calulate // Lets first get a cube to expand Vector2Int cubePosition = GetFirstWorkableCubePosition(); if (cubePosition == -Vector2Int.One) { //whopsies, we got a lil poopie here, no cubes where found! MessageBox.Show("No Workable cubes found! Make sure you have generated them first"); Stop(); return; } ; while (cubePosition != -Vector2Int.One) { cubePosition = GetFirstWorkableCubePosition(); var rect = new RectangleInt(cubePosition, cubePosition); rect = ExpandRectangle(rect); Rectangles.Add(rect); } // okay, we now have a cube, lets start a rectangle and expand it Stop(); }
private void Grid_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e) { string BaseName = System.Text.RegularExpressions.Regex.Replace((sender as System.Windows.Controls.Grid).Name, @"Grid", string.Empty, System.Text.RegularExpressions.RegexOptions.IgnoreCase); System.Windows.Shapes.Rectangle LeavedRectangle = FindName("Rectangle" + BaseName) as System.Windows.Shapes.Rectangle; int Index = Rectangles.IndexOf(LeavedRectangle); if (LeavedRectangle.Style != FindResource("RectangleStyleToday")) { if (previousIndex == Index) { LeavedRectangle.Style = (System.Windows.Style)FindResource("RectangleStyleEventedDay"); previousIndex = -1; return; } } System.Windows.Controls.TextBlock LeavedTextBlock = TextBlocks.ElementAt(Index); if ((LeavedRectangle.Style == FindResource("RectangleStyleNone") && LeavedTextBlock.Style == FindResource("TextBlockStyleForOtherMonths")) || LeavedRectangle.Style == FindResource("RectangleStyleToday") || LeavedRectangle.Style == FindResource("RectangleStyleEventedDay")) { return; } LeavedRectangle.Style = (System.Windows.Style)FindResource("RectangleStyleNone"); }
void SetFrom(ShapeCollectionSave shapeCollectionSave) { Clear(); foreach (var saveObject in shapeCollectionSave.AxisAlignedRectangleSaves) { var runtime = saveObject.ToAxisAlignedRectangle(); var vm = new AxisAlignedRectangleViewModel(runtime); Rectangles.Add(vm); } foreach (var saveObject in shapeCollectionSave.CircleSaves) { var runtime = saveObject.ToCircle(); var vm = new CircleViewModel(runtime); Circles.Add(vm); } foreach (var saveObject in shapeCollectionSave.PolygonSaves) { var runtime = saveObject.ToPolygon(); var vm = new PolygonViewModel(runtime); Polygons.Add(vm); } }
public Character(Texture2D image, Vector2 vector, int spriteCount) { this._posX = 0; this._posY = 0; this._image = image; this._vector = vector; this._spriteSheetWidth = image.Width; this._spriteSheetHeight = image.Height; this._spriteCount = spriteCount; Rectangle leftAnimation = Rectangles.GetLeftAnimationDimensions(image.Width, image.Height, spriteCount); this._movementRightRectangle = Rectangles.GetRighttAnimationDimensions(image.Width, image.Height, spriteCount); this._movementDownRectangle = Rectangles.GetDownAnimationDimensions(image.Width, image.Height, spriteCount); this._movementUpRectangle = Rectangles.GetUpAnimationDimensions(image.Width, image.Height, spriteCount); spriteSheet = new Dictionary <int, Rectangle>(); spriteSheet.Add((int)SpriteAnimations.LEFT, leftAnimation); spriteSheet.Add((int)SpriteAnimations.RIGHT, _movementRightRectangle); spriteSheet.Add((int)SpriteAnimations.DOWN, _movementDownRectangle); spriteSheet.Add((int)SpriteAnimations.UP, _movementUpRectangle); this._spriteCount = 1; }
public void InsertItem_Grouped_BeforeSelection() { // This should be second in our list no matter where we insert it var rect = new Rectangle { Width = 1.5 }; SetSource(Rectangles); View.GroupDescriptions.Add(new ConcretePropertyGroupDescription("Width") { GroupNameFromItemFunc = (item, level, culture) => ((Rectangle)item).Width < 2 ? "A" : "B" }); View.SortDescriptions.Add(new SortDescription("Width", ListSortDirection.Ascending)); var selection = View.Cast <object> ().Last(); View.MoveCurrentTo(selection); Assert.AreEqual(View.CurrentPosition, 4, "#1"); ResetCounters(); Rectangles.Insert(4, rect); Assert.AreSame(selection, View.CurrentItem, "#2"); Assert.AreEqual(5, View.CurrentPosition, "#3"); Assert.AreEqual(0, CurrentChanged, "#4"); Assert.AreEqual(0, CurrentChanging, "#5"); }
public void Draw(Point point1, Point point2) { var rectangle = Check(point1, point2); Graphics.DrawRectangle(Pen, rectangle); Rectangles.Add(rectangle, Pen.Color); }
public void ToolMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { this.rectangle = new Rectangles(e.X, e.Y); this.canvas.AddDrawingObject(this.rectangle); } }
public void HiddenINPCEvents_Add() { SetSource(Rectangles); // These INPC events don't have publicly visible properties so I don't know why/how they're being raised. INotifyPropertyChanged source = (INotifyPropertyChanged)View; VerifyPropertyChanged("#2", source, () => Rectangles.Add(new Rectangle()), "Count"); }
private double GetDirectionCost(Point direction) { return(Rectangles .Where(rectangle => !rectangle.Center.Equals(Center)) .Select(rectangle => Math.Abs((rectangle.Center - Center).AngleTo(direction))) .DefaultIfEmpty(0) .Min()); }
public static void Main() { Vertex va = new Vertex(0, 0); Vertex vb = new Vertex(0, 1.1); Vertex vc = new Vertex(1.1, 1.1); var vd = Rectangles.FindFourthVertex(va, vb, vc); Console.Write(vd); }
public void No_rectangles() { var strings = new[] { " " }; Assert.Equal(0, Rectangles.Count(strings)); }
public void RectangleAreaTest() { Rectangles testRectangle = new Rectangles(); testRectangle.Side1Top = 8; testRectangle.Side2Right = 4; Assert.AreEqual(testRectangle.Area(), 32); }
public void RectanglePerimeterTest() { Rectangles testRectangle = new Rectangles(); testRectangle.Side1Top = 8; testRectangle.Side2Right = 4; Assert.AreEqual(testRectangle.Perimeter(), 24); }
public void Scan() { GetWorkCycle(); GetOutflow(); DateStart = DateTime.ParseExact(RectangleScan(Rectangles.Where(x => x.Key == "DateStart").Single().Value), @"dd/MM/yy", CultureInfo.InvariantCulture); DateEnd = DateTime.ParseExact(RectangleScan(Rectangles.Where(x => x.Key == "DateEnd").Single().Value), @"dd/MM/yy", CultureInfo.InvariantCulture); DateSubmitted = DateTime.ParseExact(RectangleScan(Rectangles.Where(x => x.Key == "DateSubmitted").Single().Value), @"dd/MM/yy", CultureInfo.InvariantCulture); Afm = RectangleScan(Rectangles.Where(x => x.Key == "Afm").Single().Value); FormNumber = RectangleScan(Rectangles.Where(x => x.Key == "FormNumber").Single().Value); }
public void Rectangle_of_height_1_is_counted() { var strings = new[] { "+--+", "+--+" }; Assert.Equal(1, Rectangles.Count(strings)); }
public void Number_1x1_square_is_counted() { var strings = new[] { "++", "++" }; Assert.Equal(1, Rectangles.Count(strings)); }
public void DeleteSelected() { for (int i = Rectangles.Count - 1; i >= 0; i--) { if (Rectangles[i].Selected) { Rectangles.RemoveAt(i); } } }
private void ResetGeometry() { var rsList = Rectangles.ToList(); var xMin = rsList.Min(r => r.Geometry.X); var yMin = rsList.Min(r => r.Geometry.Y); var xMax = rsList.Max(r => r.Geometry.X + r.Geometry.Width); var yMax = rsList.Max(r => r.Geometry.Y + r.Geometry.Height); Geometry = new Rect(new Point(xMin, yMin), new Point(xMax, yMax)); }
private void _client_RectangleAdded(object sender, RemoteRectAddedEventArgs e) { if (!Rectangles.Contains(e.Rect)) //Check if we have not received the same rect that we have just finished... { InvokeUI(() => { Rectangles.Add(e.Rect); }); } }
static void PrintRectangle(Rectangles rectangles) { int c = rectangles.color; switch (c) { case 1: Console.ForegroundColor = ConsoleColor.Red; break; case 2: Console.ForegroundColor = ConsoleColor.Green; break; case 3: Console.ForegroundColor = ConsoleColor.Blue; break; case 4: Console.ForegroundColor = ConsoleColor.Gray; break; case 5: Console.ForegroundColor = ConsoleColor.Yellow; break; case 6: Console.ForegroundColor = ConsoleColor.Magenta; break; default: Console.ForegroundColor = ConsoleColor.White; break; } Console.SetCursorPosition(rectangles.place1, rectangles.place2); rectangles.place2++; int i, j; for (i = 1; i <= rectangles.height; i++, Console.SetCursorPosition(rectangles.place1, rectangles.place2), rectangles.place2++) { for (j = 1; j <= rectangles.width; j++) { if (i == 1 || i == rectangles.height || j == 1 || j == rectangles.width) { Console.Write("*"); } else { Console.SetCursorPosition(rectangles.place1 + j, rectangles.place2 - 1); } } Console.WriteLine(); } }
private void UpdateRepositionDirectionsFor(AxisAlignedRectangle newAar) { // Let's see what is surrounding this rectangle and update it and the surrounding rects appropriately float keyValue = GetKeyValue(newAar.X, newAar.Y); float keyValueBefore = keyValue - GridSize * 3 / 2.0f; float keyValueAfter = keyValue + GridSize * 3 / 2.0f; int before = Rectangles.GetFirstAfter(keyValueBefore, mSortAxis, 0, Rectangles.Count); int after = Rectangles.GetFirstAfter(keyValueAfter, mSortAxis, 0, Rectangles.Count); AxisAlignedRectangle leftOf = GetTileAt(newAar.X - GridSize, newAar.Y, before, after); AxisAlignedRectangle rightOf = GetTileAt(newAar.X + GridSize, newAar.Y, before, after); AxisAlignedRectangle above = GetTileAt(newAar.X, newAar.Y + GridSize, before, after); AxisAlignedRectangle below = GetTileAt(newAar.X, newAar.Y - GridSize, before, after); RepositionDirections directions = RepositionDirections.All; if (leftOf != null) { directions -= RepositionDirections.Left; if ((leftOf.RepositionDirections & RepositionDirections.Right) == RepositionDirections.Right) { leftOf.RepositionDirections -= RepositionDirections.Right; } } if (rightOf != null) { directions -= RepositionDirections.Right; if ((rightOf.RepositionDirections & RepositionDirections.Left) == RepositionDirections.Left) { rightOf.RepositionDirections -= RepositionDirections.Left; } } if (above != null) { directions -= RepositionDirections.Up; if ((above.RepositionDirections & RepositionDirections.Down) == RepositionDirections.Down) { above.RepositionDirections -= RepositionDirections.Down; } } if (below != null) { directions -= RepositionDirections.Down; if ((below.RepositionDirections & RepositionDirections.Up) == RepositionDirections.Up) { below.RepositionDirections -= RepositionDirections.Up; } } newAar.RepositionDirections = directions; }
public void One_rectangle() { var input = new[] { "+-+", "| |", "+-+" }; Assert.That(Rectangles.Count(input), Is.EqualTo(1)); }
public Rectangle PutNextRectangle(Rectangle foundRectangle) { if (!CheckIntersectionWithExistigRectangles(foundRectangle)) { foundRectangle = MoveRectangleToCenter(foundRectangle); Rectangles.AddLast(foundRectangle); UpdateBordersAndSize(foundRectangle); return(foundRectangle); } return(Rectangle.Empty); }
public void One_rectangle() { var strings = new[] { "+-+", "| |", "+-+" }; Assert.Equal(1, Rectangles.Count(strings)); }
public void Rectangle_of_width_1_is_counted() { var strings = new[] { "++", "||", "++" }; Assert.Equal(1, Rectangles.Count(strings)); }