private void xamlButton1_Click(object sender, RoutedEventArgs e) { xamlCanvas.Children.Clear(); DDPolygon p1; DDPolyline p2; /*DDRectangle r; * * r = new DDRectangle(); * * r.Bounds = new Rect(200, 140, 300, 200); * r.Stroke = Brushes.ForestGreen; * r.StrokeThickness = 3; * r.Fill = Brushes.Red; * xamlCanvas.Children.Add(r);*/ p1 = new DDPolygon(); p1.Nodes.Add(new DDNodeWithHandles(xamlCanvas, new Point(100, 100))); p1.Nodes.Add(new DDNodeWithHandles(xamlCanvas, new Point(500, 100))); p1.Nodes.Add(new DDNodeWithHandles(xamlCanvas, new Point(300, 200))); p1.Stroke = Brushes.Black; p1.Fill = Brushes.Yellow; xamlCanvas.Children.Add(p1); p2 = new DDPolyline(); p2.Nodes.Add(new DDNodeWithHandles(xamlCanvas, new Point(100, 250))); p2.Nodes.Add(new DDNodeWithHandles(xamlCanvas, new Point(500, 250))); p2.Nodes.Add(new DDNodeWithHandles(xamlCanvas, new Point(300, 350))); p2.Stroke = Brushes.Black; p2.Fill = Brushes.LimeGreen; xamlCanvas.Children.Add(p2); DDRectangle r1 = new DDRectangle(); r1.Bounds = new Rect(100, 400, 400, 100); r1.Fill = Brushes.Red; r1.Stroke = Brushes.Black; xamlCanvas.Children.Add(r1); DDEllipse e1 = new DDEllipse(); e1.Bounds = new Rect(100, 550, 400, 100); e1.Fill = Brushes.Blue; e1.Stroke = Brushes.Red; xamlCanvas.Children.Add(e1); r1.CornerRadiusX = 50; r1.CornerRadiusY = 100; }
//DDManipulationFrame manipulationFrame = null; public MainWindow() { InitializeComponent(); myTest = new DDPolygon(); myTest.Nodes.Add(new DDNodeWithHandles(new Point(130, 132))); myTest.Nodes.Add(new DDNodeWithHandles(new Point(167, 111))); myTest.Nodes.Add(new DDNodeWithHandles(new Point(217, 156))); myTest.Nodes.Add(new DDNodeWithHandles(new Point(154, 235))); myTest.Stroke = Brushes.Black; myTest.Fill = Brushes.Yellow; xamlCanvas.Children.Add(myTest); xamlCanvas.MouseMove += new MouseEventHandler(xamlCanvas_MouseMove); //manipulationFrame = new DDManipulationFrame(myTest); //xamlCanvas.Children.Add(manipulationFrame); }
private void xamlButton2_Click(object sender, RoutedEventArgs e) { xamlCanvas.Children.Clear(); Random rand = new Random(); int pCount = rand.Next(30) + 10; DDPolygon[] polygons = new DDPolygon[pCount]; for (int i = 0; i < pCount; i++) { polygons[i] = new DDPolygon(); int nCount = rand.Next(10) + 5; Point pos = new Point(rand.Next(800), rand.Next(800)); Size size = new Size(rand.Next(600) + 50, rand.Next(600) + 50); for (int j = 0; j < nCount; j++) { DDNodeWithHandles node = new DDNodeWithHandles(xamlCanvas) { Point = new Point( pos.X + rand.Next((int)size.Width), pos.Y + rand.Next((int)size.Height)) }; polygons[i].Nodes.Add(node); } polygons[i].Stroke = new SolidColorBrush(Color.FromArgb((byte)(200 + rand.Next(56)), (byte)rand.Next(256), (byte)rand.Next(256), (byte)rand.Next(256))); polygons[i].Fill = new SolidColorBrush(Color.FromArgb((byte)(200 + rand.Next(56)), (byte)rand.Next(256), (byte)rand.Next(256), (byte)rand.Next(256))); polygons[i].StrokeThickness = rand.Next(6); xamlCanvas.Children.Add(polygons[i]); } DDTranslateAndScaleFrame manipulationFrame = new DDTranslateAndScaleFrame(polygons); xamlCanvas.Children.Add(manipulationFrame); }