Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public override Canvas CreateCanvas()
- {
- Canvas canvas = new Canvas();
- Polygon polygon = new Polygon();
- canvas.Children.Add(polygon);
- polygon.Points.Add(new Point(-CameraCenterDiameter / 2, 0));
- polygon.Points.Add(new Point(CameraCenterDiameter / 2, 0));
- polygon.Points.Add(new Point(3 * CameraCenterDiameter, 5 * CameraCenterDiameter));
- polygon.Points.Add(new Point(-3 * CameraCenterDiameter, 5 * CameraCenterDiameter));
- if (VisualState == VisualState.None)
- {
- GradientBrush sightBrush = new LinearGradientBrush();
- sightBrush.GradientStops.Add(new GradientStop(Color.FromArgb(200, 255, 255, 0), 0));
- sightBrush.GradientStops.Add(new GradientStop(Color.FromArgb(50, 255, 255, 0), 1));
- sightBrush.Transform = new RotateTransform(45);
- polygon.Fill = sightBrush;
- }
- else if (VisualState == VisualState.Hovered)
- {
- GradientBrush sightBrush = new LinearGradientBrush();
- sightBrush.GradientStops.Add(new GradientStop(Color.FromArgb(255, 255, 255, 0), 0));
- sightBrush.GradientStops.Add(new GradientStop(Color.FromArgb(100, 255, 255, 0), 1));
- sightBrush.Transform = new RotateTransform(45);
- polygon.Fill = sightBrush;
- }
- Ellipse cameraCenter = new Ellipse();
- canvas.Children.Add(cameraCenter);
- cameraCenter.Width = CameraCenterDiameter;
- cameraCenter.Height = CameraCenterDiameter;
- Canvas.SetLeft(cameraCenter, -CameraCenterDiameter / 2);
- Canvas.SetTop(cameraCenter, -CameraCenterDiameter / 2);
- cameraCenter.Fill = Brushes.BlueViolet;
- cameraCenter.Stroke = Brushes.CornflowerBlue;
- cameraCenter.StrokeDashCap = PenLineCap.Round;
- polygon.Stroke = Brushes.CornflowerBlue;
- polygon.StrokeDashCap = PenLineCap.Round;
- if (VisualState == VisualState.None)
- {
- cameraCenter.StrokeDashArray = null;
- cameraCenter.StrokeThickness = 0;
- polygon.StrokeDashArray = null;
- polygon.StrokeThickness = 0;
- }
- else if (VisualState == VisualState.Hovered)
- {
- cameraCenter.StrokeDashArray = new DoubleCollection() { 2, 2 };
- cameraCenter.StrokeThickness = 5;
- polygon.StrokeDashArray = new DoubleCollection() { 2, 2 };
- polygon.StrokeThickness = 5;
- }
- else if (VisualState == VisualState.Selected)
- {
- cameraCenter.StrokeDashArray = null;
- cameraCenter.StrokeThickness = 5;
- polygon.StrokeDashArray = null;
- polygon.StrokeThickness = 5;
- }
- canvas.LayoutTransform = new RotateTransform(Camera.Angle);
- return canvas;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement