This example adds a Progress Bar control to a Splash Screen and updates it dynamically by sending commands from the Splash Screen Manager.
The Splash Screen Manager displays Splash Screens in a separate thread. The Splash Screen Manager implements the command mechanism that allows you to interact with Splash Screens. Use the SplashScreenManager.SendCommand
method to send and process commands (by overriding the SplashScreen.ProcessCommand
method).
Files to Review
- Form1.cs (VB: Form1.vb)
- SplashScreen1.cs (VB: SplashScreen1.vb)
Documentation
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
C#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);
}
}
}
C#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
}
}
}