Skip to main content

Microsoft Silverlight

sample paint applicationRSS Feed

(0)

shijuskpm
shijuskpm

Member

Member

0 points

5 Posts

sample paint application

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

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: sample paint application

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.

Mark as answer if this post answered your question.

Harsh Bardhan

shijuskpm
shijuskpm

Member

Member

0 points

5 Posts

Re: sample paint application

i need to create hotspot on the rectangle in the canvas how can i generate dynamically?

 

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: sample paint application

Hi,

check this link http://silverlight.net/forums/t/32125.aspx

 

Mark as answer if this post answered your question.

Harsh Bardhan

shijuskpm
shijuskpm

Member

Member

0 points

5 Posts

Re: sample paint application

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

 

HarshBardhan
HarshBar...

Star

Star

9908 points

1,719 Posts

Re: sample paint application

Hi,

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..

Mark as answer if this post answered your question.

Harsh Bardhan

damonpayne
damonpayne

Member

Member

304 points

75 Posts

Re: sample paint application

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.

-Damon
http://www.damonpayne.com/

shijuskpm
shijuskpm

Member

Member

0 points

5 Posts

Re: sample paint application

hi

  u have any URL address  regarding this information

 

bye

 

shijuskpm
shijuskpm

Member

Member

0 points

5 Posts

Re: sample paint application

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> 

 

 

 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities