(1) SplashScreenManager 컴포넌트 사용법
- Navigation Controls - SplashScreenManager에 대한 사용법에 대해서 공부해 보겠습니다.
- SplashScreenManager 사용법에 대해서 설명할 내용이 많아 2번 나누어 정리해 보겠습니다.
(2) 소스
(3) 기본기능 따라해 보기
- SplashScreenManager 를 검색해서 Form1 디자인에 추가 합니다.
- SplashScreenManager 컴포넌트 추가후 기본으로 제공되는 Wait Form에 대해 진행하겠습니다.
- SplashScreenManager 작업에서 Add Wait From 선택 추가
- Add Wait From 선택 추가시 기본 소스와 폼이 아래와 같이 생성됩니다.
- WaitForm.cs 더블클릭시 기본 폼화면입니다.
- 기본 소스 화면입니다.
- MainForm에서 Wait Form을 Show/Hide 사용
- Show Wait Form (showWaitFormButton) 버튼을 더블클릭하여 소스를 수정합니다.
- showWaitFormButton 버튼클릭시 호출 Script 추가합니다.
- Hide Wait Form (hideWaitFormButton) 버튼을 더블클릭하여 소스를 수정합니다.
- hideWaitFormButton 버튼클릭시 호출 Script 추가합니다.
- (실행) 프로그램 실행후 "Show Wait Form" 버튼 클릭시 아래와 같이 대기 화면이 표시되고, "Hide Wait Form" 버튼클릭시 사라지는것을 확인 할수 있습니다.
- 이번에는 OverLay 대해서 알아보겠습니다.
- "Show Overlay (showOverlayButton)" 더블클릭으로 소스를 수정합니다.
- IOverlaySplashScreenHandle overlayHandle 추가
- showOverlayButton 버튼클릭시 호출 Script 추가합니다.
- "Hide Overlay (hideOverlayButton)" 더블클릭으로 소스를 수정합니다.
- hideOverlayButton 버튼클릭시 호출 Script 추가합니다.
- (실행) 실행후 "Show Overlay" 버튼 클릭시 화면입니다. "Hide Overlay" 버튼 클릭시 사라지게 됩니다.
- "Show Overlay" 버튼 선택시 카운트 되는 화면입니다.
(4) 소스 내용
- 지금까지 수정되 소스 내용입니다.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.Utils.Svg;
using DevExpress.XtraPrinting.Preview;
using DevExpress.XtraSplashScreen;
namespace sample_2_17 {
public partial class MainForm : DevExpress.XtraEditors.XtraForm {
public MainForm() {
InitializeComponent();
syncContext = SynchronizationContext.Current;
}
private void showWaitFormButton_Click(object sender, EventArgs e)
{
splashScreenManager1.ShowWaitForm();
splashScreenManager1.SetWaitFormCaption("Wait for it");
}
private void hideWaitFormButton_Click(object sender, EventArgs e)
{
splashScreenManager1.CloseWaitForm();
}
CancellationTokenSource cancellationTokenSource;
SynchronizationContext syncContext;
Task BackgroundTask()
{
cancellationTokenSource = new CancellationTokenSource();
var cancellationToken = cancellationTokenSource.Token;
int state = 0;
return Task.Run(() => {
while (!cancellationToken.IsCancellationRequested)
{
Thread.Sleep(300);
state++;
syncContext.Post(new SendOrPostCallback(o => {
overlayTextPainter.Text = o.ToString();
}), state);
}
}, cancellationToken);
}
IOverlaySplashScreenHandle overlayHandle;
OverlayTextPainter overlayTextPainter;
private async void showOverlayButton_Click(object sender, EventArgs e)
{
if (overlayHandle == null)
{
overlayTextPainter = new OverlayTextPainter("Starting ...");
overlayHandle = SplashScreenManager.ShowOverlayForm(grid, customPainter: overlayTextPainter);
await BackgroundTask();
}
}
private void hideOverlayButton_Click(object sender, EventArgs e)
{
if (overlayHandle != null)
{
cancellationTokenSource.Cancel();
cancellationTokenSource.Dispose();
cancellationTokenSource = null;
overlayHandle.Close();
overlayHandle.Dispose();
overlayHandle = null;
}
}
}
}
감사합니다.
'개발(IT) > DevExpress 교육자료' 카테고리의 다른 글
DevExpress 강좌3-1 (MDI Demo) (0) | 2024.01.20 |
---|---|
2.Navigation Controls - SplashScreenManager Demo #2 (0) | 2023.12.03 |
2.Navigation Controls - DockManager Demo (0) | 2023.12.03 |
2.Navigation Controls - Accordion Demo (0) | 2023.12.03 |
2.Navigation Controls - Ribbon Demo4 (0) | 2023.11.26 |