Click here to Skip to main content
15,894,343 members
Articles / Desktop Programming / WPF

XAML polygon transformation tool

Rate me:
Please Sign up or sign in to vote.
4.77/5 (12 votes)
26 Aug 2008CPOL3 min read 34.2K   594   18  
A tool to automate flipping, shifting, rotating, and scaling polygons and polylines.
<Window x:Class="PolyTransform.PolyTransformation"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:pt="clr-namespace:PolyTransform"
      Title="Poly-Transformer" Height="500"  Width="675" Loaded="Window_Loaded"  >
    <Window.Resources>
        <pt:LinearTransformation x:Key="LinTrans" BoundingBox="False"  TopLeftOrigin="False" UniformStretch="False"   />
        <pt:FlipTransformation x:Key="AxialTrans" />
        <pt:RotationalTransformation x:Key="RotateTrans" />
    </Window.Resources>
    <DockPanel>
        <DockPanel.Resources>

            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="Templates/LinearResources.xaml"/>
                    <ResourceDictionary Source="Templates/FlipResources.xaml"/>
                    <ResourceDictionary Source="Templates/RotationalResources.xaml"/>
                </ResourceDictionary.MergedDictionaries>
            </ResourceDictionary>
        </DockPanel.Resources>
        <Grid DockPanel.Dock="Top" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="220"/>
                <ColumnDefinition Width="220"/>
                <ColumnDefinition Width="220"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>

                <RowDefinition Height="160"/>
                <RowDefinition Height="23"/>
            </Grid.RowDefinitions>
            <!--Col 0-->
            <ContentControl  Grid.Column="0" Grid.Row="0" Margin="10,10,10,10" ContentTemplate="{StaticResource AxialTransTemplate}" Content="{ DynamicResource AxialTrans}"/>
            <!--Col 1-->
            <ContentControl  Grid.Column="1" Grid.Row="0" Margin="10,10,10,10" ContentTemplate="{StaticResource RotateTransTemplate}" Content="{ DynamicResource RotateTrans}"/>
            <!--Col 2-->
            <ContentControl  Grid.Column="2" Grid.Row="0" Margin="10,10,10,10" Name="contentControl1" Content="{ DynamicResource LinTrans}"  ContentTemplate="{StaticResource LinTransTemplate}"/>
            <Button Grid.Column="1" Height="23"  Grid.Row="1" Margin="5,0,0,1" Name="btTransformPath" VerticalAlignment="Bottom" Click="btTransformPath_Click">Tranform Path</Button>
        </Grid>

        <Grid Name="PreviewGrid">

            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="5" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Grid.RowDefinitions>
                <RowDefinition Height="100"/>
                <RowDefinition Height="5"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>

            <!--Col 0-->
            <Border  BorderBrush="Gray" BorderThickness="2" Grid.Row="0" Grid.Column="0">
                <ContentControl   Name="previewOriginal" VerticalAlignment="Top" />
            </Border>
            <RichTextBox  Name="txtOriginal"  Grid.Row="2" Grid.Column="0"   TextChanged="txtOriginal_TextChanged"/>
            <!--Col 1-->
            <GridSplitter Grid.Column="1"  Grid.RowSpan="3" HorizontalAlignment="Stretch"  Margin="0,0,0,0"  VerticalAlignment="Stretch"  />
            <!--Col 2-->
            <Border  BorderBrush="Gray" BorderThickness="2" Grid.Column="2" Grid.Row="0">
                <ContentControl    Name="previewTransformed" VerticalAlignment="Top" />
            </Border>
            <RichTextBox Grid.Column="2" Grid.Row ="2" Name="txtTransformed"   />

            <GridSplitter Grid.Row="1"  Grid.ColumnSpan="3" HorizontalAlignment="Stretch"  Margin="0,0,0,0"  VerticalAlignment="Stretch"  />
        </Grid>
    </DockPanel>
</Window>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
Written software for what seems like forever. I'm currenly infatuated with WPF. Hopefully my affections are returned.

Comments and Discussions