本文整理汇总了C#中Corner类的典型用法代码示例。如果您正苦于以下问题:C# Corner类的具体用法?C# Corner怎么用?C# Corner使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Corner类属于命名空间,在下文中一共展示了Corner类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawLogo
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);
}
}
示例2: FindPointAtDistanceFrom
//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)
};
}
示例3: DrawString
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);
}
}
示例4: BoundingBox
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();
}
示例5: WorkOutIfPossible
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");
}
示例6: CornerButtons
public CornerButtons(Corner corner)
{
Corner = corner;
RenderSize = MinSize;
IsHoverable = true;
IsTogglable = false;
}
示例7: LODMeshObject
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
}
示例8: ArcTo
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);
}
示例9: CutCorners
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;
}
示例10: Corners
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);
}
示例11: Clone
/**
* 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;
}
示例12: HUD
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;
}
示例13: CubieCube
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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];
}
}
示例14: FloatConstructor
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);
}
示例15: GetRelativePosition
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;
}