windowsforms-devexpress-dot-xtrasplashscreen-dot-splashscreenmanager-dot-sendcommand-x28-system-dot-enum-system-dot-object-x29.md
Sends a command to the currently active splash form.
Namespace : DevExpress.XtraSplashScreen
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
public void SendCommand(
Enum cmd,
object arg
)
Public Sub SendCommand(
cmd As Enum,
arg As Object
)
| Name | Type | Description |
|---|---|---|
| cmd | Enum |
An enumeration value that identifies the command to be sent to the currently active splash form.
| | arg | Object |
The command’s parameter.
|
A splash form is displayed in a separate thread. To interact with a splash form via code, you can send commands to it via the SendCommand method. To respond to the commands, override the SplashFormBase.ProcessCommand method for your splash form and implement the required functionality.
In this example a custom Progress Bar Control is added to a Splash Screen. The example shows how to update this Progress Bar Control dynamically by sending commands from a Splash Screen Manager.Splash Screens are displayed by a Splash Screen Manager in a separate thread. Interaction with Splash Screens can be performed via the command mechanism. You send a command via the SplashScreenManager.SendCommand method and process this command by overriding the SplashScreen.ProcessCommand method. In the example, custom commands are sent to the Splash Screen to advance the progress of the Splash Screen's Progress Bar Control.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraSplashScreen;
namespace SplashScreen_ProcessCommand {
public partial class SplashScreen1 : SplashScreen {
public SplashScreen1() {
InitializeComponent();
}
#region Overrides
public override void ProcessCommand(Enum cmd, object arg) {
base.ProcessCommand(cmd, arg);
SplashScreenCommand command = (SplashScreenCommand)cmd;
if (command == SplashScreenCommand.SetProgress) {
int pos = (int)arg;
progressBarControl1.Position = pos;
}
}
#endregion
public enum SplashScreenCommand {
SetProgress,
Command2,
Command3
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraSplashScreen;
using System.Threading;
namespace SplashScreen_ProcessCommand {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void btnShowSplashScreen_Click(object sender, EventArgs e) {
// Open a Splash Screen
SplashScreenManager.ShowForm(this, typeof(SplashScreen1), true, true, false);
// The splash screen will be opened in a separate thread. To interact with it, use the SendCommand method.
for (int i = 1; i <= 100; i++) {
SplashScreenManager.Default.SendCommand(SplashScreen1.SplashScreenCommand.SetProgress, i);
//To process commands, override the SplashScreen.ProcessCommand method.
Thread.Sleep(25);
}
// Close the Splash Screen.
SplashScreenManager.CloseForm(false);
}
}
}
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraSplashScreen
Imports System.Threading
Namespace SplashScreen_ProcessCommand
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub btnShowSplashScreen_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnShowSplashScreen.Click
' Open a Splash Screen
SplashScreenManager.ShowForm(Me, GetType(SplashScreen1), True, True, False)
' The splash screen will be opened in a separate thread. To interact with it, use the SendCommand method.
For i As Integer = 1 To 100
SplashScreenManager.Default.SendCommand(SplashScreen1.SplashScreenCommand.SetProgress, i)
'To process commands, override the SplashScreen.ProcessCommand method.
Thread.Sleep(25)
Next i
' Close the Splash Screen.
SplashScreenManager.CloseForm(False)
End Sub
End Class
End Namespace
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraSplashScreen
Namespace SplashScreen_ProcessCommand
Partial Public Class SplashScreen1
Inherits SplashScreen
Public Sub New()
InitializeComponent()
End Sub
#Region "Overrides"
Public Overrides Sub ProcessCommand(ByVal cmd As System.Enum, ByVal arg As Object)
MyBase.ProcessCommand(cmd, arg)
Dim command As SplashScreenCommand = CType(cmd, SplashScreenCommand)
If command = SplashScreenCommand.SetProgress Then
Dim pos As Integer = CInt(Fix(arg))
progressBarControl1.Position = pos
End If
End Sub
#End Region
Public Enum SplashScreenCommand
SetProgress
Command2
Command3
End Enum
End Class
End Namespace
The following code snippets (auto-collected from DevExpress Examples) contain references to the SendCommand(Enum, Object) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-wait-form-cancel-operation/CS/WaitFormCanceling/Form1.cs#L78
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SendCommand(WaitForm1.WaitFormCommand.SendObject, locker1);
}
winforms-spreadsheet-create-custom-progress-indicator/CS/SpreadsheetProgressSample/Form1.cs#L35
// used to generate cancellation tokens for the task cancellation.
splashScreenManager1.SendCommand(WaitForm1.WaitFormCommand.SetCancellationTokenSource, cancellationTokenSource);
}
winforms-splash-screen-send-commands/CS/Form1.cs#L25
for (int i = 1; i <= 100; i++) {
SplashScreenManager.Default.SendCommand(SplashScreen1.SplashScreenCommand.SetProgress, i);
//To process commands, override the SplashScreen.ProcessCommand method.
winforms-wait-form-cancel-operation/VB/WaitFormCanceling/Form1.vb#L67
splashScreenManager1.ShowWaitForm()
splashScreenManager1.SendCommand(WaitForm1.WaitFormCommand.SendObject, locker1)
End Sub
winforms-spreadsheet-create-custom-progress-indicator/VB/SpreadsheetProgressSample/Form1.vb#L37
' used to generate cancellation tokens for the task cancellation.
splashScreenManager1.SendCommand(WaitForm1.WaitFormCommand.SetCancellationTokenSource, cancellationTokenSource)
End Sub
winforms-splash-screen-send-commands/VB/Form1.vb#L22
For i As Integer = 1 To 100
SplashScreenManager.Default.SendCommand(SplashScreen1.SplashScreenCommand.SetProgress, i)
'To process commands, override the SplashScreen.ProcessCommand method.
See Also