public MainWindow() { this.InitializeComponent(); Func<int, int, int, double, Polygon> shape = (ox, oy, sides, angle) => { Polygon polygon = new Polygon { Fill = new SolidColorBrush(new Color { R = 64, G = 128, B = 0, A = 255 }), Stroke = new SolidColorBrush(Colors.Black), StrokeThickness = 1 }; angle *= Math.PI / 180.0; for (int i = 0; i < sides; i++) { double theta = angle + Math.PI * 2 * i / sides; polygon.Points.Add(new Point(ox + Math.Sin(theta) * 25, oy + Math.Cos(theta) * 25)); } return polygon; }; Func<IReadOnlyList<Element>> createElements = () => new[] { new Element("triangle",shape(50,50,3,180.0)), new Element("square",shape(125,50,4,225.0)), new Element("pentagon",shape(200,50,5,180.0)), new Element("hexagon",shape(50,125,6,210.0)), new Element("heptagon",shape(125,125,7,180.0)), new Element("octagon",shape(200,125,8,202.5)) }; this.ClassicPlaceholder.Child = new DocumentUserControl(this, this.ClassicPlaceholder, createElements(), new Classic(this.AddMessage)); this.FrpPlaceholder.Child = new DocumentUserControl(this, this.FrpPlaceholder, createElements(), new Frp(this.AddMessage)); this.ActorPlaceholder.Child = new DocumentUserControl(this, this.ActorPlaceholder, createElements(), new Actor(this.AddMessage, this.Dispatcher)); }
// creates object to be drawn on the map private Grid CreatePushpinObject() { //Creating a Grid element. Grid MyGrid = new Grid(); MyGrid.RowDefinitions.Add(new RowDefinition()); MyGrid.RowDefinitions.Add(new RowDefinition()); MyGrid.Background = new SolidColorBrush(Colors.Transparent); //Creating a Rectangle Rectangle MyRectangle = new Rectangle(); MyRectangle.Fill = new SolidColorBrush(Color.FromArgb(0xF9, 0x00, 0x68, 0)); MyRectangle.Height = 20; MyRectangle.Width = 20; MyRectangle.SetValue(Grid.RowProperty, 0); MyRectangle.SetValue(Grid.ColumnProperty, 0); //Adding the Rectangle to the Grid MyGrid.Children.Add(MyRectangle); //Creating a Polygon Polygon MyPolygon = new Polygon(); MyPolygon.Points.Add(new Point(2, 0)); MyPolygon.Points.Add(new Point(22, 0)); MyPolygon.Points.Add(new Point(2, 40)); MyPolygon.Stroke = new SolidColorBrush(Colors.Black); MyPolygon.Fill = new SolidColorBrush(Colors.Black); MyPolygon.SetValue(Grid.RowProperty, 1); MyPolygon.SetValue(Grid.ColumnProperty, 0); //Adding the Polygon to the Grid MyGrid.Children.Add(MyPolygon); return MyGrid; }
private void SetUpMouseInteractions() { var mouseClicks = Observable.FromEventPattern<MouseButtonEventHandler, MouseButtonEventArgs>( h => canvas.MouseLeftButtonUp += h, h => canvas.MouseLeftButtonUp -= h) .Select(click => new { Position = click.EventArgs.GetPosition(canvas), TimeStamp = click.EventArgs.Timestamp }) .Distinct(clickInfo => clickInfo.Position) .Buffer(3); mouseClicks.Subscribe(args => { var first = args.First(); var second = args.Skip(1).First(); var third = args.Last(); var p = new Polygon(); p.Points.Add(first.Position); p.Points.Add(second.Position); p.Points.Add(third.Position); p.Stroke = Brushes.Red; p.StrokeThickness = 1; canvas.Children.Add(p); this.VM.AddGeometry(p.ToTriangle()); if (this.LineDrawn != null) LineDrawn(this, new LineDrawnEventArgs(first.Position, second.Position, DateTime.Now)); }); }
public PathFigure AddArc(int start, int end) { int horizontalPostion = 100; var startPoint = new Point(horizontalPostion, start); var endPoint = new Point(horizontalPostion, end); PathFigure pathFigure = new PathFigure(); pathFigure.StartPoint = startPoint; ArcSegment arcSeg = new ArcSegment(); arcSeg.Point = endPoint; arcSeg.Size = new Size(25, 25); arcSeg.IsLargeArc = true; arcSeg.SweepDirection = SweepDirection.Clockwise; arcSeg.RotationAngle = 90; var arrowhead = new Polygon(); arrowhead.Stroke = Brushes.Black; arrowhead.StrokeThickness = 2; arrowhead.Points.Add(new Point(endPoint.X - 4, endPoint.Y)); arrowhead.Points.Add(new Point(endPoint.X + 4, endPoint.Y + 3)); arrowhead.Points.Add(new Point(endPoint.X + 4, endPoint.Y - 3)); arrowhead.Fill = Brushes.Black; PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection(); myPathSegmentCollection.Add(arcSeg); pathFigure.Segments = myPathSegmentCollection; _pathFigureCollection.Add(pathFigure); _root.Children.Add(arrowhead); return pathFigure; }
public OrganismVisual(Organism source, Ellipse organism, Polygon sight, PointCollection boundaries, TextBlock energy) { this.source = source; source.OnDeath += source_OnDeath; this.organism = organism; this.boundaries = boundaries; this.energy = energy; organism.Dispatcher.Invoke(new Action(() => organism.Fill = new SolidColorBrush(Colors.Red))); organism.Dispatcher.Invoke(new Action(() => organism.Height = source.getSize())); organism.Dispatcher.Invoke(new Action(() => organism.Width = source.getSize())); this.sight = sight; sight.Dispatcher.Invoke(new Action(() => sight.Fill = new SolidColorBrush(Color.FromArgb(50, 200, 200, 200)))); sight.Dispatcher.Invoke(new Action(() => sight.Points = boundaries)); energy.Dispatcher.Invoke(new Action(() => energy.Foreground = new SolidColorBrush(Colors.White))); energy.Dispatcher.Invoke(new Action(() => energy.HorizontalAlignment = HorizontalAlignment.Center)); energy.Dispatcher.Invoke(new Action(() => energy.VerticalAlignment = VerticalAlignment.Center)); energy.Dispatcher.Invoke(new Action(() => energy.TextAlignment = TextAlignment.Center)); energy.Dispatcher.Invoke(new Action(() => energy.Height = 15)); energy.Dispatcher.Invoke(new Action(() => energy.Width = 40)); constructPointCollection(); }
private void addLake(object sender, RoutedEventArgs e) { try { Polygon lake = new Polygon(); string[] points = lakeTextBox.Text.Split('\n'); string[] xAndY = new string[2]; List<Double> xOfPoint = new List<Double>(); List<Double> yOfPoint = new List<Double>(); for (int i = 0; i < points.Length; i++) { xAndY = points[i].Split(','); xOfPoint.Add(Convert.ToDouble(xAndY[0])); yOfPoint.Add(Convert.ToDouble(xAndY[1])); lake.Points.Add(new Point(xOfPoint[i], yOfPoint[i])); } lake.Fill = new SolidColorBrush(Color.FromRgb(100, 100, 255)); lake.Name = "lake"; var mainWindowInstant = (MainWindow)App.Current.MainWindow; MainWindow.polygonList.Add(lake); mainWindowInstant.mapCanvas.Children.Add(lake); mainWindowInstant.reprintItemList(); landTextBox.Clear(); } catch { } }
private void CreateNewPolygon(Polygon oldPolygon) { i++; string nazwa = oldPolygon.Name; var newPolygon = new Polygon { Name = nazwa + i, Stroke = oldPolygon.Stroke, StrokeThickness = oldPolygon.StrokeThickness, Fill = oldPolygon.Fill, Points = oldPolygon.Points }; newPolygon.MouseLeftButtonDown += new MouseButtonEventHandler(p_MouseLeftButtonDown); //utworzenie 'faktycznych' wymiarów, inaczej 0 newPolygon.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); var polyWidth = newPolygon.DesiredSize.Width; _dropPoint.X = _dropPoint.X - (polyWidth) / 2; _dropPoint.Y = _dropArrow.Y2; //MessageBox.Show(newPolygon.Name); Console.Text += oldPolygon.Name + "\n"; Console.ScrollToEnd(); Canvas.SetLeft(newPolygon, _dropPoint.X); Canvas.SetTop(newPolygon, _dropPoint.Y); DropCanvas.Children.Add(newPolygon); }
public static bool[,] Rasterize(Point[] points, int width, int height) { Contract.Requires(points != null); Contract.Requires(width > 0); Contract.Requires(height > 0); Contract.Requires(width % 8 == 0); Contract.Ensures(Contract.Result<bool[,]>() != null); Contract.Ensures(Contract.Result<bool[,]>().GetLength(0) == width); Contract.Ensures(Contract.Result<bool[,]>().GetLength(1) == height); var canvas = new Canvas { Background = Brushes.White, Width = width, Height = height }; var polygon = new Polygon { Stroke = Brushes.Black, Fill = Brushes.Black, StrokeThickness = 1, Points = new PointCollection(points) }; canvas.Children.Add(polygon); RenderOptions.SetEdgeMode(canvas, EdgeMode.Aliased); canvas.Measure(new Size(width, height)); canvas.Arrange(new Rect(0, 0, canvas.DesiredSize.Width, canvas.DesiredSize.Height)); var rtb = new RenderTargetBitmap(width, height, 96, 96, PixelFormats.Default); rtb.Render(canvas); var fmb = new FormatConvertedBitmap(rtb, PixelFormats.BlackWhite, null, 0); var pixels = new byte[width * height / 8]; fmb.CopyPixels(pixels, width / 8, 0); System.Collections.BitArray ba = new System.Collections.BitArray(pixels); var result = new bool[width, height]; for (int i = 0, y = 0; y < height; ++y) for (int x = 0; x < width; ++x, ++i) result[x, y] = !ba[i]; return result; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { ExecutionState tp = (ExecutionState) value; StackPanel pausePanel = new StackPanel(); if (tp == ExecutionState.Running) { pausePanel.Orientation = Orientation.Horizontal; Polygon pause1 = new Polygon(); pause1.Points = new PointCollection(new List<Point>() { new Point(0, 0), new Point(3, 0), new Point(3, 14), new Point(0, 14) }); pause1.Fill = Brushes.Black; pause1.Stroke = Brushes.Black; Polygon pause2 = new Polygon(); pause2.Points = new PointCollection(new List<Point>() { new Point(5, 0), new Point(8, 0), new Point(8, 14), new Point(5, 14) }); pause2.Fill = Brushes.Black; pause2.Stroke = Brushes.Black; pausePanel.Children.Add(pause1); pausePanel.Children.Add(pause2); } else if (tp == ExecutionState.Paused || tp == ExecutionState.Void) { Polygon runIcon = new Polygon(); runIcon.Points = new PointCollection(new List<Point>() { new Point(0, 0), new Point(11, 7), new Point(0, 14) }); runIcon.Fill = Brushes.Black; runIcon.Stroke = Brushes.Black; pausePanel.Children.Add(runIcon); } return pausePanel; }
public TriangleArrow() { polygonArrow = new Polygon(); this.Children.Add(polygonArrow); SetAngleByPoint(new Point(0, 0), new Point(15, 0)); }
public LTakt(MainWindow wnd, Canvas Can, int Num, double LTaktWidth, double CanWidth) { TaktHeight = 0; if ((wnd!=null)&&(Can == wnd.CanTop)) TaktHeight = 80; N = Num; //this.wnd = wnd; this.Can = Can; int TTakt = Project.TTakt; //double CanWidth = (Can.Parent as Grid).ColumnDefinitions[1].ActualWidth - 5; TaktText.Background = Brushes.Black; TaktText.Foreground = Brushes.LightGray; TaktText.Text = Num.ToString(); TaktText.FontSize = 10; PGTakt = new Polygon(); PGTakt.Stroke = StandartBrushes.TaktLine; double LeftX = N * LTaktWidth; double RightX = LeftX + LTaktWidth; if (RightX > CanWidth) RightX = CanWidth; PGTakt.Points.Add(new Point(LeftX, TaktHeight + 10)); PGTakt.Points.Add(new Point(LeftX + 2, TaktHeight + 2)); PGTakt.Points.Add(new Point(RightX - 2, TaktHeight + 2)); PGTakt.Points.Add(new Point(RightX, TaktHeight + 10)); PGTakt.Points.Add(new Point(RightX - 2, TaktHeight + 20 - 2)); PGTakt.Points.Add(new Point(LeftX + 2, TaktHeight + 20 - 2)); Can.Children.Add(PGTakt); Canvas.SetZIndex(PGTakt, -2); }
public void PageLoaded (object o, EventArgs e) { Moonlight.Gtk.Desklet.SetupToolbox (this); secondsHand = FindName ("secondsHand") as RotateTransform; minuteHand = FindName ("minuteHand") as RotateTransform; hourHand = FindName ("hourHand") as RotateTransform; closeButton = FindName ("desklet-close") as Polygon; if (secondsHand == null || minuteHand == null || hourHand == null || closeButton == null) return; closeButton.MouseEnter += delegate { HighlightButton (closeButton); }; closeButton.MouseLeave += delegate { UnhighlightButton (closeButton); }; DateTime now = DateTime.Now; secondsHand.Angle = now.Second * 6; minuteHand.Angle = now.Minute * 6; hourHand.Angle = now.Hour * 30; }
public override void Draw(Canvas c) { base.Draw(c); Polygon polygon = new Polygon(); polygon.Fill = Brushes.Red; polygon.Stroke = Brushes.Black; polygon.StrokeThickness = 1; PointCollection pointCollection = new PointCollection(); pointCollection.Add(new Point(130, 162)); pointCollection.Add(new Point(145, 158)); pointCollection.Add(new Point(155, 155)); pointCollection.Add(new Point(160, 160)); pointCollection.Add(new Point(160, 165)); pointCollection.Add(new Point(155, 170)); pointCollection.Add(new Point(140, 177)); pointCollection.Add(new Point(120, 177)); pointCollection.Add(new Point(105, 170)); pointCollection.Add(new Point(100, 165)); pointCollection.Add(new Point(100, 160)); pointCollection.Add(new Point(105, 155)); pointCollection.Add(new Point(115, 158)); polygon.Points = pointCollection; c.Children.Add(polygon); }
/// <summary> /// Instantiates AreaGraph. /// </summary> public AreaGraph() { this.DefaultStyleKey = typeof(AreaGraph); _areaGraph = new Polygon(); BindBrush(); }
protected Polygon GeneratePolygon() { Polygon myPolygon = new Polygon(); myPolygon.Stroke = new SolidColorBrush(BorderColor); myPolygon.Fill = new SolidColorBrush(FillColor); myPolygon.StrokeThickness = 2; return myPolygon; }
private HexRender() { _r = GlobalConst.DEFAULT_r; _a = 2.0 / Math.Sqrt(3.0) * _r; hexGrid = HexGrid.I; polygon = new Polygon() { IsEnabled = false }; for (int i = 0; i < 6; i++) polygon.Points.Add(new Point()); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.ethPort = ((System.Windows.Shapes.Polygon)(target)); return; } this._contentLoaded = true; }
public EditingQuad(Quad quad) { Quad = quad; Polygon = new Polygon(); Polygon.Fill = PolygonFillColor; Polygon.StrokeThickness = 1; Polygon.Points = Quad.Points; Polygon.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(Polygon_PreviewMouseLeftButtonDown); Selected = false; }
// create a polygon based on a list of points static Polygon CreatePolygon(params double[] values) { var p = new Polygon(); p.Points = new PointCollection(); for (int i = 0; i < values.Length - 1; i += 2) { p.Points.Add(new Point(values[i], values[i + 1])); } return p; }
public static Polygon GetKeyShape(PianoKey.KeyTypes keyType, bool isLeftEdge, bool isRightEdge) { // White 10 width // Black 6 with // black 4 inside the white in the outside. (...?) Polygon p = new Polygon(); p.Stroke = Brushes.Black; if (isLeftEdge) { return LeftKey(); } if (isRightEdge) { return NormalKey(); } switch (keyType) { case PianoKey.KeyTypes.C: { return LeftKey(); } case PianoKey.KeyTypes.D: { return MiddleKey(); } case PianoKey.KeyTypes.E: { return RightKey(); } case PianoKey.KeyTypes.F: { return LeftKey(); } case PianoKey.KeyTypes.G: { return G(); } case PianoKey.KeyTypes.A: { return A(); } case PianoKey.KeyTypes.B: { return RightKey(); } default: { return BlackKey(); } } }
Polygon CreatePolygon(TouchPoints points) { Polygon p = new Polygon(); foreach (var point in points) { p.Points.Add(point); } return p; }
//.ctor public pcvoPolygon() { this.polygon = new Polygon(); this.polygon.Stroke = Brushes.Black; this.polygon.StrokeThickness = 2; this.polygon.Fill = Brushes.Beige; this.polygon.MouseEnter += mouseEnterHandler; this.polygon.MouseLeave += mouseLeaveHandler; this.polygon.MouseRightButtonUp += enablePolygonEditing; }
private static Polygon GetCenteredHex(double cellSize, double cellX, double cellY, double cellHeight) { var hex = new Polygon(); hex.Points.Add(new Point(cellX - cellSize, cellY)); hex.Points.Add(new Point(cellX - cellSize / 2, cellY + cellHeight / 2)); hex.Points.Add(new Point(cellX + cellSize / 2, cellY + cellHeight / 2)); hex.Points.Add(new Point(cellX + cellSize, cellY)); hex.Points.Add(new Point(cellX + cellSize / 2, cellY - cellHeight / 2)); hex.Points.Add(new Point(cellX - cellSize / 2, cellY - cellHeight / 2)); return hex; }
internal void newPolygon(Data.Image selectedImage, int areaIndex) { polygonCanvas.Children.Remove(polygon); selectedCamera = selectedImage.Place; selectedAreaIndex = areaIndex; polygon = new Shapes.Polygon(); polygon.Stroke = fillBrushes[selectedAreaIndex]; polygon.Fill = strokeBrushes[selectedAreaIndex]; polygon.Opacity = 0.33d; polygonCanvas.Children.Add(polygon); }
public MainWindow() { InitializeComponent(); DrawCartesianGrid(25, "#000000"); Polygon polygon = new Polygon(); polygon.FillRule = FillRule.Nonzero; polygon.Fill = new SolidColorBrush(Colors.DarkOrchid); polygon.Points = PointCollection; Canvas.Children.Add(polygon); }
private void LineOfSight_Click(object sender, RoutedEventArgs e) { DrawSurface.Children.Clear(); Layout layout = new Layout(Orientation.Pointy, new Point(DrawSurface.ActualWidth / 20, DrawSurface.ActualWidth / 20), new Point(DrawSurface.ActualWidth / 2, DrawSurface.ActualHeight / 2) ); List<Hex> blocked = new List<Hex>(); blocked.Add(Hex.FromOffsetY(1, 1)); blocked.Add(Hex.FromOffsetY(-1, -1)); foreach (Hex hex in blocked) { PointCollection points = new PointCollection(); Point[] corners = layout.Corners(hex); foreach (Point p in corners) { points.Add(new Point(p.X, p.Y)); } Polygon polygon = new Polygon(); polygon.Points = points; polygon.Stroke = new SolidColorBrush(Color.FromRgb(0, 0, 0)); polygon.Fill = new SolidColorBrush(Color.FromRgb(0, 0, 0)); polygon.StrokeThickness = 1; DrawSurface.Children.Add(polygon); } List<Hex> range = Hex.Zero.Range(5); List<Hex> hexes = new List<Hex>(); foreach (Hex hex in range) { if (Hex.Zero.LineOfSight(hex, blocked)) hexes.Add(hex); } byte color = 0; foreach (Hex hex in hexes) { color += 20; PointCollection points = new PointCollection(); Point[] corners = layout.Corners(hex); foreach (Point p in corners) { points.Add(new Point(p.X, p.Y)); } Polygon polygon = new Polygon(); polygon.Points = points; polygon.Stroke = new SolidColorBrush(Color.FromRgb(0, 0, 0)); polygon.Fill = new SolidColorBrush(Color.FromRgb(color, 100, 0)); polygon.StrokeThickness = 1; DrawSurface.Children.Add(polygon); } }
public void DrawFigure(Triangle triangle) { var polygon = new Polygon(); new[]{triangle.A, triangle.B, triangle.C} .Select(a => new Point(300 + a.XX * 50, 300 + a.YY * 50)) .ToList<Point>() .ForEach(polygon.Points.Add); polygon.Fill = polygon.Stroke = triangle.Color; polygon.StrokeThickness = 0.35; canvas.Children.Add(polygon); }
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); }
public Tank(Canvas canvas, Point startPosition) { this._canvas = canvas; _share = new Polygon() { Fill = Brushes.GreenYellow, RenderTransform = new RotateTransform(0, 10, 10) }; _share.Points.Add(new Point(10, 0)); _share.Points.Add(new Point(20, 20)); _share.Points.Add(new Point(0, 20)); Canvas.SetZIndex(_share, 1000); this._canvas.Children.Add(_share); Canvas.SetTop(_share, startPosition.Y * 20); Canvas.SetLeft(_share, startPosition.X * 20); }
public void InitializeComponent() { if (_contentLoaded) { return; } _contentLoaded = true; System.Windows.Application.LoadComponent(this, new System.Uri("/PlanMyWay;component/UserControlPMW/RectAnomalie.xaml", System.UriKind.Relative)); this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot"))); this.maFlecheBas = ((System.Windows.Shapes.Polygon)(this.FindName("maFlecheBas"))); this.maFlecheHaut = ((System.Windows.Shapes.Polygon)(this.FindName("maFlecheHaut"))); this.tb_Rdv = ((System.Windows.Controls.TextBlock)(this.FindName("tb_Rdv"))); this.tb_Distance_Adr = ((System.Windows.Controls.TextBlock)(this.FindName("tb_Distance_Adr"))); this.tb_TpsPrevu = ((System.Windows.Controls.TextBlock)(this.FindName("tb_TpsPrevu"))); }
public void drawGreenPoligon(float x, float y) { // Create a blue and a black Brush SolidColorBrush yellowBrush = new SolidColorBrush(); yellowBrush.Color = Colors.Green; SolidColorBrush blackBrush = new SolidColorBrush(); blackBrush.Color = Colors.Black; // Create a Polygon System.Windows.Shapes.Polygon yellowPolygon = new System.Windows.Shapes.Polygon(); yellowPolygon.Stroke = blackBrush; yellowPolygon.Fill = yellowBrush; yellowPolygon.StrokeThickness = 1; int ammount = 5; // Create a collection of points for a polygon System.Windows.Point Point1 = new System.Windows.Point(x - ammount, y - ammount); System.Windows.Point Point2 = new System.Windows.Point(x - ammount, y + ammount); System.Windows.Point Point3 = new System.Windows.Point(x + ammount, y - ammount); System.Windows.Point Point4 = new System.Windows.Point(x + ammount, y + ammount); PointCollection polygonPoints = new PointCollection(); polygonPoints.Add(Point1); polygonPoints.Add(Point2); polygonPoints.Add(Point3); polygonPoints.Add(Point4); // Set Polygon.Points properties yellowPolygon.Points = polygonPoints; // Add Polygon to the page MainWindow.mainGrid.Children.Add(yellowPolygon); }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.PART_LayoutRootControl = ((Imagin.Common.Controls.LayoutRootControl)(target)); return; case 3: this.PinTop = ((Imagin.Common.Controls.LayoutPinnedControl)(target)); return; case 4: this.PinLeft = ((Imagin.Common.Controls.LayoutPinnedControl)(target)); return; case 5: this.Root = ((System.Windows.Controls.Border)(target)); return; case 6: this.PART_Minimized = ((System.Windows.Controls.ToolBar)(target)); return; case 7: this.Markers = ((System.Windows.Controls.Grid)(target)); return; case 8: this.Selection = ((System.Windows.Shapes.Polygon)(target)); return; case 9: this.SecondaryMarkers = ((System.Windows.Controls.Grid)(target)); return; case 10: this.EmptyMarker = ((Imagin.Common.Controls.MaskedImage)(target)); return; case 11: this.PinRight = ((Imagin.Common.Controls.LayoutPinnedControl)(target)); return; case 12: this.PinBottom = ((Imagin.Common.Controls.LayoutPinnedControl)(target)); return; case 13: #line 264 "..\..\..\..\..\Controls\DockView\Controls\LayoutRootControl.xaml" ((System.Windows.Controls.Grid)(target)).MouseLeave += new System.Windows.Input.MouseEventHandler(this.OnPinLeave); #line default #line hidden return; case 14: #line 290 "..\..\..\..\..\Controls\DockView\Controls\LayoutRootControl.xaml" ((System.Windows.Controls.Grid)(target)).MouseLeave += new System.Windows.Input.MouseEventHandler(this.OnPinLeave); #line default #line hidden return; case 15: #line 316 "..\..\..\..\..\Controls\DockView\Controls\LayoutRootControl.xaml" ((System.Windows.Controls.Grid)(target)).MouseLeave += new System.Windows.Input.MouseEventHandler(this.OnPinLeave); #line default #line hidden return; case 16: #line 342 "..\..\..\..\..\Controls\DockView\Controls\LayoutRootControl.xaml" ((System.Windows.Controls.Grid)(target)).MouseLeave += new System.Windows.Input.MouseEventHandler(this.OnPinLeave); #line default #line hidden return; } this._contentLoaded = true; }
private void CreateVoronoiDiagram() { double width = Application.Current.MainWindow.Width; double height = Application.Current.MainWindow.Height; List <Color> colors = ColorUtils.GenerateRandomColors(MaxPoints); List <Point> points = CreateRandomPoints(width, height); _voronoi = new Voronoi(points, colors, new Rect(0, 0, width, height)); foreach (LineSegment lineSegment in _voronoi.VoronoiDiagram()) { if (!lineSegment.P0.HasValue || !lineSegment.P1.HasValue) { continue; } ShapeSegments.Add(new Line { X1 = lineSegment.P0.Value.X, X2 = lineSegment.P1.Value.X, Y1 = lineSegment.P0.Value.Y, Y2 = lineSegment.P1.Value.Y, Stroke = new SolidColorBrush(Colors.Black), StrokeThickness = 1 }); } int index = 0; foreach (List <Point> point in _voronoi.Regions()) { Polygon polygon = new Polygon { Stroke = new SolidColorBrush(Colors.Black), StrokeThickness = 1, Fill = new SolidColorBrush(colors[index % colors.Count]), Points = new PointCollection(point) }; ShapeSegments.Add(polygon); index++; } foreach (LineSegment lineSegment in _voronoi.DelaunayTriangulation()) { if (!lineSegment.P0.HasValue || !lineSegment.P1.HasValue) { continue; } ShapeSegments.Add(new Line { X1 = lineSegment.P0.Value.X, X2 = lineSegment.P1.Value.X, Y1 = lineSegment.P0.Value.Y, Y2 = lineSegment.P1.Value.Y, Stroke = new SolidColorBrush(Colors.Azure), StrokeThickness = 1 }); } foreach (Point point in points) { var ellipse = new Ellipse { Stroke = new SolidColorBrush(Colors.OrangeRed), StrokeThickness = 5 }; Canvas.SetLeft(ellipse, point.X - ellipse.StrokeThickness / 2); Canvas.SetTop(ellipse, point.Y - ellipse.StrokeThickness / 2); ShapeSegments.Add(ellipse); } }