本文整理汇总了C#中System.Windows.Media.PointCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# PointCollection.Add方法的具体用法?C# PointCollection.Add怎么用?C# PointCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.PointCollection
的用法示例。
在下文中一共展示了PointCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessFigure
protected override void ProcessFigure(CircularList<Point> list,
Point3DCollection vertices,
Vector3DCollection normals,
Int32Collection indices,
PointCollection textures)
{
int offset = vertices.Count;
for (int i = 0; i <= list.Count; i++)
{
Point pt = list[i];
// Set vertices.
vertices.Add(new Point3D(pt.X, pt.Y, 0));
vertices.Add(new Point3D(pt.X, pt.Y, -Depth));
// Set texture coordinates.
textures.Add(new Point((double)i / list.Count, 0));
textures.Add(new Point((double)i / list.Count, 1));
// Set triangle indices.
if (i < list.Count)
{
indices.Add(offset + i * 2 + 0);
indices.Add(offset + i * 2 + 2);
indices.Add(offset + i * 2 + 1);
indices.Add(offset + i * 2 + 1);
indices.Add(offset + i * 2 + 2);
indices.Add(offset + i * 2 + 3);
}
}
}
示例2: LayoutRoot_MouseLeftButtonUp
private void LayoutRoot_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
PointCollection points = new PointCollection();
foreach (Point p in poly.Points)
points.Add(p);
Point newPoint = e.GetPosition(poly);
points.Add(newPoint);
poly.Points = points;
// placeholder
Ellipse ph = new Ellipse
{
Fill = new SolidColorBrush(Colors.Black),
Width = 4D,
Height = 4D
};
TranslateTransform t = new TranslateTransform { X = newPoint.X - 2D, Y = newPoint.Y - 2D };
ph.RenderTransform = t;
cnv.Children.Add(ph);
//
TextBlock tb = new TextBlock
{
Foreground = new SolidColorBrush(Colors.Gray),
FontSize = 8
};
tb.Text = newPoint.ToString();
tb.RenderTransform = t;
cnv.Children.Add(tb);
}
示例3: Terrain3D
static Terrain3D()
{
{
SX = new double[17];
SZ = new double[17];
int i = 0;
for (double d = 0; d < 2; d += 0.125)
{
i++;
SX[i] = Math.Cos(Math.PI * d);
SZ[i] = Math.Sin(Math.PI * d);
}
}
{
TEXTURE_COORDINATES = new PointCollection(17);
TEXTURE_COORDINATES.Add(new Point(0, 0));
Point p = new Point(1, 0);
int i = -1;
while (++i < 16) TEXTURE_COORDINATES.Add(p);
TEXTURE_COORDINATES.Freeze();
}
{
TRIANGLE_INDICES = new Int32Collection(48);
for (int i = 1; i < 16; i++)
{
TRIANGLE_INDICES.Add(0);
TRIANGLE_INDICES.Add(i + 1);
TRIANGLE_INDICES.Add(i);
}
TRIANGLE_INDICES.Add(0);
TRIANGLE_INDICES.Add(1);
TRIANGLE_INDICES.Add(16);
TRIANGLE_INDICES.Freeze();
}
}
示例4: Convert
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
var polygonPoints = new PointCollection();
if (values.Length == 3 && values[2] is Thickness)
{
var width = System.Convert.ToDouble(values[0]);
var height = System.Convert.ToDouble(values[1]);
var margin = (Thickness)values[2];
if (System.Convert.ToInt32(parameter) == 0)
{
polygonPoints.Add(new Point(0 + margin.Left, height - margin.Bottom));
polygonPoints.Add(new Point(0, height));
polygonPoints.Add(new Point(0, 0));
polygonPoints.Add(new Point(width, 0));
polygonPoints.Add(new Point(width - margin.Right, 0 + margin.Top));
}
else
{
polygonPoints.Add(new Point(0 + margin.Left, height - margin.Bottom));
polygonPoints.Add(new Point(0, height));
polygonPoints.Add(new Point(width, height));
polygonPoints.Add(new Point(width, 0));
polygonPoints.Add(new Point(width - margin.Right, 0 + margin.Top));
}
}
return polygonPoints;
}
示例5: CreateGeometry
void CreateGeometry()
{
double r = Diameter / 2;
double l = HeadLength * Diameter;
// arrowhead
var pc = new PointCollection();
pc.Add(new Point(-l, r));
pc.Add(new Point(-l, r * 2));
pc.Add(new Point(0, 0));
var headBuilder = new MeshBuilder();
headBuilder.AddRevolvedGeometry(pc, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), ThetaDiv);
_head = headBuilder.ToMesh();
_head.Freeze();
// body
pc = new PointCollection();
pc.Add(new Point(0, 0));
pc.Add(new Point(0, r));
pc.Add(new Point(1, r));
var bodyBuilder = new MeshBuilder();
bodyBuilder.AddRevolvedGeometry(pc, new Point3D(0, 0, 0), new Vector3D(0, 0, 1), ThetaDiv);
_body = bodyBuilder.ToMesh();
_body.Freeze();
}
示例6: AddCircleInZCross
private static void AddCircleInZCross(MeshBuilder mb, Point3D centre, double radius, int div)
{
var points = MeshBuilder.GetCircle(div);
var vectors = new Point3DCollection();
var normals = new Vector3DCollection();
var textures = new PointCollection();
vectors.Add(new Point3D(centre.X, centre.Y, 0));
normals.Add(new Vector3D(0, 0, 1));
textures.Add(new Point(0.5, 0.5));
for (int i = 0; i < points.Count - 1; i++)
{
vectors.Add(new Point3D(points[i].X * radius + centre.X, points[i].Y * radius + centre.Y, centre.Z));
normals.Add(new Vector3D(0, 0, -1));
textures.Add(new Point(points[i].X * 0.5 + 0.5, points[i].Y * 0.5 + 0.5));
vectors.Add(new Point3D(points[i + 1].X * radius + centre.X, points[i + 1].Y * radius + centre.Y, centre.Z));
normals.Add(new Vector3D(0, 0, 01));
textures.Add(new Point(points[i + 1].X * 0.5 + 0.5, points[i + 1].Y * 0.5 + 0.5));
}
mb.AddTriangleFan(vectors, normals, textures);
}
示例7: CreateRectangle
public static MeshGeometry3D CreateRectangle(double height, double width)
{
var vertices = new Point3DCollection();
var normals = new Vector3DCollection();
var facets = new Int32Collection();
var textureCoords = new PointCollection();
vertices.Add(new Point3D(-width / 2, 0, -height / 2));
vertices.Add(new Point3D(-width / 2, 0, height / 2));
vertices.Add(new Point3D(width / 2, 0, -height / 2));
vertices.Add(new Point3D(width / 2, 0, height / 2));
normals.Add(new Vector3D(0, -1, 0));
normals.Add(new Vector3D(0, -1, 0));
normals.Add(new Vector3D(0, -1, 0));
normals.Add(new Vector3D(0, -1, 0));
textureCoords.Add(new Point(1,1));
textureCoords.Add(new Point(1, 0));
textureCoords.Add(new Point(0,1));
textureCoords.Add(new Point(0,0));
facets.Add(0); facets.Add(1); facets.Add(2); facets.Add(3); facets.Add(2); facets.Add(1);
var rectangle = new MeshGeometry3D();
rectangle.Positions = vertices;
rectangle.Normals = normals;
rectangle.TriangleIndices = facets;
rectangle.TextureCoordinates = textureCoords;
return rectangle;
}
示例8: LineToolBox
public LineToolBox()
{
InitializeComponent();
PointCollection points = new PointCollection();
points.Add(new Point(5, 5));
points.Add(new Point(65, 5));
this.plShadow.Points = points;
this.ShowMe(points);
}
示例9: Normalize
public static PointCollection Normalize(Rect rectangle, double thickness)
{
double shift = thickness / 2;
var pointCollection = new PointCollection();
pointCollection.Add(new Point(shift, shift));
pointCollection.Add(new Point(rectangle.Width + shift, shift));
pointCollection.Add(new Point(rectangle.Width + shift, rectangle.Height + shift));
pointCollection.Add(new Point(shift, rectangle.Height + shift));
return pointCollection;
}
示例10: LineShape
public LineShape()
{
InitializeComponent();
PointCollection points = new PointCollection();
points.Add(new Point(5, 5));
points.Add(new Point(65, 5));
plShadow.Points = points;
ShowMe(points);
SetFocus();
}
示例11: AsFace
/// <summary>
/// Return a point collection of the specified point in the List of Tuples
/// and the next point, for a single face of the hexagon
/// </summary>
public static PointCollection AsFace(this List<Tuple<double, double>> verticies, int startingPoint)
{
var pointCollection = new PointCollection(2);
var vertex1 = verticies[startingPoint];
var vertex2 = startingPoint == 5 ? verticies[0] : verticies[startingPoint + 1];
pointCollection.Add(vertex1.AsPoint());
pointCollection.Add(vertex2.AsPoint());
return pointCollection;
}
示例12: DrawTile
public static void DrawTile(int x, int y, int tileWidth, int tileHeight, Tile tile)
{
var mainWindowInstant = (MainWindow)App.Current.MainWindow;
Polygon myPolygon = new Polygon();
myPolygon.Stroke = System.Windows.Media.Brushes.Black;
myPolygon.Fill = getColor(tile);
myPolygon.StrokeThickness = 2;
myPolygon.HorizontalAlignment = HorizontalAlignment.Left;
myPolygon.VerticalAlignment = VerticalAlignment.Center;
PointCollection points = new PointCollection();
Point topCord = getPointTilePoint(x, y, tileWidth, tileHeight);
points.Add(topCord);
Point rightCord = getPointTilePoint(x + 1, y, tileWidth, tileHeight);
points.Add(rightCord);
Point botCord = getPointTilePoint(x + 1, y + 1, tileWidth, tileHeight);
points.Add(botCord);
Point leftCord = getPointTilePoint(x, y + 1, tileWidth, tileHeight);
points.Add(leftCord);
myPolygon.Points = points;
//int screenX = (x - y) * tileWidth / 2 ;
//int screenY = (x + y) * tileHeight / 2;
//int pointX;
//int pointY;
//Point p = new Point(screenX, screenY);
//points.Add(p);
//pointX = screenX + Convert.ToInt32((tileWidth / 2));
//pointY = Convert.ToInt32(screenY + (tileHeight / 2));
//p = new Point(pointX, pointY);
//points.Add(p);
//pointX = screenX;
//pointY = screenY + tileHeight;
//p = new Point(pointX, pointY);
//points.Add(p);
//pointX = Convert.ToInt32(screenX - (tileWidth / 2));
//pointY = Convert.ToInt32(screenY + (tileHeight / 2));
//p = new Point(pointX, pointY);
//points.Add(p);
mainWindowInstant.drawingCanvas.Children.Add(myPolygon);
}
示例13: get3DWalls
/// <summary>
/// This method returns a 3D representation of this building walls
/// </summary>
/// <param name="nodesDict">List of all the nodes on the map</param>
/// <param name="map">bounds of the map</param>
/// <param name="brush">Color of these walls</param>
/// <returns>ModelUIElement3D of these walls</returns>
public ModelUIElement3D get3DWalls(Dictionary<long, OsmSharp.Osm.Node> nodesDict, Map map, ImageBrush brush)
{
// Surrounding tags of the mesh
ModelUIElement3D model = new ModelUIElement3D();
GeometryModel3D geometryModel = new GeometryModel3D();
// Mesh and his his properties
MeshGeometry3D mesh = new MeshGeometry3D();
DiffuseMaterial material = new DiffuseMaterial((System.Windows.Media.Brush)brush);
Point3DCollection positions = new Point3DCollection();
PointCollection texturePoints = new PointCollection();
Int32Collection indices = new Int32Collection();
// Add Points of surface and with add points of surface with height 0
positions = getScaledPositionsWall(nodesDict, map);
// Add indices to the collection
for (int i = 0; i < positions.Count - 2; i += 2) {
indices.Add(i);
indices.Add(i + 2);
indices.Add(i + 1);
indices.Add(i + 3);
indices.Add(i + 1);
indices.Add(i + 2);
// Get the width and height of a wall
float widthWall = (float)Math.Sqrt(Math.Pow(positions[i].X - positions[i + 2].X, 2) + Math.Pow(positions[i].Y - positions[i + 2].Y, 2));
int imageWidth = (int)(brush.ImageSource.Width * widthWall);
int imageHeight = (int)(brush.ImageSource.Height * height);
// Add texture coordinates
texturePoints.Add(new System.Windows.Point(0, imageHeight));
texturePoints.Add(new System.Windows.Point(0, 0));
texturePoints.Add(new System.Windows.Point(imageWidth, imageHeight));
texturePoints.Add(new System.Windows.Point(imageWidth, 0));
}
// Add these collections to the mesh
mesh.Positions = positions;
mesh.TriangleIndices = indices;
mesh.TextureCoordinates = texturePoints;
// Set the color of front and back of the triangle
geometryModel.Material = material;
geometryModel.BackMaterial = material;
// Add the mesh to the model
geometryModel.Geometry = mesh;
model.Model = geometryModel;
return model;
}
示例14: Button3_Click
private void Button3_Click(object sender, RoutedEventArgs e)
{
Window1 wind = new Window1();
wind.Show();
PointCollection c = new PointCollection();
int i = GCDSearch.EuclideanAlgorithm(out time1, Convert.ToInt16(TextBox1_Copy.Text), Convert.ToInt16(TextBox2_Copy.Text));
int j = GCDSearch.BinaryGCDAlgorithm(out time2, Convert.ToInt16(TextBox1_Copy.Text), Convert.ToInt16(TextBox2_Copy.Text));
Point v = new Point(time1 * 1000, 1);
Point z = new Point(time2 * 1000, 2);
c.Add(v);
c.Add(z);
wind.Chart1.DataContext = c;
}
示例15: VideoSurface
public VideoSurface(string mediaSource)
{
this.ModelVisual3D = new ModelVisual3D();
var geometryModel = new GeometryModel3D();
this.ModelVisual3D.Content = geometryModel;
this.geometry = new MeshGeometry3D();
geometryModel.Geometry = geometry;
var positions = new Point3DCollection();
positions.Add(new Point3D(0, 0, 0));
positions.Add(new Point3D(640, 0, 0));
positions.Add(new Point3D(640, 480, 0));
positions.Add(new Point3D(0, 480, 0));
this.geometry.Positions = positions;
var textureCoordinates = new PointCollection();
textureCoordinates.Add(new System.Windows.Point(0, 1));
textureCoordinates.Add(new System.Windows.Point(1, 1));
textureCoordinates.Add(new System.Windows.Point(1, 0));
textureCoordinates.Add(new System.Windows.Point(0, 0));
this.geometry.TextureCoordinates = textureCoordinates;
var triangleIndices = new Int32Collection();
triangleIndices.Add(0);
triangleIndices.Add(1);
triangleIndices.Add(2);
triangleIndices.Add(2);
triangleIndices.Add(3);
triangleIndices.Add(0);
this.geometry.TriangleIndices = triangleIndices;
var material = new EmissiveMaterial();
var brush = new VisualBrush();
this.border = new Border();
this.border.BorderBrush = Brushes.White;
this.border.BorderThickness = new Thickness(10);
this.border.Opacity = 0;
this.mediaElement = new MediaElement();
mediaElement.LoadedBehavior = MediaState.Manual;
mediaElement.Source = new Uri(mediaSource);
this.border.Child = mediaElement;
brush.Visual = border;
material.Brush = brush;
geometryModel.Material = material;
this.mediaElement.MediaEnded += new RoutedEventHandler(mediaElement_MediaEnded);
}