ASP.Net/WPF/WPF Shapes

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

Ellipse

   <source lang="csharp">

<Canvas Width="510" Height="250"

  xmlns="http://schemas.microsoft.ru/client/2007"
  xmlns:x="http://schemas.microsoft.ru/winfx/2006/xaml">
 <Canvas>
   <Ellipse
     Canvas.Left="5" Canvas.Top="5" Canvas.ZIndex="1"
     Height="200" Width="200"
     Stroke="Black" StrokeThickness="10" Fill="Silver" />
   <Ellipse
     Canvas.Left="50" Canvas.Top="50" Canvas.ZIndex="3"
     Height="200" Width="200"
     Stroke="Black" StrokeThickness="10" Fill="DeepSkyBlue" />
   <Ellipse
     Canvas.Left="95" Canvas.Top="95" Canvas.ZIndex="2"
     Height="200" Width="200"
     Stroke="Black" StrokeThickness="10" Fill="Lime" />
   <Canvas.RenderTransform>
     <TransformGroup>
       <TranslateTransform X="-30" Y="40" />
       <SkewTransform AngleX="15" />
       <ScaleTransform ScaleX="1.5" ScaleY="0.6" />
     </TransformGroup>
   </Canvas.RenderTransform>
 </Canvas>

</Canvas>

</source>
   
  


Ellipse.OpacityMask

   <source lang="csharp">

<Canvas

   xmlns="http://schemas.microsoft.ru/client/2007"
   xmlns:x="http://schemas.microsoft.ru/winfx/2006/xaml"
 Width="200" Height="200">
 <Ellipse
   Canvas.Left="5" Canvas.Top="5" Canvas.ZIndex="1"
   Height="200" Width="200"
   Stroke="Black" StrokeThickness="10" Fill="Silver">
   <Ellipse.OpacityMask>
     <LinearGradientBrush>
       <GradientStop Offset="0.25" Color="#00000000"/>
       <GradientStop Offset="1" Color="#FF000000"/>
     </LinearGradientBrush>
   </Ellipse.OpacityMask>
 </Ellipse>
 <Ellipse
   Canvas.Left="50" Canvas.Top="50" Canvas.ZIndex="3"
   Height="200" Width="200"
   Stroke="Black" StrokeThickness="10">
   <Ellipse.Fill>
     <LinearGradientBrush>
       <GradientStop Offset="0.00" Color="#ffffff"/>
       <GradientStop Offset="1.00" Color="DeepSkyBlue"/>
     </LinearGradientBrush>
   </Ellipse.Fill>    
 </Ellipse>
 <Ellipse
   Canvas.Left="95" Canvas.Top="95" Canvas.ZIndex="2"
   Height="200" Width="200"
   Stroke="Black" StrokeThickness="10" Fill="Lime" />

</Canvas>

</source>
   
  


LinearGradientBrush

   <source lang="csharp">

<Canvas xmlns="http://schemas.microsoft.ru/client/2007">

 <TextBlock Canvas.Left="25" 
            Canvas.Top="10" 
            FontFamily="Verdana" 
        FontSize="32" 
        FontWeight="Bold" 
        Text="ASP.NET">
   <TextBlock.Foreground>
     <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
       <GradientStop Color="Red" Offset="0.0" />
       <GradientStop Color="Orange" Offset="0.2" />
       <GradientStop Color="Yellow" Offset="0.4" />
       <GradientStop Color="Green" Offset="0.6" />
       <GradientStop Color="Blue" Offset="0.8" />
       <GradientStop Color="Violet" Offset="1.0" />
     </LinearGradientBrush>
   </TextBlock.Foreground>
   <TextBlock.RenderTransform>
     <ScaleTransform ScaleY="2.0" />
   </TextBlock.RenderTransform>
   <LineBreak/>
   <Run Foreground="Teal" FontFamily="Verdana" FontSize="24">Core Reference</Run>
   <LineBreak/>
   <Run Foreground="Teal" FontFamily="Verdana" FontSize="18" FontStyle="Italic">Dino Esposito,</Run>
   <Run Foreground="SteelBlue" FontFamily="Verdana" FontSize="18" FontStyle="Italic">Microsoft Press, 2008</Run>
 </TextBlock>

</Canvas>

</source>
   
  


Nested Canvas

   <source lang="csharp">

