Back to Devexpress

EditingFieldExtensions.RegisterImageCollectionEditorInfo(String, IDictionary<String, Image>, Boolean, Boolean, String) Method

wpf-devexpress-dot-xpf-dot-printing-dot-editingfieldextensions-dot-registerimagecollectioneditorinfo-x28-string-idictionary-string-image-boolean-boolean-string-x29.md

latest6.1 KB
Original Source

EditingFieldExtensions.RegisterImageCollectionEditorInfo(String, IDictionary<String, Image>, Boolean, Boolean, String) Method

Registers an image editor with a filterable collection of predefined named images to be used for changing image content in Print Preview.

Namespace : DevExpress.Xpf.Printing

Assembly : DevExpress.Xpf.Printing.v25.2.dll

NuGet Package : DevExpress.Wpf.Printing

Declaration

csharp
public bool RegisterImageCollectionEditorInfo(
    string editorName,
    IDictionary<string, Image> images,
    bool searchEnabled = true,
    bool sizeOptionsEnabled = false,
    string displayName = null
)
vb
Public Function RegisterImageCollectionEditorInfo(
    editorName As String,
    images As IDictionary(Of String, Image),
    searchEnabled As Boolean = True,
    sizeOptionsEnabled As Boolean = False,
    displayName As String = Nothing
) As Boolean

Parameters

NameTypeDescription
editorNameString

The name of the registered image collection editor.

| | images | IDictionary<String, Image> |

The editor’s image collection.

|

Optional Parameters

NameTypeDefaultDescription
searchEnabledBooleanTrue

true, if the editor allows end users to filter the predefined image collection; otherwise, false.

| | sizeOptionsEnabled | Boolean | False |

true, if the editor allows end users to specify image size options; otherwise, false.

| | displayName | String | null |

The display name of the registered image collection editor.

|

Returns

TypeDescription
Boolean

true, if the image list has been successfully registered; otherwise, false.

|

Remarks

Use this method to register an image editor with a collection of predefined images in the application.

csharp
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using DevExpress.Xpf.Printing;
//...
Dictionary<string, Image> images = new Dictionary<string, Image>();
foreach (var file in Directory.GetFiles("../../Flags/", "*.png")) {
    Image img = Image.FromFile(file);
    if (img != null) {
        string name = Path.GetFileNameWithoutExtension(file);
        images.Add(name, img);
    }
}
EditingFieldExtensions.Instance.RegisterImageCollectionEditorInfo("Nationality", images, true, false, "Nationality");
vb
Imports System.Collections.Generic
Imports System.Drawing
Imports System.IO
Imports DevExpress.Xpf.Printing
'...
Dim images As New Dictionary(Of String, Image)()
For Each file In Directory.GetFiles("../../Flags/", "*.png")
    Dim img As Image = Image.FromFile(file)
    If img IsNot Nothing Then
        Dim name As String = Path.GetFileNameWithoutExtension(file)
        images.Add(name, img)
    End If
Next file
EditingFieldExtensions.Instance.RegisterImageCollectionEditorInfo("Nationality", images, True, False, "Nationality")

To use this editor for image editing in Print Preview, set a XRPictureBox control’s EditOptions | Enabled property to true and the EditOptions | EditorName property - to the registered editor’s name.

Set image edit options in the End-User Report Designer’s Properties window.

The following sample demonstrates how to do this in code.

csharp
using DevExpress.XtraReports.UI;
//...
XtraReport1 report = new XtraReport1();
XRPictureBox pictureBox = report.Bands["ReportHeader"].FindControl("xrPictureBox1", true) as XRPictureBox;
pictureBox.EditOptions.Enabled = true;
pictureBox.EditOptions.EditorName = "Nationality";
vb
Imports DevExpress.XtraReports.UI
'...
Private report As New XtraReport1()
Private pictureBox As XRPictureBox = TryCast(report.Bands("ReportHeader").FindControl("xrPictureBox1", True), XRPictureBox)
pictureBox.EditOptions.Enabled = True
pictureBox.EditOptions.EditorName = "Nationality"

When an end user clicks the Picture Box in Print Preview, the assigned editor activates. This editor allows end users to choose a predefined image or reset to the initial image.

Note

Use the RegisterImageEditorInfo(String, ImageEditorOptions, String) method instead if you need to add the Brush Options and/or Load Image menu items as well.

See Also

EditingFieldExtensions Class

EditingFieldExtensions Members

DevExpress.Xpf.Printing Namespace