Polygon Mouse down event

image_pdfimage_print


   
  
<Window x:Class="WpfApplication1.ShapesWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="ShapesWindow" Height="160" Width="400">
    <StackPanel Orientation="Horizontal">
        <Polygon Fill="Red" Canvas.Left = "100" Canvas.Top="30" Points="20 0 40 40 0 40" MouseDown="Polygon_MouseDown"/>
    </StackPanel>
</Window>


//File:Window.xaml.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApplication1
{
    public partial class ShapesWindow : Window
    {
        public ShapesWindow()
        {
            InitializeComponent();
        }

        private void Polygon_MouseDown(object sender, MouseButtonEventArgs e)
        {
            MessageBox.Show("Hi");
        }
    }
}

   
    
     


No rotation

image_pdfimage_print


   
     
<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
    <Polyline Points="25,25 0,50 25,75 50,50 25,25 25,0" Stroke="Blue" StrokeThickness="10"/> 

</Window>

   
    
    
    
    
     


Rotates the Polyline 45 degrees about the point (25,50)

image_pdfimage_print


   
     
<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
          <Polyline Points="25,25 0,50 25,75 50,50 25,25 25,0" 
            Stroke="Blue" StrokeThickness="10">
            <Polyline.RenderTransform>
              <RotateTransform CenterX="25" CenterY="50" Angle="45" />
            </Polyline.RenderTransform>
          </Polyline>

</Window>

   
    
    
    
    
     


Rotates the Polyline 45 degrees about the point (0,0)

image_pdfimage_print


   
     
<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
        <Canvas Height="200" Width="200">
          <Polyline Points="25,25 0,50 25,75 50,50 25,25 25,0" 
            Stroke="Blue" StrokeThickness="10"
            Canvas.Left="75" Canvas.Top="50">
            <Polyline.RenderTransform>
              <RotateTransform CenterX="0" CenterY="0" Angle="45" />
            </Polyline.RenderTransform>
          </Polyline>
          <Polyline Points="25,25 0,50 25,75 50,50 25,25 25,0" Stroke="Blue" StrokeThickness="10"
            Opacity="0.25" Canvas.Left="75" Canvas.Top="50" />            
        </Canvas>

</Window>

   
    
    
    
    
     


Rotates the Polyline 45 degrees about its center

image_pdfimage_print


   
     
<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
        <Canvas Height="200" Width="200">
          <Polyline 
            Points="25,25 0,50 25,75 50,50 25,25 25,0" 
            Stroke="Blue" StrokeThickness="10"
            Canvas.Left="75" Canvas.Top="50"
            RenderTransformOrigin="0.5,0.5">
            <Polyline.RenderTransform>
              <RotateTransform Angle="45" />
            </Polyline.RenderTransform>
          </Polyline>
          <Polyline Points="25,25 0,50 25,75 50,50 25,25 25,0" Stroke="Blue" StrokeThickness="10"
            Opacity="0.25" Canvas.Left="75" Canvas.Top="50" />            
        </Canvas>

</Window>

   
    
    
    
    
     


Rotates the Polyline 45 degrees about the relative origin (0.25,0.25).

image_pdfimage_print


   
     
<Window x:Class="Workspace.DockExample"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Workspace" Width="640" Height="480">
        <Canvas Height="200" Width="200">
          <Polyline 
            Points="25,25 0,50 25,75 50,50 25,25 25,0" 
            Stroke="Blue" StrokeThickness="10"
            Canvas.Left="75" Canvas.Top="50"
            RenderTransformOrigin="0.25,0.25">
            <Polyline.RenderTransform>
              <RotateTransform Angle="45" />
            </Polyline.RenderTransform>
          </Polyline>
          <Polyline Points="25,25 0,50 25,75 50,50 25,25 25,0" Stroke="Blue" StrokeThickness="10"
            Opacity="0.25" Canvas.Left="75" Canvas.Top="50" />            
        </Canvas>

</Window>