- [DEVEXPRESS] Hướng dẫn bật tính năng Scroll Pixcel in Touch trên GridView
- [DEVEXPRESS] Hướng dẫn sử dụng TileBar viết ứng dụng duyệt hình ảnh Winform
- [DEVEXPRESS] Tô màu border TextEdit trên Winform
- [C#] Lấy dữ liệu từ Console Write hiển thị lên textbox Winform
- [C#] Hiển thị Progress bar trên Window Console
- [C#] Di chuyển control Runtime và lưu layout trên winform
- [SQLSERVER] Sử dụng hàm NULL IF
- [C#] Chia sẽ source code mã đi tuần bằng giao diện Winform
- [C#] Flash Window in Taskbar Winform
- Download và Giải nén tập tin File sử dụng Powershell
- [C#] Hướng dẫn cách lấy thông tin đăng nhập tài khoản và mật khẩu web browser trên windows
- [VB.NET] CRUD Thêm xóa sửa tìm kiếm Realtime FireBase
- [C#] Hiển thị thông báo Toast Message trong lập trình Winform
- [C#] Cấu hình định dạng ngày tháng, thời gian trên Windows cho ứng dụng Winform
- [C#] Rút gọn đường dẫn link url với TinyURL API
- [C#] Hướng dẫn cách bo tròn winform with Radius
- [C#] Chia sẽ class BackGroundOverlay Show Modal cho Winform
- [C#] Hướng dẫn Flip Image Winform
- [C#] Invoke là gì? cách sử dụng phương thức Invoke()
- [C#] Hướng dẫn chia sẽ file, folder từ ứng dụng sang Zalo Chat
[DEVEXPRESS] Hướng dẫn tạo hiệu ứng form overlay in csharp
Xin chào các bạn, bài viết hôm nay mình sẽ tiếp tục hướng dẫn các bạn cách tạo hiệu ứng overlay trên panel winform C# sử dụng Devexpress.
[DEVEXPRESS] OVERLAY PANEL C#
Trong bài viết hôm trước bên chuyên mục mình đã có viết bài hướng dẫn các bạn cách tạo hiệu ứng làm mờ (blur) trong lập trình C#.
Bài hôm nay, mình sẽ hướng dẫn các bạn sử dụng SplashScreenManager
để tạo hiệu ứng overlay cho winform.
Các bạn có thể theo dõi demo ứng dụng bên dưới để biết bài viết này mình viết về các gì:
Thường chức năng này các bạn sẽ ứng dụng để khóa nguyên vùng panel.
Đầu tiên các bạn tạo cho mình một class: CustomOverlayWindowPainter.cs
using System.Drawing;
using DevExpress.Utils.Drawing;
using DevExpress.XtraSplashScreen;
namespace TestProject
{
public class CustomOverlayWindowPainter : OverlayWindowPainterBase
{
private static readonly Font _font;
static CustomOverlayWindowPainter()
{
_font = new Font("Tahoma", 16, FontStyle.Bold);
}
protected override void Draw(OverlayWindowCustomDrawContext context)
{
context.Handled = true;
GraphicsCache cache = context.DrawArgs.Cache;
cache.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
Rectangle boundRectangle = context.DrawArgs.Bounds;
context.DrawBackground();
string message = "OVERLAY PANEL C# - HTTPS://LAPTRINHVB.NET";
SizeF textSize = cache.Graphics.MeasureString(message, _font);
PointF point = new PointF
(
(boundRectangle.Width - textSize.Width ) / 2,
(boundRectangle.Height - textSize.Height) / 2
);
cache.Graphics.DrawString(message, _font, Brushes.Orange, point);
}
}
}
Và source code C# cho MainForm.cs
:
using System;
using DevExpress.XtraEditors;
using DevExpress.XtraSplashScreen;
namespace TestProject
{
public partial class MainForm : XtraForm
{
public IOverlaySplashScreenHandle handle = null;
public MainForm()
{
InitializeComponent();
}
private void applyButton_Click(object sender, EventArgs e)
{
handle = SplashScreenManager.ShowOverlayForm(this.panel1, customPainter: new CustomOverlayWindowPainter());
}
private void cancelButton_Click(object sender, EventArgs e)
{
if (handle != null)
{
SplashScreenManager.CloseOverlayForm(handle);
}
}
}
}
Thanks for watching!