public void CanvasClicked(MouseButtonEventArgs e) { /* TODO: SOME HOW CHECK WHAT WAS CLICKED ON */ /* CHECK TO SEE IF A SHAPE HAS BEEN CLICKED ON OR THE CANVAS ITS SELF */ if (e.Source.GetType() != typeof(Canvas)) { CanvasElementType selectedCanvasType = MainData.GetShapeType((Shape)e.Source); if (oldSelectedCanvasElement != null) { switch (oldSelectedCanvasElementType) { case CanvasElementType.CLUSTER: { oldSelectedCanvasElement.Stroke = Brushes.Black; Canvas.SetZIndex(oldSelectedCanvasElement, 0); break; } } } switch (selectedCanvasType) { case CanvasElementType.CLUSTER: { Galaxy galaxy = MainData.GetGalaxyMap(); Cluster selectedCluster = ((List<Cluster>)galaxy.Clusters).Find(s => s.UId == (Guid)((Polygon)e.Source).Tag); oldSelectedCanvasElement = selectedCluster.Polygon; oldSelectedCanvasElementType = CanvasElementType.CLUSTER; /* SHOW A HIGHLIGHT AROUND THE SELECTED CLUSTER */ selectedCluster.Polygon.Stroke = Brushes.Yellow; Canvas.SetZIndex(selectedCluster.Polygon, 1); //MainData.UpdateCanvas(); RightHandViewModel = new SectorEditViewModel(selectedCluster); break; } } } else { RightHandViewModel = new GalaxyEditViewModel(galaxy); } }
public CanvasPolygonElement(CanvasElementType elementType, PointCollection points, SolidColorBrush strokeBrush, SolidColorBrush fillBrush, int strokeThickness, object tag, TranslateTransform translateTransform) { ElementType = elementType; ElementDrawingType = CanvasDrawingElementType.polygon; Points = points; StrokeBrush = strokeBrush; FillBrush = fillBrush; StrokeThickness = strokeThickness; Tag = tag; TranslateTransform = translateTransform; }
public static void AddChildToCanvas(CanvasElementType type, Shape child, string UId) { CanvasElement canvasElement = new CanvasElement(type, child, UId); canvasElements.Add(canvasElement); child.Uid = UId; Canvas.Children.Add(child); if (type == CanvasElementType.CONNECTION) { Canvas.SetZIndex(child, 10); } else { Canvas.SetZIndex(child, 0); } }
public CanvasElement(CanvasElementType type, Shape shape, string uId) { Type = type; Shape = shape; UId = uId; }