Click here to Skip to main content
12,627,064 members (36,194 online)
Click here to Skip to main content

Stats

991.4K views
44.7K downloads
621 bookmarked
Posted

WPF Diagram Designer: Part 1

, 23 Aug 2008 CPOL
Drag, resize and rotate elements on a Canvas
bin
Media
cross.png
intro.wmv
paint.png
MoveResize.exe
MoveResizeRotate.exe
MoveResizeRotateWithAdorners.exe
DiagramDesignerPart1
MoveResize
Properties
MoveResizeRotate
Properties
Resources
MoveResizeRotateWithAdorners
Adorners
Media
cross.png
intro.wmv
paint.png
Properties
Resources
DragAndResizeControl
bin
Debug
DragAndResizeControl.exe
DragAndResizeControl.csproj.user
Properties
DragResizeRotateItems
DragResizeRotateItems.csproj.user
media
Excavator.png
Graph.png
intro.wmv
iPod.png
Phone.png
Properties
<Window x:Class="DragResizeRotateItems.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        SnapsToDevicePixels="True"
        Height="500" Width="800"
        WindowStartupLocation="CenterScreen"
        Title="Diagram Designer - Part I">
  
  <Window.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="./DesignerItem.xaml"/>
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Window.Resources>

  <Grid>
    <Canvas Name="DesignerCanvas" Background="White">

      <!-- Image -->
      <ContentControl Width="130" Height="130" Canvas.Top="100" Canvas.Left="70">
        <Image IsHitTestVisible="False"  Stretch="Fill" Source="./media/iPod.png"/>
      </ContentControl>

      <!-- Image -->
      <ContentControl Width="130" Height="130" Canvas.Top="100" Canvas.Left="320">
        <Image IsHitTestVisible="False"  Stretch="Fill" Source="./media/Phone.png"/>
      </ContentControl>

      <!-- ProgressBar and Slider -->
      <ContentControl Width="130" Height="130" Canvas.Top="100" Canvas.Left="570">
        <Grid>
          <Rectangle Fill="{StaticResource RectBackground}" RadiusX="8" RadiusY="8" IsHitTestVisible="False"/>
          <Border BorderBrush="#77305C88" BorderThickness="1" CornerRadius="8">
            <StackPanel Margin="5,20,5,5">
              <Slider Margin="5"/>
              <ProgressBar Name="progressBar" Maximum="100" Height="20" Margin="5">
                <ProgressBar.Triggers>
                  <EventTrigger RoutedEvent="ProgressBar.Loaded">
                    <BeginStoryboard>
                      <Storyboard>
                        <DoubleAnimation Storyboard.TargetName="progressBar"
                                         Storyboard.TargetProperty="Value"
                                         RepeatBehavior="Forever"
                                         AutoReverse="True"
                                         Duration="0:0:2" From="0" To="100" />
                      </Storyboard>
                    </BeginStoryboard>
                  </EventTrigger>
                </ProgressBar.Triggers>
              </ProgressBar>
            </StackPanel>
          </Border>
        </Grid>
      </ContentControl>

      <!--MediaElement -->
      <ContentControl Width="130" Height="130" Canvas.Top="300" Canvas.Left="320">
        <Grid>
          <Rectangle Fill="Black" RadiusX="8" RadiusY="8" IsHitTestVisible="False"/>
          <TextBlock Text="Video" HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="#AAFFFFFF" FontSize="18" IsHitTestVisible="False" Margin="10" />
          <MediaElement IsHitTestVisible="False" Name="mediaElement" Margin="10,10,10,30" Stretch="Fill" >
            <MediaElement.Triggers>
              <EventTrigger RoutedEvent="MediaElement.Loaded">
                <EventTrigger.Actions>
                  <BeginStoryboard>
                    <Storyboard>
                      <MediaTimeline Source="./media/intro.wmv" Storyboard.TargetName="mediaElement"
                        RepeatBehavior="Forever" />
                    </Storyboard>
                  </BeginStoryboard>
                </EventTrigger.Actions>
              </EventTrigger>
            </MediaElement.Triggers>
          </MediaElement>
        </Grid>
      </ContentControl>

      <!-- Image -->
      <ContentControl Width="130" Height="130" Canvas.Top="300" Canvas.Left="70">
        <Image IsHitTestVisible="False"  Stretch="Fill" Source="./media/Graph.png"/>
      </ContentControl>

      <!-- Image -->
      <ContentControl Width="130" Height="130" Canvas.Top="300" Canvas.Left="570">
        <Image IsHitTestVisible="False"  Stretch="Fill" Source="./media/Excavator.png"/>
      </ContentControl>

    </Canvas>

    <CheckBox Name="checkBox" IsThreeState="False" IsChecked="True" Margin="10"
              Content="select all" Click="OnClicked" FontSize="14" Foreground="Gray"
              VerticalAlignment="Top" HorizontalAlignment="Center"/>
  </Grid>
</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)

Share

About the Author

sukram
Austria Austria
No Biography provided

You may also be interested in...

Pro
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.161205.3 | Last Updated 24 Aug 2008
Article Copyright 2008 by sukram
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid