Class Magnifier
Represents the Magnifier control. Magnifier is used to zoom the visual elements on the screen and enables to view the objects closely. It contains the zoomed image of the area around the mouse pointer.
Inheritance
Namespace: Syncfusion.Windows.Shared
Assembly: Syncfusion.Shared.Wpf.dll
Syntax
public class Magnifier : Control
Remarks
In XAML code Magnifier.Current attached property plays the same role as Magnifier.TargetElement property in procedural code. There is no need to set TargetElement value in XAML under <Magnifier.Current> definition.
Examples
This example shows how to create the Magnifier control in XAML.
<Window x:Class="MagnifierDemo.SampleWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shared="clr-namespace:Syncfusion.Windows.Shared;assembly=Syncfusion.Shared.WPF"/>
<Grid Name="grid">
<shared:Magnifier.Current>
<shared:Magnifier ZoomFactor="0.5" FrameBackground="White"/>
</shared:Magnifier.Current>
</Grid>
</Window>
This example shows how to the Magnifier control in C#.
using System;
using System.Windows;
using Syncfusion.Windows.Shared;
namespace MagnifierDemo
{
public partial class SampleWindow : Window
{
internal System.Windows.Controls.Grid grid;
private Magnifier magnifier = new Magnifier();
public SampleWindow()
{
magnifier.TargetElement = grid;
magnifier.FrameBackground = Brushes.White;
magnifier.ZoomFactor = 0.5;
}
}
}
Constructors
Magnifier()
Initializes a new instance of the Magnifier class.
Declaration
public Magnifier()
Fields
ActualTargetElementProperty
Identifies the Syncfusion.Windows.Shared.Magnifier.ActualTargetElement dependency property.
Declaration
public static readonly DependencyProperty ActualTargetElementProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
BackgroundHeightProperty
Identifies the Syncfusion.Windows.Shared.Magnifier.BackgroundHeight dependency property.
Declaration
public static readonly DependencyProperty BackgroundHeightProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
BackgroundWidthProperty
Identifies the Syncfusion.Windows.Shared.Magnifier.BackgroundWidth dependency property.
Declaration
public static readonly DependencyProperty BackgroundWidthProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
CurrentProperty
Identifies the Magnifier.Current attached dependency property.
Declaration
public static readonly DependencyProperty CurrentProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
EnableExportProperty
Identifies the EnableExport dependency property.
Declaration
public static readonly DependencyProperty EnableExportProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
FrameBackgroundProperty
Identifies the FrameBackground dependency property.
Declaration
public static readonly DependencyProperty FrameBackgroundProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
FrameCornerRadiusProperty
Identifies the FrameCornerRadius dependency property.
Declaration
public static readonly DependencyProperty FrameCornerRadiusProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
FrameHeightProperty
Identifies the FrameHeight dependency property.
Declaration
public static readonly DependencyProperty FrameHeightProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
FrameRadiusProperty
Identifies the FrameRadius dependency property.
Declaration
public static readonly DependencyProperty FrameRadiusProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
FrameTypeProperty
Identifies the FrameType dependency property.
Declaration
public static readonly DependencyProperty FrameTypeProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
FrameWidthProperty
Identifies the FrameWidth dependency property.
Declaration
public static readonly DependencyProperty FrameWidthProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
TargetElementProperty
Identifies the TargetElement dependency property.
Declaration
public static readonly DependencyProperty TargetElementProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
ViewboxProperty
Identifies the Syncfusion.Windows.Shared.Magnifier.Viewbox dependency property.
Declaration
public static readonly DependencyProperty ViewboxProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
ZoomFactorProperty
Identifies the ZoomFactor dependency property.
Declaration
public static readonly DependencyProperty ZoomFactorProperty
Field Value
Type |
---|
System.Windows.DependencyProperty |
Properties
EnableExport
Gets or sets a value indicating whether [enable export].
Declaration
public bool EnableExport { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
FrameBackground
Gets or sets the value specifying background brush of the frame.
Declaration
public Brush FrameBackground { get; set; }
Property Value
Type | Description |
---|---|
System.Windows.Media.Brush | Type: System.Windows.Media.Brush. Default value is transparent brush. |
FrameCornerRadius
Gets or sets the value specifying the corner radius when the FrameLayout is RoundedRectangle.
Declaration
public double FrameCornerRadius { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Type: System.Double. Default value is 5. |
FrameHeight
Gets or sets the value specifying height of the frame when the FrameLayout is Rectangle or Rounded Rectangle.
Declaration
public double FrameHeight { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Type: System.Double. Default value is 200. |
FrameRadius
Gets or sets the value specifying the radius of the circle when the FrameLayout is Circle.
Declaration
public double FrameRadius { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Type: System.Double. Default value is 100. |
FrameType
Gets or sets the value specifying the shape of frame in the Magnifier.
Declaration
public FrameType FrameType { get; set; }
Property Value
Type | Description |
---|---|
FrameType | Type: FrameType enum. Default value is Rectangle. |
See Also
FrameWidth
Gets or sets the value specifying width of the frame when the FrameLayout is Rectangle or Rounded Rectangle.
Declaration
public double FrameWidth { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Type: System.Double. Default value is 200. |
TargetElement
Gets or sets UIElement available for magnifying.
Declaration
public UIElement TargetElement { get; set; }
Property Value
Type | Description |
---|---|
System.Windows.UIElement | Type: System.Windows.UIElement. Default value is null. |
Remarks
Null value means that the magnifier is inactive.
ZoomFactor
Gets or sets the value indicating relative size of the area displayed inside Magnifier. This determines zoom level. The value range is between 0.0 (infinite zoom) and 1.0 (no zoom).
Declaration
public double ZoomFactor { get; set; }
Property Value
Type | Description |
---|---|
System.Double | Type: System.Double. Default value is 1.0. |
Remarks
When user is setting value greater than 1.0, ZoomFactor will equal to 1.0, in case of value less than zero ZoomFactor will be equal zero.
Methods
AssociateWith(UIElement)
Attaches the Magnifier to the UIElement specified in the parameter and receives ability to zoom it with all visual children.
Declaration
public void AssociateWith(UIElement target)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.UIElement | target | The System.Windows.UIElement which the Magnifier has ability to zoom. |
CoerceTargetElement(Object)
Fulfils the logic before setting the value of TargetElement dependency property.
Declaration
protected virtual object CoerceTargetElement(object baseValue)
Parameters
Type | Name | Description |
---|---|---|
System.Object | baseValue | The value that should be corrected. |
Returns
Type | Description |
---|---|
System.Object | Corrected value. |
CoerceZoomFactor(Object)
Fulfils the logic before setting the value of ZoomFactor dependency property.
Declaration
protected virtual object CoerceZoomFactor(object baseValue)
Parameters
Type | Name | Description |
---|---|---|
System.Object | baseValue | The value that should be corrected. |
Returns
Type | Description |
---|---|
System.Object | Corrected value. |
CopyToClipboard()
Copies the content of the Magnifier to clipboard.
Declaration
public void CopyToClipboard()
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Magnifier area cannot be retrieved. |
GetCurrent(DependencyObject)
Gets value of the Magnifier.Current attached property.
Declaration
public static Magnifier GetCurrent(DependencyObject d)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | d | The d control. |
Returns
Type | Description |
---|---|
Magnifier | Return the current control |
OnEnableExportChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises EnableExportChanged event.
Declaration
protected virtual void OnEnableExportChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property change details, such as old value and new value. |
OnFrameBackgroundChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises FrameBackgroundChanged event.
Declaration
protected virtual void OnFrameBackgroundChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property change details, such as old value and new value. |
OnFrameCornerRadiusChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises FrameCornerRadiusChanged event.
Declaration
protected virtual void OnFrameCornerRadiusChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property change details, such as old value and new value. |
OnFrameHeightChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises FrameHeightChanged event.
Declaration
protected virtual void OnFrameHeightChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property change details, such as old value and new value. |
OnFrameRadiusChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises FrameRadiusChanged event.
Declaration
protected virtual void OnFrameRadiusChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property change details, such as old value and new value. |
OnFrameTypeChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises FrameTypeChanged event.
Declaration
protected virtual void OnFrameTypeChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property change details, such as old value and new value. |
OnFrameWidthChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises FrameWidthChanged event.
Declaration
protected virtual void OnFrameWidthChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property change details, such as old value and new value. |
OnTargetElementChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises TargetElementChanged event.
Declaration
protected virtual void OnTargetElementChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property change details, such as old value and new value. |
OnVisualParentChanged(DependencyObject)
Override Executes when visual parent of Magnifier has changed.
Declaration
protected override void OnVisualParentChanged(DependencyObject oldParent)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | oldParent | Determines old parent of the control. Not used. |
OnZoomFactorChanged(DependencyPropertyChangedEventArgs)
Updates property value cache and raises ZoomFactorChanged event.
Declaration
protected virtual void OnZoomFactorChanged(DependencyPropertyChangedEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyPropertyChangedEventArgs | e | Property change details, such as old value and new value. |
Save(Stream)
Saves content of the Magnifier to the specified stream.
Declaration
public void Save(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream. |
Save(Stream, BitmapEncoder)
Saves content of the Magnifier to the specified stream.
Declaration
public void Save(Stream stream, BitmapEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream. |
System.Windows.Media.Imaging.BitmapEncoder | encoder | The encoder. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Magnifier area cannot be retrieved. |
Save(String)
Saves content of the Magnifier to the file with specified filename.
Declaration
public void Save(string fileName)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | The filename. |
Save(String, BitmapEncoder)
Saves content of the Magnifier to the file with specified filename using encoder.
Declaration
public void Save(string fileName, BitmapEncoder encoder)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileName | The fileName. |
System.Windows.Media.Imaging.BitmapEncoder | encoder | The encoder. |
SaveToXps(Stream)
Saves content of the Magnifier to XPS format.
Declaration
public void SaveToXps(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream. |
SaveToXps(String)
Saves content of the Magnifier to XPS format.
Declaration
public void SaveToXps(string filename)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | The filename. |
SetCurrent(DependencyObject, Magnifier)
Sets value of the Magnifier.Current attached property.
Declaration
public static void SetCurrent(DependencyObject d, Magnifier magnifier)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.DependencyObject | d | The d control. |
Magnifier | magnifier | The magnifier. |
ZoomIn(Double)
Zooms in the area around the mouse pointer with the factor mentioned as the parameter.
Declaration
public void ZoomIn(double zoomFactor)
Parameters
Type | Name | Description |
---|---|---|
System.Double | zoomFactor | Factor to zoom in. |
ZoomOut(Double)
Zooms out the area around the mouse pointer with the factor mentioned as the parameter.
Declaration
public void ZoomOut(double zoomFactor)
Parameters
Type | Name | Description |
---|---|---|
System.Double | zoomFactor | Factor to zoom out. |
Events
EnableExportChanged
Event that is raised when EnableExport property is changed.
Declaration
public event PropertyChangedCallback EnableExportChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
FrameBackgroundChanged
Event that is raised when FrameBackground property is changed.
Declaration
public event PropertyChangedCallback FrameBackgroundChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
FrameCornerRadiusChanged
Event that is raised when FrameCornerRadius property is changed.
Declaration
public event PropertyChangedCallback FrameCornerRadiusChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
FrameHeightChanged
Event that is raised when FrameHeight property is changed.
Declaration
public event PropertyChangedCallback FrameHeightChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
FrameRadiusChanged
Event that is raised when FrameRadius property is changed.
Declaration
public event PropertyChangedCallback FrameRadiusChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
FrameTypeChanged
Event that is raised when FrameType property is changed.
Declaration
public event PropertyChangedCallback FrameTypeChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
FrameWidthChanged
Event that is raised when FrameWidth property is changed.
Declaration
public event PropertyChangedCallback FrameWidthChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
TargetElementChanged
Event that is raised when TargetElement property is changed.
Declaration
public event PropertyChangedCallback TargetElementChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |
TargetElementChanging
Event that is raised when TargetElement property is being changed.
Declaration
protected event CoerceValueCallback TargetElementChanging
Event Type
Type |
---|
System.Windows.CoerceValueCallback |
ZoomFactorChanged
Event that is raised when ZoomFactor property is changed.
Declaration
public event PropertyChangedCallback ZoomFactorChanged
Event Type
Type |
---|
System.Windows.PropertyChangedCallback |