| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- using System;
- using System.ComponentModel;
- using System.Threading;
- using System.Windows;
- using System.Windows.Controls;
- namespace OHV.Vehicle.Concept
- {
- /// <summary>
- /// AnimatedSplashScreenWindow.xaml에 대한 상호 작용 논리
- /// </summary>
- public partial class AnimatedSplashScreenWindow : Window, ISplashScreen, INotifyPropertyChanged
- {
- public event PropertyChangedEventHandler PropertyChanged;
- #region Properties
- string totalProgressText;
- private int _progressValue;
- public int ProgressValue
- {
- get { return _progressValue; }
- set
- {
- _progressValue = value;
- OnPropertyChanged( nameof( ProgressValue ) );
- }
- }
- public string TotalProgressText
- {
- get { return totalProgressText; }
- set
- {
- if ( totalProgressText == value )
- return;
- totalProgressText = value;
- OnPropertyChanged( nameof( TotalProgressText ) );
- }
- }
- #endregion
- public void SetRange( int count )
- {
- Dispatcher.Invoke( new Action( () =>
- {
- ProgressValue = 0;
- ProgressBar.Maximum = count;
- } ) );
- }
- public void StepIt()
- {
- Dispatcher.Invoke( new Action( () =>
- {
- if ( this.ProgressBar.Maximum <= ProgressValue )
- return;
- this.ProgressValue += 1;
- } ) );
- }
- public AnimatedSplashScreenWindow()
- {
- InitializeComponent();
- }
- public void AddMessage( string message )
- {
- Dispatcher.Invoke( (Action)delegate ()
- {
- this.UpdateMessageLabel.Content = message;
- } );
- }
- public void ReportProgress(int persent )
- {
- Dispatcher.Invoke( (Action)delegate ()
- {
- ProgressValue = persent;
- } );
- }
- public void ReportTotalProgress( int persent )
- {
- Dispatcher.Invoke( (Action)delegate ()
- {
- this.TotalProgressText = $"Total {persent}%";
- } );
- }
- public void LoadComplete()
- {
- Thread.Sleep( 500 );
- Dispatcher.InvokeShutdown();
- }
- protected void OnPropertyChanged( string name )
- {
- PropertyChangedEventHandler handler = PropertyChanged;
- if ( handler != null )
- {
- handler( this, new PropertyChangedEventArgs( name ) );
- }
- }
- }
- public interface ISplashScreen
- {
- void ReportTotalProgress( int persent );
- void AddMessage( string message );
- void LoadComplete();
- void ReportProgress( int persent );
- void SetRange( int count );
- void StepIt();
- }
- }
|