Back to Devexpress

MagnifierDialog Class

windowsforms-devexpress-dot-utils-573ab1ab.md

latest4.8 KB
Original Source

MagnifierDialog Class

The Magnifier that allows users to pick colors from anywhere around the screen.

Namespace : DevExpress.Utils

Assembly : DevExpress.Utils.v25.2.dll

NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core

Declaration

csharp
public static class MagnifierDialog
vb
Public Module MagnifierDialog

Remarks

The MagnifierDialog class allows you to utilize the Magnifier from the WinForms Skin Editor as a stand-alone tool.

End-users can use the mouse scroll wheel to zoom in and out. To copy the hovered color to the clipboard, click the left mouse button. The right button and the “Esc” key close the Magnifier.

To invoke the Magnifier, call its MagnifierDialog.ShowDialog method. When used without parameters, the method invokes the Magnifier with default settings.

csharp
MagnifierDialog.ShowDialog();
vb
MagnifierDialog.ShowDialog()

Other overloads allow you to pass the MagnifierDialogArgs object as a parameter to display a pre-customized Magnifier.

csharp
private void simpleButton2_Click(object sender, EventArgs e) {
    MagnifierDialogArgs args = new MagnifierDialogArgs() {
        CloseOnMouseClick = false,
        InitialZoomFactor = 1.25f,
        PickColorToClipboard = false,
        ColorFormat = ColorFormat.Hex
    };
    MagnifierDialogResult result = MagnifierDialog.ShowDialog(this, args);
}
vb
Private Sub simpleButton2_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim args As New MagnifierDialogArgs() With {
        .CloseOnMouseClick = False,
        .InitialZoomFactor = 1.25F,
        .PickColorToClipboard = False,
        .ColorFormat = ColorFormat.Hex }
    Dim result As MagnifierDialogResult = MagnifierDialog.ShowDialog(Me, args)
End Sub

The ShowDialog method returns the MagnifierDialogResult type object when the Magnifier closes. This object allows you to retrieve colors.

csharp
private void simpleButton1_Click(object sender, EventArgs e) {
     MagnifierDialogResult result = MagnifierDialog.ShowDialog();
     //the last color under the Magnifier crosshair
     Color hover = result.HoverColor;
     //the color a user has chosen (left mouse click)
     Color? selected = result.SelectedColor;
     //the last remembered zoom factor (use the scroll wheel to zoom in and out)
     float zoom = result.ZoomFactor;
 }
vb
Private Sub simpleButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
     Dim result As MagnifierDialogResult = MagnifierDialog.ShowDialog()
     'the last color under the Magnifier crosshair
     Dim hover As Color = result.HoverColor
     'the color a user has chosen (left mouse click)
     Dim selected? As Color = result.SelectedColor
     'the last remembered zoom factor (use the scroll wheel to zoom in and out)
     Dim zoom As Single = result.ZoomFactor
 End Sub

Inheritance

Object MagnifierDialog

See Also

MagnifierDialog Members

DevExpress.Utils Namespace