In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you how to use DevExpress WinForms help document forms and user controls to achieve overlay forms, the content is concise and easy to understand, can definitely make your eyes bright, through the detailed introduction of this article, I hope you can get something.
An override form is a translucent startup screen that does the following:
Override a control or form
Prevent users from interacting with overlapping controls
Overrides the control, even if it changes its size or position on the screen
Runs in a separate thread and does not block the main thread and operation thread
Allows you to display custom messages and buttons on overlapping controls
Note: run Overlay Form module in the XtraEditors MainDemo to see the form you are using, and click Open Solution on the ribbon to get the source code.
Show overlay form
Call the ShowOverlayForm (Control) method to display the overlay form on the control or form, which returns a handle that you can pass to the CloseOverlayForm (IOverlaySplashScreenHandle) method to close the form.
The following code shows how to display an override form on the current form when the application performs a long-running operation.
C#
Using DevExpress.XtraSplashScreen;//...IOverlaySplashScreenHandle ShowProgressPanel () {return SplashScreenManager.ShowOverlayForm (this);} void CloseProgressPanel (IOverlaySplashScreenHandle handle) {if (handle! = null) SplashScreenManager.CloseOverlayForm (handle);} /... IOverlaySplashScreenHandle handle = null;try {handle = ShowProgressPanel (); / / Launch a long-running operation while// the OverlayForm overlaps the current form.} finally {CloseProgressPanel (handle);}
VB.NET
Imports DevExpress.XtraSplashScreen'...Private Function ShowProgressPanel () As IOverlaySplashScreenHandleDim handle As IOverlaySplashScreenHandle = SplashScreenManager.ShowOverlayForm (Me) Return handleEnd FunctionPrivate Sub CloseProgressPanel (ByVal handle As IOverlaySplashScreenHandle) If handle IsNot Nothing Then SplashScreenManager.CloseOverlayForm (handle) End Sub'...Dim Handle As IOverlaySplashScreenHandle = NothingTryHandle = ShowProgressPanel () 'Launch a long-running operation while' the OverlayForm overlaps the main form.FinallyCloseProgressPanel (Handle) End Try
Warning: you can only display an overlay form on a control / form that has initialized (created its handle); otherwise, an InvalidOperationException will be thrown, see IsHandleCreated.
Custom override form
The ShowOverlayForm (Control, OverlayWindowOptions) method allows you to display an override form with the following parameters:
StartupDelay-the delay before the form is displayed.
BackColor-background color.
Opacity-opaque form.
FadeIn, FadeOut-used to show and hide the fade in and out of the form.
AnimationType-Type of animation (wait indicator):
Image-rotates the image, the default image depends on the skin. Use the ImageSize property to specify the size of the default image, which depends on the size of the overlapping control, and the Image property to specify a custom image.
The RotationParameters property specifies the rotation period and the number of frames per rotation.
Line-use the LineAnimationParameters attribute to specify the number of points, the size of points, and the distance between points.
CustomPainter-A descendant of OverlayWindowPainterBase used to draw forms, see the example in the CustomPainter section.
SkinName-the skin name applied to the form, the default wait indicator, the fade effect and color depend on the skin, and the default appearance corresponds to the appearance of the overlapping control
UseDirectX-specifies whether to use DirectX rendering to override the form, to use DirectX for all compatible DevExpress controls, enable the UseDirectX option in Project Settings, for more information, see the following topic: DirectX Hardware Acceleration.
All of these parameters are optional. If the parameter is omitted, the default value is used. The ShowOverlayForm (Control) method without options uses the static (shared in VB) default option.
The following code shows how to display an override form with custom parameters.
C#
Using DevExpress.XtraSplashScreen;OverlayWindowOptions options = new OverlayWindowOptions (startupDelay: 1000 discipline backcolor: Color.Red,opacity: 0.5 SplashScreenManager.ShowOverlayForm: false,fadeOut: false,imageSize: new Size (64, 64)); IOverlaySplashScreenHandle handle1 = SplashScreenManager.ShowOverlayForm (gridControl1, options); IOverlaySplashScreenHandle handle2 = SplashScreenManager.ShowOverlayForm (owner: gridControl1,startupDelay: 1000 lens backcolor: Color.Red,opacity: 127 law: false,fadeOut: false,imageSize: new Size (64, 64))
VB.NET
Imports DevExpress.XtraSplashScreenDim options As New OverlayWindowOptions (startupDelay:=1000,backColor:=Color.Red,opacity:=0.5,fadeIn:=False,fadeOut:=False,imageSize:=New Size (64,64)) Dim formHandle1 As IOverlaySplashScreenHandle = SplashScreenManager.ShowOverlayForm (gridControl1, options) Dim formHandle2 As IOverlaySplashScreenHandle = SplashScreenManager.ShowOverlayForm (owner:=gridControl1,startupDelay:=1000,backColor:=Color.Red,opacity:=127,fadeIn:=False,fadeOut:=False,imageSize:=New Size (64,64))
Custom Painter
You can render overlapping forms in the following ways:
Inherit from the OverlayWindowPainterBase class
Override the Draw method
Pass the created object as a parameter to the ShowOverlayForm method
The following code snippet shows how to display a custom message, as shown in the following figure:
C#
Using DevExpress.XtraSplashScreen;using DevExpress.Utils.Drawing;using System.Drawing;//...class CustomOverlayPainter: OverlayWindowPainterBase {/ / Defines the string's font.static readonly Font drawFont;static CustomOverlayPainter () {drawFont = new Font ("Tahoma", 18);} protected override void Draw (OverlayWindowCustomDrawContext context) {/ / The Handled event parameter should be set to true. / / to disable the default drawing algorithm. Context.Handled = true;//Provides access to the drawing surface. GraphicsCache cache = context.DrawArgs.Cache;//Adjust the TextRenderingHint option//to improve the image quality.cache.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;//Overlapped control bounds. Rectangle bounds = context.DrawArgs.Bounds;//Draws the default background. Context.DrawBackground (); / / Specify the string that will be drawn on the Overlay Form instead of the wait indicator.String drawString = "Please wait..."; / / Get the system's black brush.Brush drawBrush = Brushes.Black;//Calculate the size of the message string.SizeF textSize = cache.CalcTextSize (drawString, drawFont) / / A point that specifies the upper-left corner of the rectangle where the string will be drawn.PointF drawPoint = new PointF (bounds.Left + bounds.Width / 2-textSize.Width / 2); / / Draw the string on the screen.cache.DrawString (drawString, drawFont, drawBrush, drawPoint);} /. IOverlaySplashScreenHandle handle = SplashScreenManager.ShowOverlayForm (this, customPainter: new CustomOverlayPainter ())
VB.NET
Imports DevExpress.Utils.DrawingImports DevExpress.XtraSplashScreenImports System.Drawing'...Class CustomOverlayPainterInherits OverlayWindowPainterBase'Defines the string's font.Shared ReadOnly drawFont As FontShared Sub New () drawFont = New Font ("Tahoma", 18) End SubProtected Overrides Sub Draw (context As OverlayWindowCustomDrawContext) 'The Handled event parameter should be set to true' to disable the default drawing algorithm.context.Handled = True'Provides access to the drawing surface. Dim cache As GraphicsCache = context.DrawArgs.Cache'Adjust the TextRenderingHint option'to improve the image quality. Cache.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias'Overlapped control bounds.Dim bounds As Rectangle = context.DrawArgs.Bounds'Draws the default background. Context.DrawBackground () 'Create the string to draw. Dim drawString As String = "Please wait..." 'Get the system black brush. Dim drawBrush As Brush = Brushes.Black'Calculate the size of the message string. Dim textSize As SizeF = cache.CalcTextSize (drawString, drawFont)'A point that specifies the upper-left corner of the rectangle where the string should be drawn.Dim drawPoint As PointF = New PointF (bounds.Left + bounds.Width / 2-textSize.Width / 2, bounds.Top + bounds.Height / 2-textSize.Height / 2) 'Draw the string on the screen.cache.DrawString (drawString, drawFont, drawBrush, drawPoint) End SubEnd Class'...Dim handle As IOverlaySplashScreenHandle = SplashScreenManager.ShowOverlayForm (Me) CustomPainter:=New CustomOverlayPainter () the above is how to use the DevExpress WinForms help document form and user controls to override the form Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.