public void object_clicked(object sender, EventArgs e) { string objectCalled = sender.ToString().Split('.')[3]; if (objectCalled.Trim().ToLower() == "ellipse") { Ellipse ellipse = sender as Ellipse; SelectAtributesWindow window = new SelectAtributesWindow(objectCalled.ToLower(), new Point(), ellipse, true); window.ShowDialog(); } else if (objectCalled.Trim().ToLower() == "rectangle") { Rectangle rectangle = sender as Rectangle; SelectAtributesWindow window = new SelectAtributesWindow(objectCalled.ToLower(), new Point(), rectangle, true); window.ShowDialog(); } else if (objectCalled.Trim().ToLower() == "polygon") { Polygon polygon = sender as Polygon; SelectAtributesWindow window = new SelectAtributesWindow(objectCalled.ToLower(), new Point(), polygon, true); window.ShowDialog(); } else { Image image = sender as Image; SelectAtributesWindow window = new SelectAtributesWindow(objectCalled.ToLower(), new Point(), null, true, image); window.ShowDialog(); } }
private void myCanvas_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { var position = Mouse.GetPosition(myCanvas); Point startingPoint = new Point(position.X, position.Y); if (polygon.Count >= 3 && ObjectSelected == "Polygon") { SelectAtributesWindow window = new SelectAtributesWindow("Polygon", startingPoint, null, false, null, polygon); window.ShowDialog(); } }
private void myCanvas_MouseRightButtonUp(object sender, MouseButtonEventArgs e) { var position = Mouse.GetPosition(myCanvas); Point startingPoint = new Point(position.X, position.Y); Point pos = e.GetPosition((Canvas)sender); if (ObjectSelected.Length == 0) { MessageBox.Show("Please choose the object first!"); } else if (ObjectSelected == "Polygon") { Rectangle dot = new Rectangle() { Width = 4, Height = 4, Fill = Brushes.Black }; if (polygon.Count > 0) { dot.Fill = Brushes.Black; dot.Width -= 1; dot.Height -= 1; Line l = new Line() { X1 = polygon[polygon.Count - 1].X, Y1 = polygon[polygon.Count - 1].Y, X2 = pos.X, Y2 = pos.Y, Stroke = Brushes.Black }; myCanvas.Children.Add(l); } myCanvas.Children.Add(dot); Canvas.SetLeft(dot, pos.X - dot.Width / 2); Canvas.SetTop(dot, pos.Y - dot.Height / 2); polygon.Add(pos); } else { SelectAtributesWindow window = new SelectAtributesWindow(ObjectSelected, startingPoint); window.ShowDialog(); } }