Click here to Skip to main content
13,095,004 members (81,259 online)
Click here to Skip to main content

Stats

605K views
47.4K downloads
633 bookmarked
Posted 16 Jan 2008

WPF Diagram Designer: Part 1

, 23 Aug 2008
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="DragAndResizeControl.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:s="clr-namespace:DragAndResizeControl"
        Title="Diagram Designer - Part 1"
        Height="500" Width="750">
  <Window.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="./DesignerItem.xaml"/>
        <ResourceDictionary Source="./Shared.xaml"/>
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
  </Window.Resources>
  <Canvas>
    <!-- Ellipse -->
    <ContentControl Width="130" Height="130" Canvas.Top="50" Canvas.Left="70"
                    Template="{StaticResource DragableAndResizableDesignerItem}">
      <Ellipse Fill="{StaticResource Orange}" IsHitTestVisible="False"/>
    </ContentControl>
    <!-- Ellipse with shadow-->
    <ContentControl Width="130" Height="130" Canvas.Top="50" Canvas.Left="530"
                    Template="{StaticResource DragableDesignerItem}">
      <Ellipse Fill="{StaticResource Blue}" IsHitTestVisible="False">
        <Ellipse.BitmapEffect>
          <DropShadowBitmapEffect Color="Gray" Direction="320" ShadowDepth="25"
                                  Softness="1" Opacity="0.5"/>
        </Ellipse.BitmapEffect>
      </Ellipse>
    </ContentControl>
    <!-- Weather Sun -->
    <ContentControl Width="130" Height="130" Canvas.Top="50" Canvas.Left="300"
                    Template="{StaticResource DragableDesignerItem}">
      <Image IsHitTestVisible="false" Stretch="Fill">
        <Image.Source>
          <DrawingImage Drawing="{StaticResource SunDrawingResource}" />
        </Image.Source>
      </Image>
    </ContentControl>
    <!-- FlowChart PaperTape -->
    <ContentControl Width="130" Height="130" Canvas.Top="250" Canvas.Left="70"
                    Template="{StaticResource DragableDesignerItem}">
      <Path Stroke="Black" Stretch="Fill" StrokeThickness="6"
                    StrokeLineJoin="Round" IsHitTestVisible="False"
                    Data="M 100,200 C 200,180 200,220 300,200 V 300 C 200,320
                    200,280 100,300 Z"/>
    </ContentControl>
    <!-- Star -->
    <ContentControl Width="130" Height="130" Canvas.Top="250" Canvas.Left="530"
                    Template="{StaticResource DragableAndResizableDesignerItem}">
      <Path Stroke="Red" Stretch="Fill" StrokeThickness="8" StrokeLineJoin="Round"
                    IsHitTestVisible="False" Data="M 9,2 11,7 17,7 12,10 14,15 9,12
                    4,15 6,10 1,7 7,7 Z" />
    </ContentControl>
    <!-- Weather Rain -->
    <ContentControl Width="130" Height="130" Canvas.Top="250" Canvas.Left="300"
                    Template="{StaticResource DragableDesignerItem}">
      <Image IsHitTestVisible="false">
        <Image.Source>
          <DrawingImage Drawing="{StaticResource RainDrawingResource}" />
        </Image.Source>
      </Image>
    </ContentControl>
  </Canvas>
</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...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.170813.1 | Last Updated 24 Aug 2008
Article Copyright 2008 by sukram
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid