Export (0) Print
Expand All

GuidelineSet Class

Represents a collection of guide lines that can assist in adjusting rendered figures to a device pixel grid.

Namespace:  System.Windows.Media
Assembly:  PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public sealed class GuidelineSet : Animatable
<GuidelineSet .../>

The GuidelineSet type exposes the following members.

  NameDescription
Public methodGuidelineSet()Initializes a new instance of the GuidelineSet class.
Public methodGuidelineSet(Double[], Double[])Initializes a new instance of the GuidelineSet class with the specified GuidelinesX and GuidelinesY values.
Top

  NameDescription
Public propertyCanFreezeGets a value that indicates whether the object can be made unmodifiable. (Inherited from Freezable.)
Public propertyDependencyObjectTypeGets the DependencyObjectType that wraps the CLR type of this instance.  (Inherited from DependencyObject.)
Public propertyDispatcherGets the Dispatcher this DispatcherObject is associated with. (Inherited from DispatcherObject.)
Public propertyGuidelinesXGets or sets a series of coordinate values that represent guide lines on the X-axis.
Public propertyGuidelinesYGets or sets a series of coordinate values that represent guide lines on the Y-axis.
Public propertyHasAnimatedPropertiesGets a value that indicates whether one or more AnimationClock objects is associated with any of this object's dependency properties. (Inherited from Animatable.)
Public propertyIsFrozenGets a value that indicates whether the object is currently modifiable. (Inherited from Freezable.)
Public propertyIsSealedGets a value that indicates whether this instance is currently sealed (read-only). (Inherited from DependencyObject.)
Top

  NameDescription
Public methodApplyAnimationClock(DependencyProperty, AnimationClock)Applies an AnimationClock to the specified DependencyProperty. If the property is already animated, the SnapshotAndReplace handoff behavior is used. (Inherited from Animatable.)
Public methodApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior)Applies an AnimationClock to the specified DependencyProperty. If the property is already animated, the specified HandoffBehavior is used. (Inherited from Animatable.)
Public methodBeginAnimation(DependencyProperty, AnimationTimeline)Applies an animation to the specified DependencyProperty. The animation is started when the next frame is rendered. If the specified property is already animated, the SnapshotAndReplace handoff behavior is used. (Inherited from Animatable.)
Public methodBeginAnimation(DependencyProperty, AnimationTimeline, HandoffBehavior)Applies an animation to the specified DependencyProperty. The animation is started when the next frame is rendered. If the specified property is already animated, the specified HandoffBehavior is used. (Inherited from Animatable.)
Public methodCheckAccessDetermines whether the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Public methodClearValue(DependencyProperty)Clears the local value of a property. The property to be cleared is specified by a DependencyProperty identifier. (Inherited from DependencyObject.)
Public methodClearValue(DependencyPropertyKey)Clears the local value of a read-only property. The property to be cleared is specified by a DependencyPropertyKey. (Inherited from DependencyObject.)
Public methodCloneCreates a modifiable clone of this GuidelineSet, making deep copies of this object's values. When copying dependency properties, this method copies resource references and data bindings (but they might no longer resolve) but not animations or their current values.
Public methodCloneCurrentValueCreates a modifiable clone of this GuidelineSet object, making deep copies of this object's current values. Resource references, data bindings, and animations are not copied, but their current values are.
Public methodCoerceValueCoerces the value of the specified dependency property. This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject. (Inherited from DependencyObject.)
Public methodEqualsDetermines whether a provided DependencyObject is equivalent to the current DependencyObject. (Inherited from DependencyObject.)
Public methodFreeze()Makes the current object unmodifiable and sets its IsFrozen property to true. (Inherited from Freezable.)
Public methodGetAnimationBaseValueReturns the non-animated value of the specified DependencyProperty. (Inherited from Animatable.)
Public methodGetAsFrozenCreates a frozen copy of the Freezable, using base (non-animated) property values. Because the copy is frozen, any frozen sub-objects are copied by reference. (Inherited from Freezable.)
Public methodGetCurrentValueAsFrozenCreates a frozen copy of the Freezable using current property values. Because the copy is frozen, any frozen sub-objects are copied by reference. (Inherited from Freezable.)
Public methodGetHashCodeGets a hash code for this DependencyObject. (Inherited from DependencyObject.)
Public methodGetLocalValueEnumeratorCreates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject. (Inherited from DependencyObject.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodGetValueReturns the current effective value of a dependency property on this instance of a DependencyObject. (Inherited from DependencyObject.)
Public methodInvalidatePropertyRe-evaluates the effective value for the specified dependency property (Inherited from DependencyObject.)
Public methodReadLocalValueReturns the local value of a dependency property, if it exists. (Inherited from DependencyObject.)
Public methodSetCurrentValueSets the value of a dependency property without changing its value source. (Inherited from DependencyObject.)
Public methodSetValue(DependencyProperty, Object)Sets the local value of a dependency property, specified by its dependency property identifier. (Inherited from DependencyObject.)
Public methodSetValue(DependencyPropertyKey, Object)Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property. (Inherited from DependencyObject.)
Protected methodShouldSerializePropertyReturns a value that indicates whether serialization processes should serialize the value for the provided dependency property. (Inherited from DependencyObject.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodVerifyAccessEnforces that the calling thread has access to this DispatcherObject. (Inherited from DispatcherObject.)
Top

  NameDescription
Public eventChangedOccurs when the Freezable or an object it contains is modified. (Inherited from Freezable.)
Top

  NameDescription
Public fieldStatic memberGuidelinesXPropertyIdentifies the GuidelinesX dependency property.
Public fieldStatic memberGuidelinesYPropertyIdentifies the GuidelinesY dependency property.
Top

This example shows how to apply a GuidelineSet to a DrawingGroup.

The DrawingGroup class is the only type of Drawing that has a GuidelineSet property. To apply a GuidelineSet to another type of Drawing, add it to a DrawingGroup and then apply the GuidelineSet to your DrawingGroup.

The following example creates two DrawingGroup objects that are almost identical; the only difference is: the second DrawingGroup has a GuidelineSet and the first does not.

The following illustration shows the output from the example. Because the rendering difference between the two DrawingGroup objects is so subtle, portions of the drawings are enlarged.

A DrawingGroup with and without a GuidelineSet
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace SDKSample
{
    /// <summary> 
    /// This example shows how to apply a GuidelineSet to  
    /// a drawing. 
    /// </summary> 
	public class DrawingGroupGuidelineSetExample : Page
	{
        public DrawingGroupGuidelineSetExample()
        {

            // 
            // Create a DrawingGroup 
            // that has no guideline set 
            //          
            GeometryDrawing drawing1 = new GeometryDrawing(
                    Brushes.Black, 
                    null,
                    new RectangleGeometry(new Rect(0,20,30,80))
                );

            GeometryGroup whiteRectangles = new GeometryGroup();
            whiteRectangles.Children.Add(new RectangleGeometry(new Rect(5.5, 25, 20, 20)));
            whiteRectangles.Children.Add(new RectangleGeometry(new Rect(5.5, 50, 20, 20)));
            whiteRectangles.Children.Add(new RectangleGeometry(new Rect(5.5, 75, 20, 20)));

            GeometryDrawing drawing2 = new GeometryDrawing(
                    Brushes.White,
                    null,
                    whiteRectangles
                );

            // Create a DrawingGroup
            DrawingGroup drawingGroupWithoutGuidelines = new DrawingGroup();
            drawingGroupWithoutGuidelines.Children.Add(drawing1);
            drawingGroupWithoutGuidelines.Children.Add(drawing2);

            // Use an Image control and a DrawingImage to 
            // display the drawing.
            DrawingImage drawingImage01 = new DrawingImage(drawingGroupWithoutGuidelines);

            // Freeze the DrawingImage for performance benefits.
            drawingImage01.Freeze();

            Image image01 = new Image();
            image01.Source = drawingImage01;
            image01.Stretch = Stretch.None;
            image01.HorizontalAlignment = HorizontalAlignment.Left;
            image01.Margin = new Thickness(10);

            // 
            // Create another DrawingGroup and apply  
            // a blur effect to it. 
            // 

            // Create a clone of the first DrawingGroup.
            DrawingGroup drawingGroupWithGuidelines =
                drawingGroupWithoutGuidelines.Clone();

            // Create a guideline set.
            GuidelineSet guidelines = new GuidelineSet();
            guidelines.GuidelinesX.Add(5.5);
            guidelines.GuidelinesX.Add(25.5);
            guidelines.GuidelinesY.Add(25);
            guidelines.GuidelinesY.Add(50);
            guidelines.GuidelinesY.Add(75);

            // Apply it to the drawing group.
            drawingGroupWithGuidelines.GuidelineSet = guidelines; 

            // Use another Image control and DrawingImage 
            // to display the drawing.
            DrawingImage drawingImage02 = new DrawingImage(drawingGroupWithGuidelines);

            // Freeze the DrawingImage for performance benefits.
            drawingImage02.Freeze();

            Image image02 = new Image();
            image02.Source = drawingImage02;
            image02.Stretch = Stretch.None;
            image02.HorizontalAlignment = HorizontalAlignment.Left;
            image02.Margin = new Thickness(50, 10, 10, 10);

            StackPanel mainPanel = new StackPanel();
            mainPanel.Orientation = Orientation.Horizontal;
            mainPanel.HorizontalAlignment = HorizontalAlignment.Left;
            mainPanel.Margin = new Thickness(20);
            mainPanel.Children.Add(image01);
            mainPanel.Children.Add(image02);

            // 
            // Use a DrawingBrush to create a grid background. 
            //
            GeometryDrawing backgroundRectangleDrawing =
                new GeometryDrawing(
                    Brushes.White,
                    null,
                    new RectangleGeometry(new Rect(0,0,1,1))
                );
            PolyLineSegment backgroundLine1 = new PolyLineSegment();
            backgroundLine1.Points.Add(new Point(1, 0));
            backgroundLine1.Points.Add(new Point(1, 0.1));
            backgroundLine1.Points.Add(new Point(0, 0.1));
            PathFigure line1Figure = new PathFigure();
            line1Figure.Segments.Add(backgroundLine1);
            PathGeometry backgroundLine1Geometry = new PathGeometry();
            backgroundLine1Geometry.Figures.Add(line1Figure);
            GeometryDrawing backgroundLineDrawing1 = new GeometryDrawing(
                    new SolidColorBrush(Color.FromArgb(255,204,204,255)),
                    null,
                    backgroundLine1Geometry
                );
            PolyLineSegment backgroundLine2 = new PolyLineSegment();
            backgroundLine2.Points.Add(new Point(0, 1));
            backgroundLine2.Points.Add(new Point(0.1, 1));
            backgroundLine2.Points.Add(new Point(0.1, 0));
            PathFigure line2Figure = new PathFigure();
            line2Figure.Segments.Add(backgroundLine2);
            PathGeometry backgroundLine2Geometry = new PathGeometry();
            backgroundLine2Geometry.Figures.Add(line2Figure);
            GeometryDrawing backgroundLineDrawing2 = new GeometryDrawing(
                    new SolidColorBrush(Color.FromArgb(255, 204, 204, 255)),
                    null,
                    backgroundLine2Geometry
                );

            DrawingGroup backgroundGroup = new DrawingGroup();
            backgroundGroup.Children.Add(backgroundRectangleDrawing);
            backgroundGroup.Children.Add(backgroundLineDrawing1);
            backgroundGroup.Children.Add(backgroundLineDrawing2);

            DrawingBrush gridPatternBrush = new DrawingBrush(backgroundGroup);
            gridPatternBrush.Viewport = new Rect(0, 0, 10, 10);
            gridPatternBrush.ViewportUnits = BrushMappingMode.Absolute;
            gridPatternBrush.TileMode = TileMode.Tile;
            gridPatternBrush.Freeze();

            Border mainBorder = new Border();
            mainBorder.Background = gridPatternBrush;
            mainBorder.BorderThickness = new Thickness(1);
            mainBorder.BorderBrush = Brushes.Gray;
            mainBorder.HorizontalAlignment = HorizontalAlignment.Left;
            mainBorder.VerticalAlignment = VerticalAlignment.Top;
            mainBorder.Margin = new Thickness(20);
            mainBorder.Child = mainPanel;

            // 
            // Add the items to the page. 
            // 
            this.Content = mainBorder;
            this.Background = Brushes.White;

        }


	}
}
<Page 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" 
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="PresentationOptions">
  <Border BorderThickness="1" BorderBrush="Gray" 
    HorizontalAlignment="Left" VerticalAlignment="Top"
    Margin="20">
    <StackPanel Margin="20" Orientation="Horizontal">


        <Image Stretch="None" Margin="10">
          <Image.Source>
            <DrawingImage PresentationOptions:Freeze="True">
              <DrawingImage.Drawing>

                <!-- This DrawingGroup has no GuidelineSet. -->
                <DrawingGroup>
                  <GeometryDrawing Brush="Black">
                    <GeometryDrawing.Geometry>
                      <RectangleGeometry Rect="0,20,30,80" />
                    </GeometryDrawing.Geometry>
                  </GeometryDrawing>
                  <GeometryDrawing Brush="White">
                    <GeometryDrawing.Geometry>
                      <GeometryGroup>
                        <RectangleGeometry Rect="5.5,25, 20,20" />
                        <RectangleGeometry Rect="5.5,50, 20,20" />
                        <RectangleGeometry Rect="5.5,75, 20,20" />
                      </GeometryGroup>
                    </GeometryDrawing.Geometry>
                  </GeometryDrawing>
                </DrawingGroup>
              </DrawingImage.Drawing>
            </DrawingImage>
          </Image.Source>
        </Image>

        <Image Stretch="None" Margin="50,10,10,10">
          <Image.Source>
            <DrawingImage PresentationOptions:Freeze="True">
              <DrawingImage.Drawing>

                <!-- This DrawingGroup has a GuidelineSet. -->
                <DrawingGroup>
                  <GeometryDrawing Brush="Black">
                    <GeometryDrawing.Geometry>
                      <RectangleGeometry Rect="0,20,30,80" />
                    </GeometryDrawing.Geometry>
                  </GeometryDrawing>
                  <GeometryDrawing Brush="White">
                    <GeometryDrawing.Geometry>
                      <GeometryGroup>
                        <RectangleGeometry Rect="5.5,25, 20,20" />
                        <RectangleGeometry Rect="5.5,50, 20,20" />
                        <RectangleGeometry Rect="5.5,75, 20,20" />
                      </GeometryGroup>
                    </GeometryDrawing.Geometry>
                  </GeometryDrawing>
                  <DrawingGroup.GuidelineSet>

                    <!-- The GuidelineSet -->
                    <GuidelineSet
                      GuidelinesX="5.5,25.5" GuidelinesY="25,50,75" />
                  </DrawingGroup.GuidelineSet>
                </DrawingGroup>
              </DrawingImage.Drawing>
            </DrawingImage>
          </Image.Source>
        </Image>
    </StackPanel>

    <Border.Background>
      <DrawingBrush  Viewport="0,0,10,10" ViewportUnits="Absolute" TileMode="Tile"
        PresentationOptions:Freeze="True">
        <DrawingBrush.Drawing>
          <DrawingGroup>
            <GeometryDrawing Brush="White">
              <GeometryDrawing.Geometry>
                <RectangleGeometry Rect="0,0,1,1" />
              </GeometryDrawing.Geometry>
            </GeometryDrawing>
            <GeometryDrawing Geometry="M0,0 L1,0 1,0.1, 0,0.1Z " Brush="#CCCCFF" />
            <GeometryDrawing Geometry="M0,0 L0,1 0.1,1, 0.1,0Z" Brush="#CCCCFF" />
          </DrawingGroup>
        </DrawingBrush.Drawing>
      </DrawingBrush>    
    </Border.Background>
  </Border>
</Page>

.NET Framework

Supported in: 4.6, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft