public override void ArcTo(double x, double y, double size, Corner corner) { float left = (float)(Math.Min(x, _lastPoint.X) - (corner == Corner.TopRight || corner == Corner.BottomRight ? size : 0)); float top = (float)(Math.Min(y, _lastPoint.Y) - (corner == Corner.BottomLeft || corner == Corner.BottomRight ? size : 0)); _graphicsPath.AddArc(left, top, (float)size * 2, (float)size * 2, GetStartAngle(corner), 90); _lastPoint = new RPoint(x, y); }
public LODMeshObject(LODMeshObject parent, QuadTreeNode quadTreeNode, AxisAlignedRectangle bounds, int depth) { Invalid = true; Parent = parent; QuadNode = quadTreeNode; Bounds = bounds; Depth = depth; TotalDepth = QuadNode.Depth + Depth; Children = new LODMeshObject[4]; CornerReference = new bool[5]; Center = FindOrCreateCorner(Bounds.Position, true); Vector2 halfSize = Bounds.Size / 2; Corner = new Corner[8]; Corner[0] = FindOrCreateCorner(Bounds.Position + new Vector2(-halfSize.x, -halfSize.y), Parent == null); // bottom left Corner[1] = FindOrCreateCorner(Bounds.Position + new Vector2(-halfSize.x, 0), true); // left Corner[2] = FindOrCreateCorner(Bounds.Position + new Vector2(-halfSize.x, halfSize.y), Parent == null); // top left Corner[3] = FindOrCreateCorner(Bounds.Position + new Vector2(0, halfSize.y), true); // top Corner[4] = FindOrCreateCorner(Bounds.Position + new Vector2(halfSize.x, halfSize.y), Parent == null); // top right Corner[5] = FindOrCreateCorner(Bounds.Position + new Vector2(halfSize.x, 0), true); // right Corner[6] = FindOrCreateCorner(Bounds.Position + new Vector2(halfSize.x, -halfSize.y), Parent == null); // bottom right Corner[7] = FindOrCreateCorner(Bounds.Position + new Vector2(0, -halfSize.y), true); // bottom }
public static void DrawLogo(this Image image, Image logo, Corner corner) { if (logo.Width > image.Width || logo.Height > image.Height) { throw new ArgumentException("Logo image must be smaller than the original image."); } using (var graphics = Graphics.FromImage(image)) { var point = new Point(); switch (corner) { case Corner.UpperLeft: point.X = 0; point.Y = 0; break; case Corner.UpperRight: point.X = image.Width - logo.Width; point.Y = 0; break; case Corner.BottomLeft: point.X = 0; point.Y = image.Height - logo.Height; break; case Corner.BottomRight: point.X = image.Width - logo.Width; point.Y = image.Height - logo.Height; break; } graphics.DrawImage(logo, point); } }
public static void WorkOutIfPossible(IList<Point> points) { //get all the corners IList<Corner> corners = new List<Corner>(); if (points.Count >= 3) { for (int i = 2; i < points.Count; i++) { Corner currentCorner = new Corner(); currentCorner.start = points[i - 2]; currentCorner.cornerPoint = points[i - 1]; currentCorner.endPoint = points[i]; corners.Add(currentCorner); } Corner returnToStart = new Corner(); returnToStart.start = points[points.Count - 2]; returnToStart.cornerPoint = points[points.Count - 1];// last point returnToStart.endPoint = points[0]; corners.Add(returnToStart); Corner continuePastStart = new Corner(); continuePastStart.start = points[points.Count - 1]; continuePastStart.cornerPoint = points[0]; continuePastStart.endPoint = points[1]; corners.Add(continuePastStart); } bool allPositives = true; bool allNegatives = true; foreach (Corner c in corners) { //p2-p1 int v2X = c.endPoint.X - c.cornerPoint.X; int v2Y = c.endPoint.Y - c.cornerPoint.Y; //p1 -p0 int v1x = c.cornerPoint.X - c.start.X; int v1y = c.cornerPoint.Y - c.start.Y; //calculate signed area int cross = (v1x * v2Y) - (v2X * v1y); if (cross == 0) continue; //check its all consistent at least one direction allPositives &= cross > 0; allNegatives &= cross < 0; if (!allPositives && !allNegatives) { Console.WriteLine("not possible"); return; } } Console.WriteLine("possible"); }
//http://stackoverflow.com/questions/3225803/calculate-endpoint-given-distance-bearing-starting-point private static Corner FindPointAtDistanceFrom(Corner startPoint, double initialBearingRadians, double distanceKilometres) { const double radiusEarthKilometres = 6371.01; var distRatio = distanceKilometres / radiusEarthKilometres; var distRatioSine = Math.Sin(distRatio); var distRatioCosine = Math.Cos(distRatio); var startLatRad = DegreesToRadians(startPoint.Latitude); var startLonRad = DegreesToRadians(startPoint.Longitude); var startLatCos = Math.Cos(startLatRad); var startLatSin = Math.Sin(startLatRad); var endLatRads = Math.Asin((startLatSin * distRatioCosine) + (startLatCos * distRatioSine * Math.Cos(initialBearingRadians))); var endLonRads = startLonRad + Math.Atan2( Math.Sin(initialBearingRadians) * distRatioSine * startLatCos, distRatioCosine - startLatSin * Math.Sin(endLatRads)); return new Corner { Latitude = RadiansToDegrees(endLatRads), Longitude = RadiansToDegrees(endLonRads) }; }
public BoundingBox(double latitude, double longitude, double heading, double speed, int modeOfTransportation) { //convert from mph -> kph -> mps this.heading = heading; double metersPerSecond = speed * 1.60934 * .277778; currentPosition = new Corner(); currentPosition.Latitude = latitude; currentPosition.Longitude = longitude; //person if (modeOfTransportation == 0) { //distance = (speed x time) / (convert to kilometers) + base kilomoters distanceForwardBackward = (metersPerSecond * 5) / 1000 + .001; distanceLeftRight = .001; } //car else if (modeOfTransportation == 1) { distanceForwardBackward = (metersPerSecond * 5) / 1000 + .005; distanceLeftRight = .005; } //airplane else { distanceForwardBackward = (metersPerSecond * 5) / 1000 + .04; distanceLeftRight = .04; } CalculateBoundingBoxCorners(); }
public CornerButtons(Corner corner) { Corner = corner; RenderSize = MinSize; IsHoverable = true; IsTogglable = false; }
public static void DrawString(this Image image, string text, Corner corner, Font font, Color color) { using (var graphics = Graphics.FromImage(image)) { var stringFormat = new StringFormat(); stringFormat.SetMeasurableCharacterRanges(new[] { new CharacterRange(0, text.Length) }); Region[] region = graphics.MeasureCharacterRanges(text, font, new Rectangle(0, 0, image.Width, image.Height), stringFormat); RectangleF rect = region[0].GetBounds(graphics); rect.Width += (int)Math.Ceiling(rect.Width * 0.05d); var point = new PointF(); switch (corner) { case Corner.UpperLeft: point.X = 0; point.Y = 0; break; case Corner.UpperRight: point.X = image.Width - rect.Width; point.Y = 0; break; case Corner.BottomLeft: point.X = 0; point.Y = image.Height - rect.Height; break; case Corner.BottomRight: point.X = image.Width - rect.Width; point.Y = image.Height - rect.Height; break; } graphics.DrawString(text, font, new SolidBrush(color), point); } }
public Pipeline CutCorners(float cornerRadius, Color background, Corner roundCorner) { CutCornersFilter filter = new CutCornersFilter() { Corner = roundCorner }; filter.CornerRadius = cornerRadius; filter.BackGroundColor = background; _image = filter.ExecuteFilter(_image); return this; }
public Corners(float x, float y, float width, float height, double radius, Corner corner) { this.x = x; this.y = y; this.width = width; this.height = height; this.radius = radius; FillList(corner); }
/** * This method returns a copy of the blueprint. * This is a Deep Copy, meaning that all the Rooms, Corners in those rooms and Walls connected to those corners will be copied. * The purpose of this is to make a new copy to work in when editing a blueprint, while preserving the original. */ public Blueprint Clone() { Blueprint newBp = new Blueprint(this.Name); List<Wall> newWalls = new List<Wall>(); List<Corner> newCorners = new List<Corner>(); foreach(Room room in this.Rooms) { Room newRoom = new Room(room.Name, room.GetID(), room.GetFloorID(), room.FunctionID); newBp.Rooms.Add(newRoom); foreach(Corner corner in room.GetCorners()) { Corner newCorner = newCorners.Find( (c) => (c.GetID() == corner.GetID()) ); if(newCorner != null) { newRoom.AddCorner(newCorner); continue; } newCorner = new Corner(corner.GetID(), corner.GetPoint()); newRoom.AddCorner(newCorner); newCorners.Add(newCorner); foreach(Wall wall in corner.GetWalls()) { Wall newWall = newWalls.Find( (w) => (w.GetID() == wall.GetID()) ); if(newWall != null) { if(newWall.Left.GetID() == corner.GetID()) { newWall.Left = newCorner; } else if(newWall.Right.GetID() == corner.GetID()) { newWall.Right = newCorner; } if(newWall.GetType() == typeof(Door)) { ((Door)newWall).Hinge = (((Door)newWall).Hinge.Equals(newWall.Left) ? newWall.Left : newWall.Right); } newCorner.AddWall(newWall); continue; } Corner left = (wall.Left.Equals(newCorner) ? newCorner : wall.Left); Corner right = (wall.Right.Equals(newCorner) ? newCorner : wall.Right); if(wall.GetType() == typeof(Door)) { newWall = new Door(wall.GetID(), left, right, (((Door)wall).Hinge.GetID() == left.GetID() ? left : right), ((Door)wall).Direction); } else { newWall = new Wall(wall.GetID(), left, right); } newWalls.Add(newWall); newCorner.AddWall(newWall); } } newRoom.IsChanged = room.IsChanged; } return newBp; }
public HUD(PC player, Corner corner) { //TODO: again, a textureloader. //load up all the things. BackPanel = Utils.TextureLoader("hud/backPanel.png"); ItemFrame = Utils.TextureLoader("hud/itemFrame.png"); ItemFrameBig = Utils.TextureLoader("hud/itemFrameBig.png"); StatBar = Utils.TextureLoader("hud/statBar.png"); Player = player; Ccorner = corner; }
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ private CubieCube(Corner[] cp, sbyte[] co, Edge[] ep, sbyte[] eo) { for (int i = 0; i < 8; i++) { this.cp[i] = cp[i]; this.co[i] = co[i]; } for (int i = 0; i < 12; i++) { this.ep[i] = ep[i]; this.eo[i] = eo[i]; } }
public static Point GetRelativePosition(FrameworkElement e, FrameworkElement relativeTo, Corner p) { GeneralTransform gt = e.TransformToVisual(relativeTo); Point po = new Point(); if (p == Corner.LeftTop) po = gt.Transform(new Point(0, 0)); if (p == Corner.LeftBottom) po = gt.Transform(new Point(0, e.ActualHeight)); if (p == Corner.RightTop) po = gt.Transform(new Point(e.ActualWidth, 0)); if (p == Corner.RightBottom) po = gt.Transform(new Point(e.ActualWidth, e.ActualHeight)); return po; }
public void FloatConstructor(float x, float y) { //Arrange //Act Corner corner = new Corner(1, x, y); //Assert Assert.IsNotNull(corner); Assert.IsInstanceOf(typeof(Corner), corner); Assert.AreEqual(1, corner.GetID()); Assert.AreEqual(x, corner.GetPoint().X); Assert.AreEqual(y, corner.GetPoint().Y); }
public static double[] GetCorner(this double[] extent, Corner corner) { double[] coordinate=null; if (corner == Corner.BottomLeft) { coordinate = GetBottomLeft(extent); } else if (corner == Corner.BottomRight) { coordinate = GetBottomRight(extent); } else if (corner == Corner.TopLeft) { coordinate = GetTopLeft(extent); } else if (corner == Corner.TopRight) { coordinate = GetTopRight(extent); } return coordinate; }
public void NullAddWall() { //Arrange Corner left = new Corner(new PointF(0, 0)); Corner right = new Corner(new PointF(10, 0)); Wall wall = null; //Act left.AddWall(wall); right.AddWall(wall); //Assert IList lWalls = left.GetWalls(); Assert.AreEqual(0, lWalls.Count); }
public void Constructor() { //Arrange Corner left = new Corner(new PointF(0, 0)); Corner right = new Corner(new PointF(10, 0)); //Act Door door = new Door(left, right); //Assert Assert.IsNotNull(door); Assert.IsInstanceOf(typeof(Door), door); Assert.AreEqual(left, door.Left); Assert.AreEqual(right, door.Right); }
public void Constructor() { //Arrange //Act Corner left = new Corner(1, new PointF(0, 0)); Corner right = new Corner(2, new PointF(10, 0)); Wall wall = new Wall(1, left, right); //Assert Assert.IsNotNull(wall); Assert.IsInstanceOf(typeof(Wall), wall); Assert.AreEqual(1, wall.GetID()); Assert.AreEqual(left, wall.Left); Assert.AreEqual(right, wall.Right); }
public void DoorAddWall() { //Arrange Corner left = new Corner(new PointF(0, 0)); Corner right = new Corner(new PointF(10, 0)); Door door = new Door(left, right); //Act left.AddWall(door); right.AddWall(door); //Assert IList lWalls = left.GetWalls(); Assert.AreEqual(1, lWalls.Count); Assert.IsInstanceOf<Door>(lWalls[0]); Assert.AreEqual(door, lWalls[0]); }
public void MixedAddWalls() { //Arrange Corner corn1 = new Corner(new PointF(0, 0)); Corner corn2 = new Corner(new PointF(10, 0)); Corner corn3 = new Corner(new PointF(10, 10)); Wall wall = new Wall(corn1, corn2); Door door = new Door(corn2, corn3); //Act corn2.AddWalls(wall, door); //Assert IList lWalls = corn2.GetWalls(); Assert.AreEqual(2, lWalls.Count); Assert.AreEqual(wall, lWalls[0]); Assert.AreEqual(door, lWalls[1]); }
// 按下滑鼠 public override void PressMouse(Point point) { _mousePressed = true; _pressPoint = point; if (_shapeModel.SelectedShape != null) { _pressedCorner = _shapeModel.SelectedShape.ContainCorner(point); if (_pressedCorner != Corner.None) { _resizing = true; } } if (!_resizing) { _shapeModel.SelectedShape = _shapeModel.Contains(_mousePressed, point); } }
private static GraphicsPath CreateRoundRectanglePath(int x, int y, int w, int h, int width, int height, Corner rrPosition) { int aw = width << 1; int ah = height << 1; GraphicsPath path = new GraphicsPath(); path.StartFigure(); switch (rrPosition) { case Corner.TopLeft: { x -= 1; y -= 1; path.AddLine(x, y, x, y + height); path.AddArc(x, y, aw, ah, 180, 90); break; } case Corner.TopRight: { y -= 1; path.AddLine(x + w, y, x + w - width, y); path.AddArc(w - aw, y, aw, ah, 270, 90); break; } case Corner.BottomLeft: { x -= 1; path.AddLine(x, y + h, x + width, y + h); path.AddArc(x, y + h - aw, aw, ah, 90, 90); break; } case Corner.BottomRight: { path.AddLine(x + w, y + h, x + w, y + h - height); path.AddArc(x + w - aw, y + h - aw, aw, ah, 0, 90); break; } } path.CloseFigure(); return path; }
/// <summary> /// Get arc start angle for the given corner. /// </summary> private static int GetStartAngle(Corner corner) { int startAngle; switch (corner) { case Corner.TopLeft: startAngle = 180; break; case Corner.TopRight: startAngle = 270; break; case Corner.BottomLeft: startAngle = 90; break; case Corner.BottomRight: startAngle = 0; break; default: throw new ArgumentOutOfRangeException("corner"); } return startAngle; }
// Update is called once per frame void Update() { if (window == IntPtr.Zero) { if (GetWindowHandle() != IntPtr.Zero) { window = GetWindowHandle(); } } POINT cursor_pos; GetCursorPos(out cursor_pos); Vector2 mouse_delta = new Vector2(cursor_pos.X, cursor_pos.Y) - last_mouse_pos; // Set corner press state if (Input.GetMouseButton(0) && mouse_pressed_in_corner == Corner.NONE) { // Left bottom if ((Input.mousePosition.x <= scale_corner_size) && (Input.mousePosition.y <= scale_corner_size)) { print("Mouse pressed in bottom left corner"); mouse_pressed_in_corner = Corner.BOTTOM_LEFT; } // Right bottom if ((Input.mousePosition.x >= Screen.width - scale_corner_size) && (Input.mousePosition.y <= scale_corner_size)) { print("Mouse pressed in bottom right corner"); mouse_pressed_in_corner = Corner.BOTTOM_RIGHT; } // Right top if ((Input.mousePosition.x >= Screen.width - scale_corner_size) && (Input.mousePosition.y >= Screen.height - scale_corner_size)) { print("Mouse pressed in top right corner"); mouse_pressed_in_corner = Corner.TOP_RIGHT; } // Left top if ((Input.mousePosition.x <= scale_corner_size) && (Input.mousePosition.y >= Screen.height - scale_corner_size)) { print("Mouse pressed in top left corner"); mouse_pressed_in_corner = Corner.TOP_LEFT; } } // //Make full screen on double-click if (Input.GetMouseButtonDown(0)) { mouse_pressed_at[0] = mouse_pressed_at[1]; mouse_pressed_at[1] = Time.time; } if (Input.GetMouseButtonUp(0)) { if (Time.time - mouse_pressed_at[0] < fullscreen_double_tap_time) { print("INFO: Making full screen.."); Screen.fullScreen = !Screen.fullScreen; } } // // Clear mouse pressed in corner if mouse has been released if (!Input.GetMouseButton(0)) { mouse_pressed_in_corner = Corner.NONE; } // // Move window Rect screen_rect = new Rect(0, 0, Screen.width, Screen.height); RECT WinR; GetWindowRect(GetActiveWindow(), out WinR); if (WinR != last_window_rect) { print("Window moved."); MsgWindowSpecUpdate window_update = new MsgWindowSpecUpdate(); window_update.height = WinR.Bottom - WinR.Top; window_update.width = WinR.Right - WinR.Left; window_update.x = WinR.Left; window_update.y = WinR.Top; print("Window height: " + window_update.height); } last_window_rect = WinR; // // Resize window if mouse has been pressed down in a corner. if (mouse_pressed_in_corner != Corner.NONE) { print("Scaling window, last window params: " + WinR.ToString()); if (mouse_pressed_in_corner == Corner.TOP_LEFT) { SetPosition(WinR.Left + (int)mouse_delta.x, WinR.Top + (int)mouse_delta.y, (WinR.Right - WinR.Left) - (int)mouse_delta.x, (WinR.Bottom - WinR.Top) - (int)mouse_delta.y); } else if (mouse_pressed_in_corner == Corner.BOTTOM_LEFT) { SetPosition(WinR.Left + (int)mouse_delta.x, WinR.Top, (WinR.Right - WinR.Left) - (int)mouse_delta.x, (WinR.Bottom - WinR.Top) + (int)mouse_delta.y / 2); } else if (mouse_pressed_in_corner == Corner.BOTTOM_RIGHT) { SetPosition(WinR.Left, WinR.Top, (WinR.Right - WinR.Left) + (int)mouse_delta.x, (WinR.Bottom - WinR.Top) + (int)mouse_delta.y); } else { SetPosition(WinR.Left, WinR.Top + (int)mouse_delta.y, (WinR.Right - WinR.Left) + (int)mouse_delta.x, (WinR.Bottom - WinR.Top) - (int)mouse_delta.y); } } else if (Input.GetMouseButton(0) && screen_rect.Contains(Input.mousePosition)) { GetWindowRect(GetActiveWindow(), out WinR); print("Moving window, last window params: " + WinR.ToString()); SetPosition(WinR.Left + (int)mouse_delta.x, WinR.Top + (int)mouse_delta.y); } //Input.mousePosition; last_mouse_pos = new Vector2(cursor_pos.X, cursor_pos.Y); }
private static (char, char, char, char) AdjacentCornerPieceNames(List <PiecePlacement> solution, int x, int y, Corner corner) { var thisPieceName = FindPieceNameAt(solution, x, y); var nPieceName = FindPieceNameAt(solution, x, y - 1); var sPieceName = FindPieceNameAt(solution, x, y + 1); var ePieceName = FindPieceNameAt(solution, x + 1, y); var wPieceName = FindPieceNameAt(solution, x - 1, y); var nwPieceName = FindPieceNameAt(solution, x - 1, y - 1); var nePieceName = FindPieceNameAt(solution, x + 1, y - 1); var swPieceName = FindPieceNameAt(solution, x - 1, y + 1); var sePieceName = FindPieceNameAt(solution, x + 1, y + 1); switch (corner) { case Corner.Nw: return(nwPieceName, nPieceName, wPieceName, thisPieceName); case Corner.Ne: return(nPieceName, nePieceName, thisPieceName, ePieceName); case Corner.Sw: return(wPieceName, thisPieceName, swPieceName, sPieceName); case Corner.Se: return(thisPieceName, ePieceName, sPieceName, sePieceName); default: throw new ArgumentOutOfRangeException("corner"); } }
private void 角编码数ToolStripMenuItem_Click(object sender, EventArgs e) => MessageBox.Show(Corner.Stat(x => x.CodeLength));
public Dock(Corner eCorner, short nLeft, short nTop) : this(eCorner, new Offset(nLeft, nTop)) { }
/// <summary> /// Gets the rounded path. /// </summary> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="radius">The radius.</param> /// <param name="corner">The corner.</param> /// <returns></returns> private static GraphicsPath GetRoundedPath(float x, float y, float width, float height, float radius, Corner corner) { GraphicsPath path = new GraphicsPath(); if (radius > 0) { Corners r = new Corners(x, y, width, height, radius, corner); r.Execute(path); } else { path.AddRectangle(new RectangleF(x, y, width, height)); } path.CloseFigure(); return(path); }
/// <summary> /// Fills the rounded rectangle. /// </summary> /// <param name="gp">The gp.</param> /// <param name="brush">The brush.</param> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="radius">The radius.</param> /// <param name="border">The border.</param> /// <param name="borderColor">Color of the border.</param> /// <param name="corner">The corner.</param> public static void FillRoundedRectangle(this Graphics gp, System.Drawing.Brush brush, float x, float y, float width, float height, float radius, float border, Color borderColor, Corner corner = Corner.All) { PointF basePoint = new PointF(x, y); //PointF[] roundedRectangle = new PointF[5]; //roundedRectangle[0].X = basePoint.X; //roundedRectangle[0].Y = basePoint.Y; //roundedRectangle[1].X = basePoint.X + width; //roundedRectangle[1].Y = basePoint.Y; //roundedRectangle[2].X = basePoint.X + width; //roundedRectangle[2].Y = basePoint.Y + height; //roundedRectangle[3].X = basePoint.X; //roundedRectangle[3].Y = basePoint.Y + height; //roundedRectangle[4].X = basePoint.X; //roundedRectangle[4].Y = basePoint.Y; var border1 = 0f; var border2 = border; if (border2 > 1) { border1 = border2 / 2.0f - 1; border2 = border2 - 1; } var path = GetRoundedPath(x + border1, y + border1, width - border2, height - border2, radius, corner); gp.FillPath(brush, path); if (border > 0) { Pen pen = new Pen(borderColor, border); gp.DrawPath(pen, path); pen.Dispose(); } brush.Dispose(); //Pen pen = new Pen(System.Drawing.Color.Black,2); //gp.DrawPath(pen, path); }
public async Task <ActionResult> New(CornerViewModel cornerViewModel) { #region validate input if (!ModelState.IsValid) { TempData["error"] = ModelState.ToErrors(); return(RedirectToRoute("", new { Controller = "Home", Action = "Index" })); } #endregion if (Request.Form["submitType"] == "preview") { Log.Info("Showing preview for {0}", cornerViewModel.BlmPointId); return(await Preview(cornerViewModel)); } var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["PLSS"].ConnectionString); try { await connection.OpenAsync(); var user = CommandExecutor.ExecuteCommand(new GetUserCommand(connection, User.Identity.Name)); if (user == null) { Log.Info("Could not find user {0} redirecting to home.", User.Identity.Name); TempData["error"] = "You must log in to submit a corner"; return(RedirectToRoute("", new { Controller = "Home", Action = "Index" })); } Log.Info("Submitting tiesheet for {0}", user.Name); cornerViewModel.User = user; var corner = new Corner(cornerViewModel); var grid = new Grid(cornerViewModel.Grid); var coordinate = new Coordinate(cornerViewModel.Coordinate); var formInfo = new FormInfo(user.Name, corner.BlmPointId); var photos = new Photo(cornerViewModel); corner.CoordinateId = coordinate.CoordinateId; corner.GridId = grid.GridId; corner.FormInfoId = formInfo.FormInfoId; corner.PhotoId = photos.PhotoId; var gInserts = connection.Execute(Grid.InsertString, grid); Debug.Assert(gInserts == 1, "inserted into grid successfully"); var cInserts = connection.Execute(Coordinate.InsertString, coordinate); Debug.Assert(cInserts == 1, "inserted into coords successfully"); var fInserts = connection.Execute(FormInfo.InsertString, formInfo); Debug.Assert(fInserts == 1, "inserted into form successfully"); var pInserts = connection.Execute(Photo.InsertString, photos); Debug.Assert(pInserts == 1, "inserted into photo successfully"); var cornInserts = connection.Execute(Corner.InsertString, corner); Debug.Assert(cornInserts == 1, "inserted into corners successfully"); var model = new TieSheetPdfModel(cornerViewModel, corner, photos); var pdfService = new PlssPdfService("Assets\\pdf"); var pdf = pdfService.HydratePdfForm("MonumentStatusTemplate.pdf", model); #if DEBUG pdf.FlattenFormFields(); #endif Log.Info("finished created database models"); var actualPath = Path.Combine(Config.Global.Get <string>("SharePath"), formInfo.Path); Log.Info($"Writing PDF to: {actualPath}"); var success = FileSaver.SaveFile(actualPath, pdf.GetPDFAsByteArray()); if (!success) { Log.Fatal($"problem saving pdf for {cornerViewModel}"); //do nothing, email will get sent about issue and we'll rebuild pdf form later. Log.Info("Sending failed notification email to {0}", string.Join(", ", App.AdminEmails)); CommandExecutor.ExecuteCommand(new UserSubmitionFailedEmailCommand( new UserSubmitionFailedEmailCommand.MailTemplate(App.AdminEmails, new[] { user. UserName }, user.Name, model.BlmPointId, model. CollectionDate))); } else { CommandExecutor.ExecuteCommand(new UserSubmittedEmailCommand( new UserSubmittedEmailCommand.MailTemplate(App.AdminEmails, new[] { user.UserName }, user.Name, model.BlmPointId, model.CollectionDate, actualPath))); } Log.Info("updating forminfoes table path: {0}", actualPath, success); var cUpdate = connection.Execute( "update FormInfoes set " + "path = @actualpath, " + "uploadedSuccessfully = @success " + "where forminfoid = @FormInfoId", new { actualPath, formInfo.FormInfoId, success }); Debug.Assert(cUpdate == 1, "updated form infos correctly"); } catch (Exception ex) { Log.LogException(LogLevel.Fatal, $"problem saving new corner for {cornerViewModel}", ex); TempData["error"] = ex.Message; return(RedirectToRoute("", new { Controller = "Home", Action = "Index" })); } finally { connection.Close(); connection.Dispose(); } return(RedirectToRoute("", new { Controller = "Home", Action = "Index" })); }
public async Task <ActionResult> Preview(CornerViewModel cornerViewModel) { #region validate input if (!ModelState.IsValid) { TempData["error"] = "There was a problem with your input. Please try again."; return(RedirectToAction("Index")); } #endregion var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["PLSS"].ConnectionString); PDFDocument pdf = null; try { await connection.OpenAsync(); var user = CommandExecutor.ExecuteCommand(new GetUserCommand(connection, User.Identity.Name)); if (user == null) { TempData["error"] = "You must log in to submit a corner"; return(RedirectToRoute("", new { Controller = "Home", Action = "Index" })); } cornerViewModel.User = user; var corner = new Corner(cornerViewModel); var photos = new Photo(cornerViewModel); var model = new TieSheetPdfModel(cornerViewModel, corner, photos); var pdfService = new PlssPdfService("Assets\\pdf"); pdf = pdfService.HydratePdfForm("MonumentStatusTemplate.pdf", model); #if DEBUG pdf.FlattenFormFields(); #endif return(File(pdf.GetPDFAsByteArray(), MediaTypeNames.Application.Pdf, $"{model.BlmPointId}-preview.pdf")); } catch (Exception ex) { Log.LogException(LogLevel.Fatal, $"problem previewing pdf for {cornerViewModel}", ex); TempData["error"] = $"There was a problem generating your preview. {ex.Message}"; return(RedirectToRoute("", new { Controller = "Home", Action = "Index" })); } finally { pdf?.Dispose(); connection.Close(); connection.Dispose(); } }
private void 角小循环数ToolStripMenuItem_Click(object sender, EventArgs e) => MessageBox.Show(Corner.Stat(x => x.OtherCycleAmount));
private void 角大循环长度ToolStripMenuItem_Click(object sender, EventArgs e) => MessageBox.Show(Corner.Stat(x => x.MainCycle.Item1));
private void 角翻色数ToolStripMenuItem_Click(object sender, EventArgs e) => MessageBox.Show(Corner.Stat(x => x.TwistAmount));
/// <summary> /// Fills the rounded rectangle. /// </summary> /// <param name="gp">The gp.</param> /// <param name="brush">The brush.</param> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="radius">The radius.</param> /// <param name="corner">The corner.</param> public static void FillRoundedRectangle(this Graphics gp, System.Drawing.Brush brush, float x, float y, float width, float height, float radius, Corner corner = Corner.All) { gp.FillRoundedRectangle(brush, x, y, width, height, radius, 0, Color.Transparent, corner); //RectangleF rectangle = new RectangleF(x, y, width, height); //GraphicsPath path = GetRoundedRect(rectangle, radius, corner); //gp.FillPath(brush, path); //Pen pen = new Pen(System.Drawing.Color.Black,2); //gp.DrawPath(pen, path); }
public Dock(Corner eCorner, Offset cOffset) { this.eCorner = eCorner; this.cOffset = cOffset; }
private static char LookupCorner(List <PiecePlacement> solution, int x, int y, Corner corner) { var(nw, ne, sw, se) = AdjacentCornerPieceNames(solution, x, y, corner); string WallType(char pieceName1, char pieceName2) => pieceName1 == '?' && pieceName2 == '?' ? "-" : pieceName1 == pieceName2 ? "n" : "b"; var l = WallType(nw, sw); var r = WallType(ne, se); var u = WallType(nw, ne); var d = WallType(sw, se); var key = string.Concat(l, r, u, d); return(CORNERS_TABLE[key]); }
public override void ArcTo(double x, double y, double size, Corner corner) { _geometryContext.ArcTo(new Point(x, y), new Size(size, size), 0, false, SweepDirection.Clockwise); }
/// <summary> /// Gets the cut rect. /// </summary> /// <param name="baseRect">The base rect.</param> /// <param name="radius">The radius.</param> /// <param name="corner">The corner.</param> /// <returns></returns> private static GraphicsPath GetCutRect(RectangleF baseRect, float radius, Corner corner) { // if corner radius is less than or equal to zero, // return the original rectangle if (radius <= 0.0F) { GraphicsPath mPath = new GraphicsPath(); mPath.AddRectangle(baseRect); mPath.CloseFigure(); return(mPath); } // if the corner radius is greater than or equal to // half the width, or height (whichever is shorter) // then return a capsule instead of a lozenge //if (radius >= (System.Math.Min(baseRect.Width, baseRect.Height)) / 2.0) // return GetCapsule(baseRect); // create the arc for the rectangle sides and declare // a graphics path object for the drawing //float diameter = radius * 2.0F; //SizeF sizeF = new SizeF(diameter, diameter); //RectangleF arc = new RectangleF(baseRect.Location, sizeF); GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); if ((corner & Corner.TopLeft) == Corner.TopLeft) { path.AddLine(new PointF(radius, baseRect.Y), new PointF(0, radius)); } else { path.AddLine(new PointF(baseRect.X, baseRect.Y), new PointF(radius, baseRect.Y)); path.AddLine(new PointF(baseRect.X, baseRect.Y), new PointF(baseRect.X, radius)); } //画多边形边 path.AddLine( new PointF(radius, baseRect.Y), new PointF(baseRect.Right - radius, baseRect.Y) ); // top right corner if ((corner & Corner.TopRight) == Corner.TopRight) { path.AddLine( new PointF(baseRect.Right - radius, baseRect.Y), new PointF(baseRect.Right, radius)); } else { path.AddLine(new PointF(baseRect.Right - radius, baseRect.Y), new PointF(baseRect.Right, baseRect.Y)); path.AddLine(new PointF(baseRect.Right, baseRect.Y), new PointF(baseRect.Right, radius)); } // bottom right arc if ((corner & Corner.BottomRight) == Corner.BottomRight) { path.AddLine( new PointF(baseRect.Right, baseRect.Bottom - radius), new PointF(baseRect.Right - radius, baseRect.Bottom)); } else { path.AddLine(new PointF(baseRect.Right, baseRect.Bottom - radius), new PointF(baseRect.Right, baseRect.Bottom)); path.AddLine(new PointF(baseRect.Right, baseRect.Bottom), new PointF(baseRect.Right - radius, baseRect.Bottom)); } path.AddLine( new PointF(baseRect.Right - radius, baseRect.Bottom), new PointF(radius, baseRect.Bottom)); if ((corner & Corner.BottomLeft) == Corner.BottomLeft) { path.AddLine( new PointF(radius, baseRect.Bottom), new PointF(0, baseRect.Bottom - radius)); } else { path.AddLine(new PointF(baseRect.Right - radius, baseRect.Bottom), new PointF(baseRect.X, baseRect.Bottom)); path.AddLine(new PointF(baseRect.X, baseRect.Bottom), new PointF(baseRect.X, baseRect.Bottom - radius)); } // bottom left arc path.AddLine( new PointF(baseRect.X, baseRect.Bottom - radius), new PointF(baseRect.X, radius)); if ((corner & Corner.TopLeft) != Corner.TopLeft) { path.AddLine(new PointF(baseRect.X, baseRect.Y), new PointF(baseRect.X, radius)); } path.CloseFigure(); return(path); }
public PointOnRectangleLocator(Corner corner, Point offset) : this(new AnimationBoundsLocator(), corner, offset) { }
public void UpdateHover(Model renderModel, uint modelPolygonId) { HoverPolygon = null; if(renderModel != null) { if(HoverModel != renderModel) { HoverModel = renderModel; HoverGroup.Clear(); HoverGroup.Add(renderModel); } //if(Configuration.hoverDebug) { PolygonIds.Clear(); PolygonIds.Add(modelPolygonId); // Temp debug code IMeshSource meshSource = HoverModel.Batch.MeshSource; if (meshSource is GeometryMesh original) { if (original.Geometry.PolygonAttributes.Contains<Vector3>("polygon_normals")) { if (modelPolygonId < original.Geometry.Polygons.Count) { HoverPolygon = original.Geometry.Polygons[(int)modelPolygonId]; #if true //selectionMesh.Geometry = Geometry.Clone(original.Geometry, SelectedPolygonIds).Destination; //selectionMesh.BuildMeshFromGeometry(); Frame hoverFrame = HoverModel.Frame; Polygon polygon = HoverPolygon; var polygonNormals = original.Geometry.PolygonAttributes.Find<Vector3>("polygon_normals"); var polygonCentroids = original.Geometry.PolygonAttributes.Find<Vector3>("polygon_centroids"); Vector3 normalInModel = polygonNormals[polygon]; Vector3 positionInModel = hoverFrame.LocalToWorld.InverseMatrix.TransformPoint(HoverPosition); var pointLocations = original.Geometry.PointAttributes.Find<Vector3>("point_locations"); Corner pivotCorner = original.Geometry.ClosestPolygonCorner(polygon, positionInModel); Point pivotPoint = pivotCorner.Point; HoverPoint = pivotPoint; Edge firstEdge; Edge secondEdge; original.Geometry.PolygonCornerEdges(polygon, pivotCorner, out firstEdge, out secondEdge); Point firstEdgeOutPoint = firstEdge.Other(pivotPoint); Point secondEdgeOutPoint = secondEdge.Other(pivotPoint); Vector3 pivotLocation = hoverFrame.LocalToWorld.Matrix.TransformPoint(pointLocations[pivotPoint]); Vector3 firstOutLocation = hoverFrame.LocalToWorld.Matrix.TransformPoint(pointLocations[firstEdgeOutPoint]); Vector3 secondOutLocation = hoverFrame.LocalToWorld.Matrix.TransformPoint(pointLocations[secondEdgeOutPoint]); Vector3 normal = hoverFrame.LocalToWorld.Matrix.TransformDirection(normalInModel); Vector3 firstDirection = Vector3.Normalize(firstOutLocation - pivotLocation); Vector3 secondDirection = Vector3.Normalize(secondOutLocation - pivotLocation); Vector3 centroid = hoverFrame.LocalToWorld.Matrix.TransformPoint(polygonCentroids[polygon]); if (Configuration.hoverDebug) { lineRenderer.Begin(); lineRenderer.Line(HoverPosition, HoverPosition + 0.5f * normal, new Vector4(1.0f, 1.0f, 1.0f, 1.0f)); lineRenderer.Line(centroid, centroid + 0.25f * normal, new Vector4(0.5f, 0.5f, 0.5f, 1.0f)); /*LineRenderer.Line(pivotLocation, pivotLocation + normal); LineRenderer.Line(pivotLocation - firstDirection * 1.0f, pivotLocation + firstDirection * 1.0f); LineRenderer.Line(pivotLocation - secondDirection * 1.0f, pivotLocation + secondDirection * 1.0f);*/ lineRenderer.End(); } } #endif } } } } else { if(HoverModel != null) { HoverGroup.Clear(); } HoverModel = null; } }
public void Play() { bool play; string playAgain; while (play = true && Player.money > 0) { Console.Clear(); WriteText.WriteLine("Place Your Bets!", ConsoleColor.Red); WriteText.WriteLine($"Choose a number cooresponding to the bet you'd like to place\n" + $"1: bet on a number(1/36 odds)\t 2: Even or Odds(1/2 odds)\t 3: Red or Black(1/2 odds)\n" + $"4: Lows or Highs(1/2 odds)\t 5: Dozens(1/3 odds)\t 6: Column bet(1/3 odds)\n" + $"7: Street(1/12 odds)\t 8: six-line(1/6 odds)\t 9: Split(1/18 odds)\n" + $"10: Corner bet(1/9 odds)", ConsoleColor.Green); int chosenBet = Int32.Parse(Console.ReadLine()); //switch (chosenBet) //{ // case 1: chosenBet > 10; // throw new IndexOutOfRangeException("You chose a number that dose not match any of the bets."); // break; //} if (chosenBet > 10) { throw new IndexOutOfRangeException("You chose a number that dose not match any of the bets."); } if (chosenBet == 1) { Number number = new Number(); number.NumbersBet(Spin()); } if (chosenBet == 2) { EvenOrOdd evenorodd = new EvenOrOdd(); evenorodd.EvenOrOddBet(Spin()); } if (chosenBet == 3) { RedOrBlack redorblack = new RedOrBlack(); redorblack.RedOrBlackBet(Spin()); } if (chosenBet == 4) { LowsHighs loworhigh = new LowsHighs(); loworhigh.LowOrHighBet(Spin()); } if (chosenBet == 5) { Dozens dozens = new Dozens(); dozens.DozensBet(Spin()); } if (chosenBet == 6) { Columns columns = new Columns(); columns.ColumnBet(Spin()); } if (chosenBet == 7) { Street street = new Street(); street.StreetBet(Spin()); } if (chosenBet == 8) { SixLine sixLine = new SixLine(); sixLine.SixLineBet(Spin()); } if (chosenBet == 9) { Split split = new Split(); split.SplitBet(Spin()); } if (chosenBet == 10) { Corner corner = new Corner(); corner.CornerBet(Spin()); } if (Player.money == 0) { play = false; WriteText.WriteLine("You lost all you own GET OUT!", ConsoleColor.Red); Console.ReadKey(); } if (Player.money > 0) { WriteText.WriteLine("Play again? (yes/no): ", ConsoleColor.Red); playAgain = Console.ReadLine(); playAgain.ToLower(); if (playAgain == "yes") { play = true; Random random = new Random(); int phrase = random.Next(1, 3); if (phrase == 1) { WriteText.WriteLine("Its always possible to have Better luck this time.", ConsoleColor.Red); } if (phrase == 2) { WriteText.WriteLine("Play Again!? Why?", ConsoleColor.Red); } if (phrase == 3) { WriteText.WriteLine("Luck is on your side.", ConsoleColor.Red); Console.ReadKey(); } } } } }
private static bool CheckRoundedCorner(int h, int k, int r, Corner which, int xC, int yC) { int x = 0; int y = r; int p = (3 - (2 * r)); do { switch (which) { case Corner.TopLeftCorner: { //Testing if its outside the top left corner if (xC <= h - x && yC <= k - y) { return(false); } else if (xC <= h - y && yC <= k - x) { return(false); } break; } case Corner.TopRightCorner: { //Testing if its outside the top right corner if (xC >= h + y && yC <= k - x) { return(false); } else if (xC >= h + x && yC <= k - y) { return(false); } break; } case Corner.BottomRightCorner: { //Testing if its outside the bottom right corner if (xC >= h + x && yC >= k + y) { return(false); } else if (xC >= h + y && yC >= k + x) { return(false); } break; } case Corner.BottomLeftCorner: { //Testing if its outside the bottom left corner if (xC <= h - y && yC >= k + x) { return(false); } else if (xC <= h - x && yC >= k + y) { return(false); } break; } } x++; if (p < 0) { p += ((4 * x) + 6); } else { y--; p += ((4 * (x - y)) + 10); } } while (x <= y); return(true); }
public static void GetPointMap(double latitude, double longitude, List <Corner> corners, float width, float height, out float posX, out float posY) { int corner = 1; double min = Utils.PerpendicularDistance(corners[0], corners[1], longitude, latitude); double perpendicular = Utils.PerpendicularDistance(corners[1], corners[2], longitude, latitude); if (perpendicular <= min) { min = perpendicular; corner = 2; } perpendicular = Utils.PerpendicularDistance(corners[2], corners[3], longitude, latitude); if (perpendicular <= min) { min = perpendicular; corner = 3; } perpendicular = Utils.PerpendicularDistance(corners[3], corners[0], longitude, latitude); if (perpendicular <= min) { min = perpendicular; corner = 4; } float checkX = 0; float checkY = 0; if (corner == 1) { //29 18 Corner currentCorner1 = corners[1]; Corner currentCorner2 = corners[0]; double distance2 = Utils.HaversineInM(latitude, longitude, currentCorner1.Latitude, currentCorner1.Longitude); double distanceCorner = Utils.HaversineInM(currentCorner2.Latitude, currentCorner2.Longitude, currentCorner1.Latitude, currentCorner1.Longitude); double temp = Utils.getPixelWithPer(min, distance2); checkY = (float)(height / distanceCorner * temp); currentCorner2 = corners[2]; distanceCorner = Utils.HaversineInM(currentCorner1.Latitude, currentCorner1.Longitude, currentCorner2.Latitude, currentCorner2.Longitude); checkX = (float)(width / distanceCorner * min); } else if (corner == 3) { Corner currentCorner1 = corners[2]; Corner currentCorner2 = corners[3]; double distance2 = (float)Utils.HaversineInM(latitude, longitude, currentCorner1.Latitude, currentCorner1.Longitude); double distanceCorner = Utils.HaversineInM(currentCorner2.Latitude, currentCorner2.Longitude, currentCorner1.Latitude, currentCorner1.Longitude); double temp = Utils.getPixelWithPer(min, distance2); checkY = (float)(height / distanceCorner * temp); currentCorner2 = corners[1]; distanceCorner = Utils.HaversineInM(currentCorner1.Latitude, currentCorner1.Longitude, currentCorner2.Latitude, currentCorner2.Longitude); double x = distanceCorner - (min); checkX = (float)(width / distanceCorner * x); } else if (corner == 2) { Corner currentCorner1 = corners[2]; Corner currentCorner2 = corners[1]; double distance2 = Utils.HaversineInM(latitude, longitude, currentCorner2.Latitude, currentCorner2.Longitude); double distanceCorner = Utils.HaversineInM(currentCorner2.Latitude, currentCorner2.Longitude, currentCorner1.Latitude, currentCorner1.Longitude); double temp = Utils.getPixelWithPer(min, distance2); checkX = (float)(width / distanceCorner * temp); currentCorner1 = corners[0]; distanceCorner = Utils.HaversineInM(currentCorner1.Latitude, currentCorner1.Longitude, currentCorner2.Latitude, currentCorner2.Longitude); checkY = (float)(height / distanceCorner * min); } else if (corner == 4) { Corner currentCorner1 = corners[3]; Corner currentCorner2 = corners[0]; double distance2 = Utils.HaversineInM(latitude, longitude, currentCorner2.Latitude, currentCorner2.Longitude); double distanceCorner = Utils.HaversineInM(currentCorner2.Latitude, currentCorner2.Longitude, currentCorner1.Latitude, currentCorner1.Longitude); double temp = Utils.getPixelWithPer(min, distance2); checkX = (float)(width / distanceCorner * temp); currentCorner2 = corners[2]; distanceCorner = Utils.HaversineInM(currentCorner1.Latitude, currentCorner1.Longitude, currentCorner2.Latitude, currentCorner2.Longitude); double x = distanceCorner - min; checkY = (float)(height / distanceCorner * x); } if ((checkX <= width && checkX >= 0) && (checkY <= height && checkY >= 0)) { posX = checkX; posY = checkY; } else { posX = -1; posY = -1; } }
/// <summary> /// Add circular arc of the given size to the given point from the last point. /// </summary> public abstract void ArcTo(double x, double y, double size, Corner corner);
public Vector3 GetCornerPosition(Corner c) { return(_calibratedCorners[(int)c]); }
public void AddCorner(Corner c) { m_corners.Add(c); }
public void SetCornerPosition(Corner c, Vector3 pos) { _calibratedCorners[(int)c] = pos; UpdateTransform(); }
public PointOnRectangleLocator(IRectangleLocator locator, Corner corner) : this(locator, corner, Point.Empty) { }
public LEDMatrix(LEDs leds, ushort startPixel, byte width, byte height, Corner firstPixelPosition, Orientation secondPixelPosition) { offset = startPixel; target = leds; map = new ushort[width, height]; if (firstPixelPosition == Corner.TopRight) { byte x = (byte)(width - 1); byte y = 0; ushort led = offset; do { map[x, y] = led++; // 321 // 456 // 987 if (secondPixelPosition == Orientation.Rows) { if (y % 2 == 0) { if (x > 0) { x--; } else { y++; } } else { if (x < (byte)(width - 1)) { x++; } else { y++; } } } // 761 // 852 // 943 else // (secondPixelPosition == Orientation.Colums) { if (x % 2 == width % 2) { if (y > 0) { y--; } else { x--; } } else { if (y < (byte)(height - 1)) { y++; } else { x--; } } } } while (led < offset + width * height); } else if (firstPixelPosition == Corner.TopLeft) { byte x = 0; byte y = 0; ushort led = offset; do { map[x, y] = led++; // 123 // 654 // 789 if (secondPixelPosition == Orientation.Rows) { if (y % 2 == 0) { if (x < (byte)(width - 1)) { x++; } else { y++; } } else { if (x > 0) { x--; } else { y++; } } } // 167 // 258 // 349 else // (secondPixelPosition == Orientation.Colums) { if (x % 2 == 0) { if (y < (byte)(height - 1)) { y++; } else { x++; } } else { if (y > 0) { y--; } else { x++; } } } } while (led < offset + width * height); } else if (firstPixelPosition == Corner.BottomLeft) { byte x = 0; byte y = (byte)(height - 1); ushort led = offset; do { map[x, y] = led++; // 789 // 654 // 123 if (secondPixelPosition == Orientation.Rows) { if (y % 2 == height % 2) { if (x < (byte)(width - 1)) { x++; } else { y--; } } else { if (x > 0) { x--; } else { y--; } } } // 349 // 258 // 167 else // (secondPixelPosition == Orientation.Colums) { if (x % 2 == 0) { if (y > 0) { y--; } else { x++; } } else { if (y < (byte)(height - 1)) { y++; } else { x++; } } } } while (led < offset + width * height); } else // (firstPixelPosition == Corner.BottomRight) { byte x = (byte)(width - 1); byte y = (byte)(height - 1); ushort led = offset; do { map[x, y] = led++; // 987 // 456 // 321 if (secondPixelPosition == Orientation.Rows) { if (y % 2 == height % 2) { if (x > 0) { x--; } else { y--; } } else { if (x < (byte)(width - 1)) { x++; } else { y--; } } } // 943 // 852 // 761 else // (secondPixelPosition == Orientation.Colums) { if (x % 2 == width % 2) { if (y > 0) { y--; } else { x--; } } else { if (y < (byte)(height - 1)) { y++; } else { x--; } } } } while (led < offset + width * height); } }
public PointOnRectangleLocator(IRectangleLocator locator, Corner corner, Point offset) { this.RectangleLocator = locator; this.PointProportions = this.ConvertCornerToProportion(corner); this.Offset = offset; }
private static GraphicsPath GetRoundedRect(RectangleF baseRect, float radius, Corner corner) { // if corner radius is less than or equal to zero, // return the original rectangle if (radius <= 0.0F) { GraphicsPath mPath = new GraphicsPath(); mPath.AddRectangle(baseRect); mPath.CloseFigure(); return mPath; } // if the corner radius is greater than or equal to // half the width, or height (whichever is shorter) // then return a capsule instead of a lozenge //if (radius >= (System.Math.Min(baseRect.Width, baseRect.Height)) / 2.0) // return GetCapsule(baseRect); // create the arc for the rectangle sides and declare // a graphics path object for the drawing float diameter = radius * 2.0F; SizeF sizeF = new SizeF(diameter, diameter); RectangleF arc = new RectangleF(baseRect.Location, sizeF); GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); if ((corner & Corner.TopLeft) == Corner.TopLeft) { path.AddArc(arc, 180, 90); } else { path.AddLine(new PointF(baseRect.X, baseRect.Y), new PointF(radius, baseRect.Y)); } //画多边形边 path.AddLine( new PointF(radius, baseRect.Y), new PointF(baseRect.Right - radius, baseRect.Y) ); // top right arc arc.X = baseRect.Right - diameter; if ((corner & Corner.TopRight) == Corner.TopRight) { path.AddArc(arc, 270, 90); path.AddLine( new PointF(baseRect.Right, radius), new PointF(baseRect.Right, baseRect.Bottom - radius)); } else { path.AddLine(new PointF(baseRect.Right - radius, baseRect.Y), new PointF(baseRect.Right, baseRect.Y)); path.AddLine(new PointF(baseRect.Right, baseRect.Y), new PointF(baseRect.Right, radius)); } arc.Y = baseRect.Bottom - diameter; // bottom right arc if ((corner & Corner.BottomRight) == Corner.BottomRight) { path.AddArc(arc, 0, 90); } else { path.AddLine(new PointF(baseRect.Right, baseRect.Bottom - radius), new PointF(baseRect.Right, baseRect.Bottom)); path.AddLine(new PointF(baseRect.Right, baseRect.Bottom), new PointF(baseRect.Right - radius, baseRect.Bottom)); } path.AddLine( new PointF(baseRect.Right - radius, baseRect.Bottom), new PointF(radius, baseRect.Bottom)); arc.X = baseRect.Left; if ((corner & Corner.BottomLeft) == Corner.BottomLeft) { path.AddArc(arc, 90, 90); } else { path.AddLine(new PointF(baseRect.Right - radius, baseRect.Bottom), new PointF(baseRect.X, baseRect.Bottom)); path.AddLine(new PointF(baseRect.X, baseRect.Bottom), new PointF(baseRect.X, baseRect.Bottom - radius)); } // bottom left arc path.AddLine( new PointF(baseRect.X, baseRect.Bottom - radius), new PointF(baseRect.Y, radius)); if ((corner & Corner.TopLeft) != Corner.TopLeft) { path.AddLine(new PointF(baseRect.X, baseRect.Y), new PointF(baseRect.X, radius)); } path.CloseFigure(); return path; }
public static System.Drawing.Drawing2D.GraphicsPath RoundedRect(RectangleF rect, int cornerradius, int margin, Corner roundedcorners) { System.Drawing.Drawing2D.GraphicsPath p = new System.Drawing.Drawing2D.GraphicsPath(); float x = rect.X; float y = rect.Y; float w = rect.Width; float h = rect.Height; int m = margin; int r = cornerradius; p.StartFigure(); //top left arc if (System.Convert.ToBoolean(roundedcorners & Corner.TopLeft)) { p.AddArc(CtrlHelper.CheckedRectangleF(x + m, y + m, 2 * r, 2 * r), 180, 90); } else { p.AddLine(new PointF(x + m, y + m + r), new PointF(x + m, y + m)); p.AddLine(new PointF(x + m, y + m), new PointF(x + m + r, y + m)); } //top line p.AddLine(new PointF(x + m + r, y + m), new PointF(x + w - m - r, y + m)); //top right arc if (System.Convert.ToBoolean(roundedcorners & Corner.TopRight)) { p.AddArc(CtrlHelper.CheckedRectangleF(x + w - m - 2 * r, y + m, 2 * r, 2 * r), 270, 90); } else { p.AddLine(new PointF(x + w - m - r, y + m), new PointF(x + w - m, y + m)); p.AddLine(new PointF(x + w - m, y + m), new PointF(x + w - m, y + m + r)); } //right line p.AddLine(new PointF(x + w - m, y + m + r), new PointF(x + w - m, y + h - m - r)); //bottom right arc if (System.Convert.ToBoolean(roundedcorners & Corner.BottomRight)) { p.AddArc(CtrlHelper.CheckedRectangleF(x + w - m - 2 * r, y + h - m - 2 * r, 2 * r, 2 * r), 0, 90); } else { p.AddLine(new PointF(x + w - m, y + h - m - r), new PointF(x + w - m, y + h - m)); p.AddLine(new PointF(x + w - m, y + h - m), new PointF(x + w - m - r, y + h - m)); } //bottom line p.AddLine(new PointF(x + w - m - r, y + h - m), new PointF(x + m + r, y + h - m)); //bottom left arc if (System.Convert.ToBoolean(roundedcorners & Corner.BottomLeft)) { p.AddArc(CtrlHelper.CheckedRectangleF(x + m, y + h - m - 2 * r, 2 * r, 2 * r), 90, 90); } else { p.AddLine(new PointF(x + m + r, y + h - m), new PointF(x + m, y + h - m)); p.AddLine(new PointF(x + m, y + h - m), new PointF(x + m, y + h - m - r)); } //left line p.AddLine(new PointF(x + m, y + h - m - r), new PointF(x + m, y + m + r)); //close figure... p.CloseFigure(); return(p); }
public Dock(Corner eCorner) : this(eCorner, new Offset()) { }
public static System.Drawing.Drawing2D.GraphicsPath RoundedRect(Rectangle rect, int cornerradius, int margin, Corner roundedcorners) { return(RoundedRect(CtrlHelper.CheckedRectangleF(rect.Left, rect.Top, rect.Width, rect.Height), cornerradius, margin, roundedcorners)); }
public void SetCorners(Corner corners) { this.corners = corners; if (style != null) { style.SetCorners(corners, this); } }
public PointOnRectangleLocator(Corner corner) : this(new AnimationBoundsLocator(), corner, Point.Empty) { }
/// <summary> /// Draws the rounded rectangle. /// </summary> /// <param name="gp">The gp.</param> /// <param name="pen">The pen.</param> /// <param name="x">The x.</param> /// <param name="y">The y.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="radius">The radius.</param> /// <param name="corner">The corner.</param> public static void DrawRoundedRectangle(this Graphics gp, System.Drawing.Pen pen, float x, float y, float width, float height, float radius, Corner corner = Corner.All) { RectangleF rectangle = new RectangleF(x, y, width - pen.Width, height - pen.Width); GraphicsPath path = GetRoundedRect(rectangle, radius, corner); gp.DrawPath(pen, path); }
private static bool CheckRoundedCorner(int h, int k, int r, Corner which, int xC, int yC) { int num = 0; int num2 = r; int num3 = 3 - 2 * r; do { switch (which) { case Corner.TopLeftCorner: if (xC <= h - num && yC <= k - num2) { return(false); } if (xC <= h - num2 && yC <= k - num) { return(false); } break; case Corner.TopRightCorner: if (xC >= h + num2 && yC <= k - num) { return(false); } if (xC >= h + num && yC <= k - num2) { return(false); } break; case Corner.BottomRightCorner: if (xC >= h + num && yC >= k + num2) { return(false); } if (xC >= h + num2 && yC >= k + num) { return(false); } break; case Corner.BottomLeftCorner: if (xC <= h - num2 && yC >= k + num) { return(false); } if (xC <= h - num && yC >= k + num2) { return(false); } break; } num++; if (num3 < 0) { num3 += 4 * num + 6; continue; } num2--; num3 += 4 * (num - num2) + 10; }while (num <= num2); return(true); }