MagnifierDialog Class
The Magnifier that allows users to pick colors from anywhere around the screen.
Namespace: DevExpress.Utils
Assembly: DevExpress.Utils.v24.1.dll
NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core
Declaration
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.
Other overloads allow you to pass the MagnifierDialogArgs object as a parameter to display a pre-customized Magnifier.
- MagnifierDialogArgs.CloseOnMouseClick - specifies whether or not the Magnifier instantly closes after a user has selected a color by clicking the left mouse button;
- MagnifierDialogArgs.InitialZoomFactor - a start-up Magnifier zoom level;
- MagnifierDialogArgs.PickColorToClipboard - specifies whether or not the selected color should be copied to the clipboard;
- MagnifierDialogArgs.ColorFormat - allows you to choose whether the Magnifier displays current and selected colors in RGB or HEX formats. This applies to the UI only, in code, both colors are always stored as ARGB values.
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);
}
The ShowDialog method returns the MagnifierDialogResult type object when the Magnifier closes. This object allows you to retrieve colors.
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;
}