Use a PathGeometry object to highlight displayed text. : Geometry « Windows Presentation Foundation « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Windows Presentation Foundation » GeometryScreenshots 
Use a PathGeometry object to highlight displayed text.
Use a PathGeometry object to highlight displayed text.
       

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="WpfApplication1.Window1"
  Title="Using a Path Geometry to Highlight Text"
  Background="PowderBlue">

  <StackPanel>
      <Button Margin="10" Grid.Column="2" Grid.Row="0" FontSize="16" Click="OnDisplayTextClick">Display Text</Button>
    <Canvas Margin="20" Height="150">
      <Path Canvas.Top="15" Canvas.Left="15" Stroke="SteelBlue" StrokeThickness="3" Fill="LightSteelBlue" Name="path" />
      <Ellipse Canvas.Top="0" Canvas.Left="0" Width="30" Height="30">
        <Ellipse.Fill>
          <RadialGradientBrush GradientOrigin="0.5,0.5" Center="0.5,0.5" RadiusX="0.5" RadiusY="0.5">
            <RadialGradientBrush.GradientStops>
              <GradientStop Color="Yellow" Offset="0.25" />
              <GradientStop Color="Transparent" Offset="1" />
            </RadialGradientBrush.GradientStops>
          </RadialGradientBrush>
        </Ellipse.Fill>

        <Ellipse.RenderTransform>
          <MatrixTransform />
        </Ellipse.RenderTransform>
        <Ellipse.Triggers>
          <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <EventTrigger.Actions>
            <BeginStoryboard>
              <Storyboard x:Name="storyboard">
                <MatrixAnimationUsingPath 
                  x:Name="matrixAnimation"
                  Duration="0:00:40"
                  RepeatBehavior="Forever"
                  Storyboard.TargetProperty="RenderTransform.Matrix" />
              </Storyboard>
            </BeginStoryboard>
            </EventTrigger.Actions>
          </EventTrigger>
        </Ellipse.Triggers>
      </Ellipse>
    </Canvas>
  </StackPanel>
</Window>

//File:Window.xaml.vb

Imports System
Imports System.Globalization
Imports System.Windows
Imports System.Windows.Media

Namespace WpfApplication1
  Public Partial Class Window1
    Inherits Window
    Public Sub New()
      InitializeComponent()
    End Sub

    Public Sub OnDisplayTextClick(sender As Object, e As EventArgs)
      Dim formattedText As New FormattedText("asdf", CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, New Typeface("Verdana")96, Brushes.Black)

      formattedText.SetFontWeight(FontWeights.Bold)

      Dim geometry As Geometry = formattedText.BuildGeometry(New Point(00))

      Dim pathGeometry As PathGeometry = geometry.GetFlattenedPathGeometry()

      path.Data = pathGeometry

      matrixAnimation.PathGeometry = pathGeometry
    End Sub
  End Class
End Namespace

   
    
    
    
    
    
    
  
Related examples in the same category
1.GeometryCombineMode = UnionGeometryCombineMode = Union
2.GeometryCombineMode = IntersectGeometryCombineMode = Intersect
3.GeometryCombineMode = XorGeometryCombineMode = Xor
4.GeometryCombineMode = ExcludeGeometryCombineMode = Exclude
5.Combine two circles into one shape using CombinedGeometry: UnionCombine two circles into one shape using CombinedGeometry: Union
6.Combine two circles into one shape using CombinedGeometry: XorCombine two circles into one shape using CombinedGeometry: Xor
7.Combine two circles into one shape using CombinedGeometry: IntersectCombine two circles into one shape using CombinedGeometry: Intersect
8.Combine two circles into one shape using CombinedGeometry: ExcludeCombine two circles into one shape using CombinedGeometry: Exclude
9.Combine GeometryCombine Geometry
10.LineGeometry for PathLineGeometry for Path
11.EllipseGeometry for PathEllipseGeometry for Path
12.BezierSegment for a PathBezierSegment for a Path
13.Put EllipseGeometry to GeometryGroupPut EllipseGeometry to GeometryGroup
14.Put RectangleGeometry to GeometryGroupPut RectangleGeometry to GeometryGroup
15.Path based on GeometryGroup ResourcePath based on GeometryGroup Resource
16.GeometryDrawing.BrushGeometryDrawing.Brush
17.GeometryDrawing.PenGeometryDrawing.Pen
18.GeometryDrawing with 2 PathFiguresGeometryDrawing with 2 PathFigures
19.GeometryGroup and DrawingImageGeometryGroup and DrawingImage
20.GeometryDrawing insize a DrawingGroupGeometryDrawing insize a DrawingGroup
21.Use the StreamGeometry mini-language to create polylineUse the StreamGeometry mini-language to create polyline
22.Create a PathGeometry using the PathFigureCollection mini-language.Create a PathGeometry using the PathFigureCollection mini-language.
23.PolyLineSegment creates a series of straight lines.PolyLineSegment creates a series of straight lines.
24.LineGeometry vs LineLineGeometry vs Line
25.RectangleGeometry vs RectangleRectangleGeometry vs Rectangle
26.EllipseGeometry vs Ellipse
27.Combine geometries is to use the GeometryGroup objectCombine geometries is to use the GeometryGroup object
28.Geometry GroupGeometry Group
29.GeometryDrawing Pen and GeometryGeometryDrawing Pen and Geometry
30.CombinedGeometry GeometryCombineMode="Union"CombinedGeometry GeometryCombineMode=
31.Reusing GeometryReusing Geometry
32.Converting text to geometryConverting text to geometry
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.