Advertisement
Guest User

Untitled

a guest
May 25th, 2013
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.06 KB | None | 0 0
  1.         public override Canvas CreateCanvas()
  2.         {
  3.             Canvas canvas = new Canvas();
  4.  
  5.             Polygon polygon = new Polygon();
  6.             canvas.Children.Add(polygon);
  7.             polygon.Points.Add(new Point(-CameraCenterDiameter / 2, 0));
  8.             polygon.Points.Add(new Point(CameraCenterDiameter / 2, 0));
  9.             polygon.Points.Add(new Point(3 * CameraCenterDiameter, 5 * CameraCenterDiameter));
  10.             polygon.Points.Add(new Point(-3 * CameraCenterDiameter, 5 * CameraCenterDiameter));
  11.  
  12.             if (VisualState == VisualState.None)
  13.             {
  14.                 GradientBrush sightBrush = new LinearGradientBrush();
  15.                 sightBrush.GradientStops.Add(new GradientStop(Color.FromArgb(200, 255, 255, 0), 0));
  16.                 sightBrush.GradientStops.Add(new GradientStop(Color.FromArgb(50, 255, 255, 0), 1));
  17.                 sightBrush.Transform = new RotateTransform(45);
  18.  
  19.                 polygon.Fill = sightBrush;
  20.             }
  21.             else if (VisualState == VisualState.Hovered)
  22.             {
  23.                 GradientBrush sightBrush = new LinearGradientBrush();
  24.                 sightBrush.GradientStops.Add(new GradientStop(Color.FromArgb(255, 255, 255, 0), 0));
  25.                 sightBrush.GradientStops.Add(new GradientStop(Color.FromArgb(100, 255, 255, 0), 1));
  26.                 sightBrush.Transform = new RotateTransform(45);
  27.  
  28.                 polygon.Fill = sightBrush;
  29.             }
  30.  
  31.             Ellipse cameraCenter = new Ellipse();
  32.             canvas.Children.Add(cameraCenter);
  33.             cameraCenter.Width = CameraCenterDiameter;
  34.             cameraCenter.Height = CameraCenterDiameter;
  35.             Canvas.SetLeft(cameraCenter, -CameraCenterDiameter / 2);
  36.             Canvas.SetTop(cameraCenter, -CameraCenterDiameter / 2);
  37.  
  38.             cameraCenter.Fill = Brushes.BlueViolet;
  39.             cameraCenter.Stroke = Brushes.CornflowerBlue;
  40.             cameraCenter.StrokeDashCap = PenLineCap.Round;
  41.             polygon.Stroke = Brushes.CornflowerBlue;
  42.             polygon.StrokeDashCap = PenLineCap.Round;
  43.  
  44.             if (VisualState == VisualState.None)
  45.             {
  46.                 cameraCenter.StrokeDashArray = null;
  47.                 cameraCenter.StrokeThickness = 0;
  48.                 polygon.StrokeDashArray = null;
  49.                 polygon.StrokeThickness = 0;
  50.             }
  51.             else if (VisualState == VisualState.Hovered)
  52.             {
  53.                 cameraCenter.StrokeDashArray = new DoubleCollection() { 2, 2 };
  54.                 cameraCenter.StrokeThickness = 5;
  55.                 polygon.StrokeDashArray = new DoubleCollection() { 2, 2 };
  56.                 polygon.StrokeThickness = 5;
  57.             }
  58.             else if (VisualState == VisualState.Selected)
  59.             {
  60.                 cameraCenter.StrokeDashArray = null;
  61.                 cameraCenter.StrokeThickness = 5;
  62.                 polygon.StrokeDashArray = null;
  63.                 polygon.StrokeThickness = 5;
  64.             }
  65.  
  66.             canvas.LayoutTransform = new RotateTransform(Camera.Angle);
  67.  
  68.             return canvas;
  69.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement