本文整理汇总了C#中IShape类的典型用法代码示例。如果您正苦于以下问题:C# IShape类的具体用法?C# IShape怎么用?C# IShape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IShape类属于命名空间,在下文中一共展示了IShape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Subject_ChangedForm
void Subject_ChangedForm(IShape subject, ChangeFormState state)
{
if (isAttracted || dragged != subject || !state.HasFlag(ChangeFormState.Coords)) return;
using (StartFinishAction.Create(() => isAttracted = true, () => isAttracted = false))
{
RectangleF rect = subject.Rectangle;
PointF center = subject.GetCenter(), minDist = new PointF(10, 10), dist = new PointF();
guidlines = subject.GetCenter();
hit = 0;
bool lHit = false;
foreach (var guide in guides.Where(s => s != subject).Select(s => s.GetCenter()))
{
if ((dist.X = Math.Abs(center.X - guide.X)) < minDist.X)
{
minDist.X = dist.X;
guidlines.X = guide.X;
hit |= 1;
}
if ((dist.Y = Math.Abs(center.Y - guide.Y)) < minDist.Y)
{
minDist.Y = dist.Y;
guidlines.Y = guide.Y;
hit |= 2;
}
if (hit == 3) break;
//if (hit = Math.Abs(rect.Left - guide.X) <= 10)
// subject.Left = guide.X;
//if (hit |= Math.Abs(rect.Top - guide.Y) <= 10)
// subject.Top = guide.Y;
//if (hit) break;
}
subject.ToCenterPoint(guidlines);
}
}
示例2: Connect
public static IConnection Connect(this RadDiagram diagram, IShape a, IShape b, string name = null)
{
var c = diagram.AddConnection(a, b);
if (!string.IsNullOrEmpty(name))
c.Name = name;
return c;
}
示例3: StaticPhysicalEntity
public StaticPhysicalEntity(IShape shape, float weight = 1, bool inelasticCollision = false, bool elasticCollision = false)
{
Shape = shape;
InelasticCollision = inelasticCollision;
ElasticCollision = elasticCollision;
Weight = weight;
}
示例4: Main
private static void Main()
{
var shapes = new IShape[]
{
new Rectangle(1.5, 2),
new Rhombus(4, 5),
new Circle(30),
new Circle(1),
new Circle(2),
new Rhombus(2, 3),
new Rectangle(1.1, 1),
};
shapes = shapes.ToList().OrderByDescending(a => a.GetType().Name).ToArray(); // this is optional
var longestTypePad = shapes.Max(a => a.GetType().Name).Length + 2;
var longestShapePad = shapes.Max(a => a.ToString()).Length + 2;
foreach (var shape in shapes)
{
Console.WriteLine("{0} -> {1} Area: {2,-8:F2} Perimeter: {3:F2}",
shape.GetType().Name.PadRight(longestTypePad),
shape.ToString().PadRight(longestShapePad),
shape.CalculateArea(),
shape.CalculatePerimeter());
}
}
示例5: AbstractPrefixTreeFilter
public AbstractPrefixTreeFilter(IShape queryShape, string fieldName, SpatialPrefixTree grid, int detailLevel)
{
this.queryShape = queryShape;
this.fieldName = fieldName;
this.grid = grid;
this.detailLevel = detailLevel;
}
示例6: IntersectsPrefixTreeFilter
public IntersectsPrefixTreeFilter(IShape queryShape, string fieldName,
SpatialPrefixTree grid, int detailLevel,
int prefixGridScanLevel, bool hasIndexedLeaves)
: base(queryShape, fieldName, grid, detailLevel, prefixGridScanLevel)
{
this.hasIndexedLeaves = hasIndexedLeaves;
}
示例7: collide
public static Vector2 collide(IShape a, IShape b)
{
if (a is RectangleShape && b is RectangleShape)
{
return intersectRectangles((RectangleShape)a, (RectangleShape)b);
}
if (a is Circle && b is RectangleShape)
{
if (b is Line) return -circleLineDetect((Line)b, (Circle)a);
return intersectCircleRectangle((Circle) a, (RectangleShape) b);
}
if (a is RectangleShape && b is Circle)
{
if (a is Line) return circleLineDetect((Line)a, (Circle)b);
return -intersectCircleRectangle((Circle) b, (RectangleShape) a);
}
if (a is Circle && b is Circle)
{
return intersectCircles((Circle)a, (Circle)b);
}
return Vector2.Zero;
}
示例8: BuildShapeContext
protected BuildShapeContext(IShape shape, IContent content, string groupId, IShapeFactory shapeFactory) {
Shape = shape;
ContentItem = content.ContentItem;
New = shapeFactory;
GroupId = groupId;
FindPlacement = (partType, differentiator, defaultLocation) => new PlacementInfo {Location = defaultLocation, Source = String.Empty};
}
示例9: Draw
public void Draw(IShape shape)
{
if (shape is Rectangle) { DrawRectangle(); }
else if (shape is Circle) { DrawCircle(); }
// If we want to introduce new shape(s),
// we have to MODIFY this entity right HERE...
}
示例10: UpdateEditorContext
public UpdateEditorContext(IShape model, IContent content, IUpdateModel updater, string groupInfoId, IShapeFactory shapeFactory, ShapeTable shapeTable, string path)
: base(model, content, groupInfoId, shapeFactory) {
ShapeTable = shapeTable;
Updater = updater;
Path = path;
}
示例11: Add
public void Add(IShape item)
{
if (!base.List.Contains(item))
{
base.List.Add(item);
}
}
示例12: Remove
public void Remove(IShape shape)
{
if (_shapeList.Contains(shape))
{
_shapeList.Remove(shape);
}
}
示例13: Add
public void Add(IShape shape)
{
if (shape != null)
{
_shapeList.Add(shape);
}
}
示例14: FindPlacementImpl
private static PlacementInfo FindPlacementImpl(ShapeTable shapeTable, IShape shape, string differentiator, string displayType)
{
ShapeDescriptor descriptor;
var shapeType = shape.Metadata.Type;
if (shapeTable.Descriptors.TryGetValue(shapeType, out descriptor))
{
var placementContext = new ShapePlacementContext
{
Shape = shape,
DisplayType = displayType,
Differentiator = differentiator
};
var placement = descriptor.Placement(placementContext);
if (placement != null)
{
placement.Source = placementContext.Source;
return placement;
}
}
return null;
}
示例15: SpatialArgs
public SpatialArgs(SpatialOperation operation, IShape shape)
{
if (operation == null || shape == null)
throw new ArgumentException("operation and shape are required");
this.Operation = operation;
this.Shape = shape;
}