Skip to main content
Home Forums Silverlight Design Designing with Silverlight sample paint application
8 replies. Latest Post by shijuskpm on October 14, 2008.
(0)
shijuskpm
Member
0 points
5 Posts
10-09-2008 3:52 AM |
I need to create sample paint like application. In the tool bar i have the option for drawing
rectangle ellipse.. i want to resize the rectangle drawn in the canvas when i clicked inside the rectangle.. plese tell me how to do it wth sample code
HarshBar...
Star
9908 points
1,719 Posts
10-09-2008 4:35 AM |
Hi,
For Drawing opption you can check this link.
http://silverlight.net/forums/p/27265/92239.aspx#92239
As far as Drawing Rectangle from Toolbox is Required on Click of toolbox tool you have to capture that info what you are going to draw on Screen and you have to Handle them mouseLeftbuttonDown even,MouseMove event and MouseLeftbutton up event .In these event you have tos et size accordingly of your Control which you are going to draw.
Based on Mouse Cordinates you have to increase and decrease its size.
10-09-2008 4:45 AM |
i need to create hotspot on the rectangle in the canvas how can i generate dynamically?
10-09-2008 7:56 AM |
check this link http://silverlight.net/forums/t/32125.aspx
10-09-2008 8:10 AM |
hi . i have seen that lilnk. that is the way to create hotspot at design time....? i want to create it run time? plese provide the sample code if any
10-09-2008 9:30 AM |
Presently i am not having any such sample code.
But i will suggest you to check how it is creating in Xaml and then use some custom logic according to that in your c# code.
If you are facing any issue please let me know i will try to help you..
damonpayne
304 points
75 Posts
10-12-2008 4:04 PM |
If you take a look at my Visio-esque project here, http://www.damonpayne.com/2008/10/10/RunTimeIsDesignTimeForAGT13.aspx ,
I am drawing Rectangles etc. at runtime on a Designer surface. Code is included with the articles.
10-14-2008 9:51 AM |
hi
u have any URL address regarding this information
bye
10-14-2008 10:00 AM |
Hi
Following XAML code represents the rectangle hotSpot. can u plese send the corresponding run time code(in C#) of this.....
here canvas contains hyperllink control. we are making it as rectangle hotspot by using control template.
<ControlTemplate TargetType="HyperlinkButton"> <Grid Cursor="{TemplateBinding Cursor}"> <Grid.Resources> <Color x:Key="FocusColor">#FF333333</Color> <SolidColorBrush Color="#FF99C3F7" x:Name="HoverColor"/> </Grid.Resources> <vsm:VisualStateManager.VisualStateGroups> <vsm:VisualStateGroup x:Name="CommonStates"> <vsm:VisualState x:Name="Normal"/> </vsm:VisualStateGroup> <vsm:VisualStateGroup x:Name="FocusStates"> <vsm:VisualState x:Name="Focused"> <Storyboard> <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0"> <DiscreteObjectKeyFrame.Value> <Visibility>Visible</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </vsm:VisualState> <vsm:VisualState x:Name="Unfocused"> <Storyboard> <ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="FocusVisual" Storyboard.TargetProperty="Visibility"> <DiscreteObjectKeyFrame KeyTime="0"> <DiscreteObjectKeyFrame.Value> <Visibility>Collapsed</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> </Storyboard> </vsm:VisualState> </vsm:VisualStateGroup> </vsm:VisualStateManager.VisualStateGroups> <Rectangle x:Name="FocusVisual" IsHitTestVisible="false" Visibility="Collapsed" StrokeDashArray=".2 5" StrokeDashCap="Round"> <Rectangle.Stroke> <SolidColorBrush Color="{StaticResource FocusColor}"/> </Rectangle.Stroke> </Rectangle> <ContentPresenter Margin="0,-2,0,0" x:Name="Content" Background="{TemplateBinding Background}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" TextAlignment="{TemplateBinding TextAlignment}" TextDecorations="{TemplateBinding TextDecorations}" TextWrapping="{TemplateBinding TextWrapping}"/> <Rectangle Height="77" HorizontalAlignment="Stretch" Margin="-19,0,-77,-214" VerticalAlignment="Bottom" Fill="#FFFFFFFF" Stroke="#FF000000"/> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White" > <HyperlinkButton Height="16" HorizontalAlignment="Left" Margin="191,44,0,0" Style="{StaticResource HyperlinkButtonStyle1}" VerticalAlignment="Top" Width="118" Content="HyperlinkButton"/> </Grid>