<Canvas xmlns="http://schemas.microsoft.ru/client/2007"

    xmlns:x="http://schemas.microsoft.ru/winfx/2006/xaml"
  x:Name="rootCanvas">
 <Canvas Canvas.Top="30">
   <Rectangle MouseLeftButtonUp="startDownload"
     x:Name="Button1"
     Canvas.Left="20"
     Height="25" Width="50"
     Fill="Silver" />
   <TextBlock
     Canvas.Top ="5" Canvas.Left="30"
     Text="Add" FontSize="12" />
   
   <Rectangle MouseLeftButtonUp="clearTree"
     x:Name="Button2"
     Canvas.Left="80"
     Height="25" Width="50"
     Fill="Silver" />
   <TextBlock
     Canvas.Top ="5" Canvas.Left="90"
     Text="Clear" FontSize="12" />
 </Canvas>
 <Canvas Canvas.Left="5" Canvas.Top="70">
   <Ellipse Height="200" Width="200"
     Stroke="Black" StrokeThickness="10" Fill="Cyan">
     <Ellipse.OpacityMask>
       <LinearGradientBrush>
         <GradientStop Offset="0.25" Color="#00000000"/>
         <GradientStop Offset="1" Color="#FF000000"/>
       </LinearGradientBrush>
     </Ellipse.OpacityMask>
   </Ellipse>
 </Canvas>
 <Canvas x:Name="insertPoint" Canvas.Left="35" Canvas.Top="120">
 </Canvas>
 <Canvas Canvas.Top="10">
   <Rectangle
     x:Name="progressRectangle"
     Canvas.Left="20"
     Height="10" Width="0"
     Fill="Maroon" />
   <Rectangle
     Canvas.Top ="-1"
     Canvas.Left="19" Height="12"
     Width="202"
     StrokeThickness="1" Stroke="Black" />
   <TextBlock
     x:Name="progressText"
     Canvas.Top ="-4" Canvas.Left="230"
     Text="0%" FontSize="12" />
 </Canvas>

</Canvas>

</source>
   
  


Polyline

   <source lang="csharp">

<Canvas

   xmlns="http://schemas.microsoft.ru/client/2007"
   xmlns:x="http://schemas.microsoft.ru/winfx/2006/xaml"
 Width="300" Height="300">
 <Polyline Points="150, 150 150, 250 250, 250 250, 150"
   Stroke="Gray" StrokeThickness="5"   
   Canvas.ZIndex="3" />
 <Polygon Points="10,10 10,110 110,110 110,10"
   Stroke="Blue" StrokeThickness="10" Fill="LightBlue" />
 <Path Data="M 0,200 L100,200 50,50z"
     Stroke="LightYellow" Fill="Yellow"
     Canvas.Left="150" Canvas.Top="70" />

</Canvas>

</source>
   
  


RectangleGeometry

   <source lang="csharp">

<Canvas Width="300" Height="300"

  xmlns="http://schemas.microsoft.ru/client/2007"
  xmlns:x="http://schemas.microsoft.ru/winfx/2006/xaml">
 <Ellipse Height="200" Width="200" 
      Canvas.Left="30" Canvas.Top="30" Canvas.ZIndex="2"
      Stroke="Black" StrokeThickness="10" Fill="Blue">
   <Ellipse.Clip>
     <RectangleGeometry Rect="0, 0, 100, 100"/>
   </Ellipse.Clip>
 </Ellipse>
 <Ellipse Height="200" Width="200" Canvas.Left="30" Canvas.Top="30"
    Stroke="Black" StrokeThickness="10" Fill="Blue" Opacity="0.3">
 </Ellipse>

</Canvas>

</source>
   
  


Rectangle.RenderTransform

   <source lang="csharp">

<Canvas

 xmlns="http://schemas.microsoft.ru/client/2007"
 xmlns:x="http://schemas.microsoft.ru/winfx/2006/xaml"
 Width="400" Height="300">
 <Rectangle Canvas.Top="40" Fill="Blue" Width="50" Height="50" x:Name="MyRect">
   <Rectangle.RenderTransform>
     <TranslateTransform x:Name="MyAnimatedTranslateTransform"
       X="0" Y="0" />
   </Rectangle.RenderTransform>
   
   <Rectangle.Triggers>
     <EventTrigger RoutedEvent="Rectangle.Loaded">
       <BeginStoryboard>
         <Storyboard>
           <DoubleAnimationUsingKeyFrames
             Storyboard.TargetName="MyAnimatedTranslateTransform"
             Storyboard.TargetProperty="X"
             Duration="0:0:10">
             <LinearDoubleKeyFrame Value="0" KeyTime="0:0:0" />
             <LinearDoubleKeyFrame Value="350" KeyTime="0:0:2" />
             <LinearDoubleKeyFrame Value="50" KeyTime="0:0:7" />
             <LinearDoubleKeyFrame Value="200" KeyTime="0:0:8" />
           </DoubleAnimationUsingKeyFrames>
           <DoubleAnimation 
             Storyboard.TargetName="MyRect"
             Storyboard.TargetProperty="(Width)"
             To="150"
             Duration="0:0:1" />            
         </Storyboard>
       </BeginStoryboard>
     </EventTrigger>
   </Rectangle.Triggers>
 </Rectangle>

</Canvas>

</source>
   
  


TextBlock

   <source lang="csharp">

<Canvas xmlns="http://schemas.microsoft.ru/client/2007"

    xmlns:x="http://schemas.microsoft.ru/winfx/2006/xaml">
   <TextBlock>
       Hello XAML from the Web--#1
   </TextBlock>

</Canvas>

</source>