Quantcast
Channel: Developer Express Inc.
Viewing all articles
Browse latest Browse all 2389

Office-Inspired Controls (WinForms & WPF) — Early Access Preview (v24.2) — AI-Powered Behaviors and Accessibility Enhancements

$
0
0

We are excited to introduce a set of new, powerful features coming to DevExpress Rich Text Editor and Spreadsheet Control for WinForms and WPF. This post outlines what’s inside our current Early Access Preview build v24.2, which is now available for download for our Universal and DXperience subscribers.

Early Access and CTP builds are provided solely for early testing purposes and are not ready for production use. This build can be installed side by side with other major versions of DevExpress products. Please back up your project and other important data before installing Early Access and CTP builds. This EAP may not include all features/products we expect to ship in our v24.2 release cycle. As its name implies, the EAP offers an early preview of what we expect to ship in two months.

For additional information on what you can expect, please refer to our v24.2 roadmap.

Important Changes in v24.2

.NET 9 Support

The DevExpress WinForms and WPF product lines now support NET 9 RC1 .

.NET Framework 4.6.2 and .NET 8 Support

With this release, minimally supported framework and IDE versions will be as follows:

  • .NET 4.6.2
  • .NET 8
  • Visual Studio 2019

Learn more about this global change in the following announcement: .NET — .NET 8 and .NET Framework 4.6.2 Are Minimally Supported Target Frameworks for DevExpress Libraries in v24.2

AI-Powered Behaviors in Rich Text and Spreadsheet Editors for WinForms and WPF

In v24.2, we introduce several built-in AI behaviors that integrate seamlessly into our DevExpress WinForms and WPF visual controls. In previous blog post (DevExpress AI-Powered Extensions — Extending Text Editors with AI Capabilities — Early Access Preview (v24.2)), we outlined the potential of these AI-driven features. Here, we dive deeper into how they enhance desktop Rich Text and Spreadsheet controls.

AI Behaviors in User Interface

The DevExpress AI behaviors for Rich Edit and Spreadsheet controls offer diverse capabilities for modifying, analyzing, and improving content within Word and Excel documents. Below are some of the key actions available in the controls’ User Interface:

AI Behavior NameSupported ControlDescription
ExpandRich EditExpands document text and adds more detail or context (making it more comprehensive).
ShortenRich EditShortens document text to the key points while retaining clarity.
SummarizeRich Edit, SpreadsheetCondenses the document content or cell text into a brief summary of key information.
ExplainRich Edit, SpreadsheetGenerates an explanation or clarification of document text or cell text, enhancing understanding.
Tone StyleRich EditChanges the tone of document text.
ProofreadRich Edit, Spreadsheet

Checks document text or cell text for grammar, spelling, and punctuation errors, and offers corrections.
Note: Rich Edit offers the proofread text in a separate dialog; Spreadsheet replaces cell values with proofread text on a fly.

Rewrite StyleRich EditRewrites document text to match a new style or flow (making it suitable for different contexts).
TranslateRich Edit, Spreadsheet

Translates document text or cell range into another language chosen by the user.
Note: Rich Edit displays the translated text in a separate dialog; Spreadsheet replaces cell values with translated text on a fly.

Custom RequestRich EditSends a custom request to the AI for specific tasks and receives a response with new content / modified data.
Generate DescriptionRich Edit, SpreadsheetGenerates a description or Alt Text for the selected image within a document or worksheet.
Explain FormulaSpreadsheetGenerates a detailed explanation of the formula used in the selected worksheet cell (clarifying its purpose and function).


Each AI behavior can be individually integrated in the Rich Text or Spreadsheet Control, giving you flexibility in enhancing control’s capabilities based on your usage scenario. Once a behavior is added to the Rich Text or Spreadsheet Control and the AI service registration is complete, the new "AI Text Transform" submenu becomes available in the control’s context menu during runtime. AI-related menu options are context-dependent and become enabled only when the relevant document content (paragraphs with text, worksheet cells or document graphics) is selected.


Almost all AI behaviors (except for specific Spreadsheet behaviors listed in the table above) do not modify your document directly. Instead, they open a special dialog which contains the result of the AI service’s request, offering users control over the output.
In these dialogs, users can write their own requests to AI services, review the AI-generated content/response, modify it as needed, copy the generated data to the Clipboard, and choose whether to discard changes or insert/replace data in the document.

Here is an example of such an AI dialog:

Integrating AI Behaviors in Rich Text and Spreadsheet Applications

In this section, we will describe the required steps to enable DevExpress AI-Powered features in DevExpress Rich Text Editor and Spreadsheet Control for WinForms and WPF platforms.

Prerequisites

To get started, you need to meet the following prerequisites:

Installing NuGet Packages and Registering AI Service

  • Add the following NuGet packages to your application:
    • DevExpress.AIIntegration.Azure.OpenAI or DevExpress.AIIntegration.OpenAI
    • DevExpress.AIIntegration.Desktop
    • DevExpress.AIIntegration.WinForms or DevExpress.AIIntegration.WPF
  • Register AI services using your personal service credentials and the default extensions container AIExtensionsContainerDesktop.Default:
AIExtensionsContainerDesktop.Default.RegisterChatClientOpenAIService(
    new AzureOpenAIClient(
        new Uri(azureOpenAIEndpoint), 
        new System.ClientModel.ApiKeyCredential(azureOpenAIKey)),
    deploymentName);

Adding AI Behaviors in a WinForms Application

In Visual Studio, open the Toolbox window, locate the BehaviorManager component and drag and drop it onto the form. Then, access its smart tag and click “Edit Behaviors”.

TIP: You can also click the “Register AI-Powered Behaviors” option in the BehaviorManager smart-tag to automatically reference required NuGet packages/assemblies.

In the BehaviorManager’s Collection Editor, click the “Add Snap Windows Behavior” button, expand the “AI-Powered Behaviors” submenu and choose the behavior you would like to add in your application. Once complete, the behavior will be associated with a suitable control. You may change the behavior target (associated control) at design time as you require.


It’s also possible to attach behaviors to Rich Text and Spreadsheet Control in code. Use the BehaviorManager.Attach method as follows:

using DevExpress.AIIntegration.Desktop;
using DevExpress.AIIntegration.WinForms;

// Register RichEditControl's behaviors
behaviorManager.Attach<SummarizeBehavior>(richEditControl, behaviorSettings => behaviorSettings.Properties.SummarizationMode = DevExpress.AIIntegration.SummarizeBehaviorMode.Abstractive);
behaviorManager.Attach<ExplainBehavior>(richEditControl);
behaviorManager.Attach<ShortenBehavior>(richEditControl);
behaviorManager.Attach<ExpandBehavior>(richEditControl);
behaviorManager.Attach<ToneStyleBehavior>(richEditControl);
behaviorManager.Attach<ProofreadBehavior>(richEditControl);
behaviorManager.Attach<RewriteStyleBehavior>(richEditControl);
behaviorManager.Attach<CustomRequestBehavior>(richEditControl);
behaviorManager.Attach<TranslateBehavior>(richEditControl, behaviorSettings => behaviorSettings.Properties.Languages = new LanguageInfo[] {
                 new LanguageInfo("de-DE"), new LanguageInfo("fr-FR")
            });;
behaviorManager.Attach<GenerateDescriptionBehavior>(richEditControl);

// Register SpreadsheetControl's behaviors
behaviorManager.Attach<SummarizeBehavior>(spreadsheetControl, behaviorSettings => behaviorSettings.Properties.SummarizationMode = DevExpress.AIIntegration.SummarizeBehaviorMode.Abstractive);
behaviorManager.Attach<ExplainBehavior>(spreadsheetControl);
behaviorManager.Attach<ProofreadBehavior>(spreadsheetControl);
behaviorManager.Attach<TranslateBehavior>(spreadsheetControl, behaviorSettings => behaviorSettings.Properties.Languages = new LanguageInfo[] {
                 new LanguageInfo("de-DE"), new LanguageInfo("fr-FR")
            });
behaviorManager.Attach<GenerateDescriptionBehavior>(spreadsheetControl);
behaviorManager.Attach<FormulaExplanationBehavior>(spreadsheetControl);

Note that some behaviors may require additional setup. For example, the Translate behavior requires that you add supported languages in the behavior’s Languages collection. Otherwise, the Translate option will be disabled.

Adding AI Behaviors in a WPF Application

To enable AI capabilities for Rich Text Editor and Spreadsheet Control in a WPF application, define DevExpress.AIIntegration.Wpf.Office and DevExpress.AIIntegration.Desktop namespaces in XAML. Then, add the required behaviors to the Interaction.Behaviors collection.

The following code snippet shows how to add all supported AI behaviors for WPF Rich Text Editor:

xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxre="http://schemas.devexpress.com/winfx/2008/xaml/richedit" 
xmlns:wpfo="clr-namespace:DevExpress.AIIntegration.Wpf.Office;assembly=DevExpress.AIIntegration.Wpf.v24.2"
xmlns:desktop="clr-namespace:DevExpress.AIIntegration.Desktop;assembly=DevExpress.AIIntegration.Desktop.v24.2"

<dxre:RichEditControl x:Name="richEditControl" CommandBarStyle="Ribbon">
    <dxmvvm:Interaction.Behaviors>
        <wpfo:RichEditExpandBehavior />
        <wpfo:RichEditShortenBehavior />
        <wpfo:RichEditSummarizeBehavior />
        <wpfo:RichEditExplainBehavior />
        <wpfo:RichEditToneStyleBehavior />
        <wpfo:RichEditProofreadBehavior />
        <wpfo:RichEditRewriteStyleBehavior />
        <wpfo:RichEditTranslateBehavior >
            <desktop:LanguageInfo Culture="de-DE"/>
        </wpfo:RichEditTranslateBehavior>
        <wpfo:RichEditCustomRequestBehavior />
        <wpfo:RichEditGenerateDescriptionBehavior/>
    </dxmvvm:Interaction.Behaviors>
</dxre:RichEditControl>

This code demonstrates how to add AI behaviors for WPF Spreadsheet Control:

xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxspreadsheet="http://schemas.devexpress.com/winfx/2008/xaml/spreadsheet" 
xmlns:wpf="clr-namespace:DevExpress.AIIntegration.Wpf;assembly=DevExpress.AIIntegration.Wpf.v24.2"
xmlns:wpfo="clr-namespace:DevExpress.AIIntegration.Wpf.Office;assembly=DevExpress.AIIntegration.Wpf.v24.2"
xmlns:desktop="clr-namespace:DevExpress.AIIntegration.Desktop;assembly=DevExpress.AIIntegration.Desktop.v24.2"

<dxspreadsheet:SpreadsheetControl x:Name="richEditControl" CommandBarStyle="Ribbon">
    <dxmvvm:Interaction.Behaviors>
        <wpfo:SpreadsheetSummarizeBehavior />
        <wpfo:SpreadsheetExplainBehavior />
        <wpfo:SpreadsheetProofreadBehavior />
        <wpfo:SpreadsheetTranslateBehavior >
            <desktop:LanguageInfo Culture="de-DE"/>
        </wpfo:SpreadsheetTranslateBehavior>
        <wpfo:SpreadsheetFormulaExplanationBehavior />
        <wpfo:SpreadsheetCustomRequestBehavior />
        <wpfo:SpreadsheetGenerateDescriptionBehavior/>
    </dxmvvm:Interaction.Behaviors>
</dxspreadsheet:SpreadsheetControl>

Accessibility Enhancements - Alt Text dialogs

In v24.2, we implemented new AI-Powered Alt Text dialogs for WinForms and WPF Rich Text Editors and Spreadsheet Controls.
The Alt Text dialog allows you to set accessible descriptions for shape objects in Word and Excel documents or mark non-informative document graphics as Decorative (this setting allows screen readers to ignore decorative graphics when scanning documents).
In addition, you can use the Alt Text dialog to generate the meaningful descriptions for document images using the power of the AI behavior. To enable this functionality, follow the steps from the previous section of the current blog post to register the AI service and then, attach the DevExpress.AIIntegration.WinForms.GenerateDescriptionBehavior behavior for RichEditControl or SpreadsheetControl in a WinForms application, or attach the RichEditGenerateDescriptionBehavior/SpreadsheetGenerateDescriptionBehavior behavior in a WPF application.

The Generate button is disabled if the *GenerateDescriptionBehavior isn't registed for Rich Text Editor or Spreadsheet Control.
Descriptions can be generated only for document images. The Generate option is disabled when a shape or chart object is selected.

The new built-in dialogs are available from the shape’s context menu. To activate the Alt Text dialog, select a document shape, or image, or chart, open the context menu and click the “View Alt Text…” context menu item.


Your Feedback Matters

We value your feedback. Please take a moment to respond to the following survey and let us know how we can best serve your needs now and into the future:

Should you encounter an issue while using this Early Access Preview build (v24.2), please submit a support ticket via the DevExpress Support Center.  


Viewing all articles
Browse latest Browse all 2389

Trending Articles