Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.
How to: Show an Image as a Splash Screen and Draw Custom Information Over this Image
6 minutes to read
In this example, an image is displayed as a splash screen via the SplashScreenManager.ShowImage method.Custom information is painted over this image via a custom class (SplashImagePainter), whose instance is passed as a parameter to the ShowImage method. The SplashImagePainter draws text labels with custom progress information.
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
usingDevExpress.XtraSplashScreen;
namespaceSplashScreenManagerSample01 {
publicpartialclassForm1 : Form {
publicForm1() {
InitializeComponent();
LongInitialization();
}
protectedvoidLongInitialization() {
BaseInitialization();
LoadFonts();
LoadTextures();
}
voidBaseInitialization() {
// Set progress stage to be displayed by SplashImagePainter
SplashImagePainter.Painter.ViewInfo.Stage = "Initialization";
for(int i = 1; i <= 100; i++) {
System.Threading.Thread.Sleep(20);
// Change progress to be displayed by SplashImagePainter
SplashImagePainter.Painter.ViewInfo.Counter = i;
//Force SplashImagePainter to repaint information
SplashScreenManager.Default.Invalidate();
}
}
voidLoadFonts() {
// Set progress stage to be displayed by SplashImagePainter
SplashImagePainter.Painter.ViewInfo.Stage = "Loading Fonts";
for(int i = 1; i <= 100; i++) {
System.Threading.Thread.Sleep(20);
// Change progress to be displayed by SplashImagePainter
SplashImagePainter.Painter.ViewInfo.Counter = i;
//Force SplashImagePainter to repaint information
SplashScreenManager.Default.Invalidate();
}
}
voidLoadTextures() {
// Set progress stage to be displayed by SplashImagePainter
SplashImagePainter.Painter.ViewInfo.Stage = "Loading Textures";
for(int i = 1; i <= 100; i++) {
System.Threading.Thread.Sleep(20);
// Change progress to be displayed by SplashImagePainter
SplashImagePainter.Painter.ViewInfo.Counter = i;
//Force SplashImagePainter to repaint information
SplashScreenManager.Default.Invalidate();
}
}
//protectedoverridevoidOnLoad(EventArgs e) {
base.OnLoad(e);
// Close splash image
SplashScreenManager.HideImage();
}
}
}
ImportsMicrosoft.VisualBasicImportsSystemImportsSystem.DrawingImportsSystem.ReflectionImportsSystem.Windows.FormsImportsDevExpress.XtraSplashScreenNamespace SplashScreenManagerSample01
FriendNotInheritableClass Program
PrivateSubNew()
EndSub
<STAThread> _
SharedSub Main()
Application.EnableVisualStyles()
Application.SetCompatibleTextRenderingDefault(False)
Dim image As Image = GetImage()
' Show splash image
SplashScreenManager.ShowImage(image, True, True, SplashImagePainter.Painter)
Application.Run(New Form1())
EndSubPrivateSharedFunction GetImage() As Image
Dim asm As System.Reflection.Assembly = GetType(Program).AssemblyReturnNew Bitmap(asm.GetManifestResourceStream("DefSplashImage.png"))
EndFunctionEndClassEndNamespace
ImportsMicrosoft.VisualBasicImportsSystemImportsSystem.Collections.GenericImportsSystem.ComponentModelImportsSystem.DataImportsSystem.DrawingImportsSystem.LinqImports System.TextImportsSystem.Windows.FormsImportsDevExpress.XtraSplashScreenNamespace SplashScreenManagerSample01
PartialPublicClass Form1
Inherits Form
PublicSubNew()
InitializeComponent()
LongInitialization()
EndSubProtectedSub LongInitialization()
BaseInitialization()
LoadFonts()
LoadTextures()
EndSubPrivateSub BaseInitialization()
' Set progress stage to be displayed by SplashImagePainter
SplashImagePainter.Painter.ViewInfo.Stage = "Initialization"For i AsInteger = 1To100
System.Threading.Thread.Sleep(20)
' Change progress to be displayed by SplashImagePainter
SplashImagePainter.Painter.ViewInfo.Counter = i
'Force SplashImagePainter to repaint information
SplashScreenManager.Default.Invalidate()
Next i
EndSubPrivateSub LoadFonts()
' Set progress stage to be displayed by SplashImagePainter
SplashImagePainter.Painter.ViewInfo.Stage = "Loading Fonts"For i AsInteger = 1To100
System.Threading.Thread.Sleep(20)
' Change progress to be displayed by SplashImagePainter
SplashImagePainter.Painter.ViewInfo.Counter = i
'Force SplashImagePainter to repaint information
SplashScreenManager.Default.Invalidate()
Next i
EndSubPrivateSub LoadTextures()
' Set progress stage to be displayed by SplashImagePainter
SplashImagePainter.Painter.ViewInfo.Stage = "Loading Textures"For i AsInteger = 1To100
System.Threading.Thread.Sleep(20)
' Change progress to be displayed by SplashImagePainter
SplashImagePainter.Painter.ViewInfo.Counter = i
'Force SplashImagePainter to repaint information
SplashScreenManager.Default.Invalidate()
Next i
EndSub'ProtectedOverridesSub OnLoad(ByVal e As EventArgs)
MyBase.OnLoad(e)
' Close splash image
SplashScreenManager.HideImage()
EndSubEndClassEndNamespace
ImportsMicrosoft.VisualBasicImportsSystem.DrawingImportsDevExpress.Utils.DrawingImports DevExpress.Utils.TextImportsDevExpress.XtraSplashScreenNamespace SplashScreenManagerSample01
FriendClass SplashImagePainter
Implements ICustomImagePainter
SharedSubNew()
Painter = New SplashImagePainter()
EndSubProtectedSubNew()
EndSubPrivateShared privatePainter As SplashImagePainter
PublicSharedProperty Painter() As SplashImagePainter
GetReturn privatePainter
EndGetPrivateSet(ByVal value As SplashImagePainter)
privatePainter = value
EndSetEndPropertyPrivate info As ViewInfo = NothingPublicReadOnlyProperty ViewInfo() As ViewInfo
GetIfMe.info IsNothingThenMe.info = New ViewInfo()
EndIfReturnMe.info
EndGetEndProperty#Region "Drawing"PublicSub Draw(ByVal cache As GraphicsCache, ByVal bounds As Rectangle) Implements ICustomImagePainter.Draw
Dim pt As PointF = ViewInfo.CalcProgressLabelPoint(cache, bounds)
cache.Graphics.DrawString(ViewInfo.Text, ViewInfo.ProgressLabelFont, ViewInfo.Brush, pt)
EndSub#EndRegionEndClassFriendClass ViewInfo
PublicSubNew()
Counter = 1
Stage = String.Empty
EndSubPrivate privateCounter AsIntegerPublicProperty Counter() AsIntegerGetReturn privateCounter
EndGetSet(ByVal value AsInteger)
privateCounter = value
EndSetEndPropertyPrivate privateStage AsStringPublicProperty Stage() AsStringGetReturn privateStage
EndGetSet(ByVal value AsString)
privateStage = value
EndSetEndPropertyPublicFunction CalcProgressLabelPoint(ByVal cache As GraphicsCache, ByVal bounds As Rectangle) As PointF
Const yOffset AsInteger = 40Dim size As Size = TextUtils.GetStringSize(cache.Graphics, Text, ProgressLabelFont)
ReturnNew Point(bounds.Width / 2 - size.Width / 2, yOffset)
EndFunctionPrivate progressFont As Font = NothingPublicReadOnlyProperty ProgressLabelFont() As Font
GetIfMe.progressFont IsNothingThenMe.progressFont = New Font("Consolas", 10)
EndIfReturnMe.progressFont
EndGetEndPropertyPrivate brush_Renamed As Brush = NothingPublicReadOnlyProperty Brush() As Brush
GetIfMe.brush_Renamed IsNothingThenMe.brush_Renamed = New SolidBrush(Color.Black)
EndIfReturnMe.brush_Renamed
EndGetEndPropertyPublicReadOnlyPropertyText() AsStringGetReturnString.Format("{0} - ({1}%)", Stage, Counter.ToString("D2"))
EndGetEndPropertyEndClassEndNamespace
Was this page helpful?
Thanks for your feedback!
How can we improve this help topic?
Additional comments/thoughts:
If you have any questions, submit a ticket to our Support Center.
No
Your feedback is appreciated.
By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts.
Privacy Preference Center
When you visit a Developer Express Inc (“DevExpress”) website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. While the information does not usually directly identify you, it can give you a more personalized web experience. Because DevExpress respects your right to privacy, you can choose to disallow/disable the use of certain cookies. Click on different category headings to learn more and change our default settings. Keep in mind that blocking some types of cookies may impact your experience on the site and may affect the services DevExpress is able to offer to you. You cannot opt-out of our use of strictly necessary cookies as they are used to ensure the proper functioning of our Websites (such as remembering your settings, allowing you to log into your account, and other similar purposes). You may, however, opt-out of receiving and our use of non-essential cookies (including preference, functional, and targeting cookies) by changing your settings for each category listed below.
[Videos]
Our use of cookies may also collect information about what videos you have watched on our websites. You may opt-out of these cookies by changing your settings for functional and advertising cookies. We will ask you to review and update your choices at least once every two (2) years. By continuing to allow us to use these cookies you explicitly consent to our use of cookies and our disclosure of what videos you have watched on our Websites to our video hosting providers, such as YouTube, for a period of up to two (2) years.
Manage Consent Preferences
Strictly Necessary Cookies
Always Active
These cookies are necessary for the website to function properly and cannot be disabled. They are usually set in response to actions initiated by you – actions that amount to a request for services, such as setting your privacy preferences, logging onto the website, or populating website forms. You can set your browser to block or alert you about these cookies, but certain portions of the site will not work properly when these cookies are disabled. These cookies do not store any personally identifiable information.
Performance Cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand page popularity and determine how visitors move around the site. All information collected by these cookies are aggregated and therefore anonymous. If you disallow/disable these cookies, we will not know when you have visited our site and we will not be able to monitor its performance.
Functional Cookies
These cookies allow the website to provide enhanced functionality and personalization. They may be set by us or by third party providers whose services we have added to our pages. If you disallow/disable these cookies, some or all of these services may fail to function properly.
Targeting Cookies
These cookies may be set through our site by our advertising partners. They may be used by advertising partners to build a profile of your interests and display relevant advertisements on other sites. While these cookies do not store personal information, they do identify your browser and internet device. If you disallow/disable these cookies, you will experience less targeted advertising.