@@ -33,6 +33,7 @@ public MainViewModel(IWindowManager _windowManager,IThemeService themeService, I
3333
3434 notifyManager = _notifyManager ;
3535 notifyManager . ShowNotification += showNotification ;
36+ notificationList = new ObservableCollection < NotifyModel > ( ) ;
3637
3738 _themeService = themeService ;
3839 _themeService . ThemeChanged += ThemeChanged ;
@@ -102,12 +103,14 @@ public void ChangePageCommand(string selected_item)
102103 sideBarBtns [ ind ] . background = _themeService . IsLightTheme ? ColorCon . Convert ( "#FCFCFC" ) : ColorCon . Convert ( "#36393F" ) ;
103104 if ( currentPage != Pages [ ind ] ) pageService . Page = Pages [ ind ] ;
104105
106+
105107 if ( selected_item == "Share" )
106108 {
107- notifyManager . CreateNotification ( "This is just for test" , 6 ) ;
109+ notifyManager . CreateNotification ( $ "{ k } : This is just for test", 5 ) ;
110+ k ++ ;
108111 }
109112 }
110-
113+ private int k = 1 ;
111114 #region Color
112115 private SolidColorBrush _backgroundColor ;
113116 public SolidColorBrush backgroundColor
@@ -200,38 +203,48 @@ public string minImage
200203 }
201204
202205 #region NotificationDialogView
203- private Object _notificationDialogView ;
204- public Object notificationDialogView
205- {
206- get => _notificationDialogView ;
207- set => SetAndNotify ( ref _notificationDialogView , value ) ;
208- }
209-
210- private Visibility _notifcationDialogVisibility ;
211- public Visibility notifcationDialogVisibility
206+ private ObservableCollection < NotifyModel > _notificationList ;
207+ public ObservableCollection < NotifyModel > notificationList
212208 {
213- get => _notifcationDialogVisibility ;
214- set => SetAndNotify ( ref _notifcationDialogVisibility , value ) ;
209+ get => _notificationList ;
210+ set => SetAndNotify ( ref _notificationList , value ) ;
215211 }
216212
213+ private List < NotifyModel > WaitingNotifications = new List < NotifyModel > ( ) ;
217214 private void showNotification ( object sender , EventArgs e )
218215 {
219- var noitification = sender as NotifyModel ;
216+ var notification = sender as NotifyModel ;
220217
221- var notifcationViewModel = new NotificationDialogViewModel ( _themeService , noitification . Message ) ;
222- notificationDialogView = ( Object ) notifcationViewModel ;
218+ var notifcationViewModel = new NotificationDialogViewModel ( _themeService , notification . Message ) ;
219+ notification . View = ( Object ) notifcationViewModel ;
223220
224- notifcationDialogVisibility = Visibility . Visible ;
225- var closeTimer = new DispatcherTimer
221+ if ( notificationList . Count > 2 )
226222 {
227- Interval = TimeSpan . FromSeconds ( noitification . Delay ) ,
228- IsEnabled = true
229- } ;
230- closeTimer . Tick += ( object sender , EventArgs e ) =>
223+ WaitingNotifications . Add ( notification ) ;
224+ }
225+ else
231226 {
232- notifcationDialogVisibility = Visibility . Hidden ;
233- closeTimer . Stop ( ) ;
234- } ;
227+ notificationList . Add ( notification ) ;
228+
229+ var closeTimer = new DispatcherTimer
230+ {
231+ Interval = TimeSpan . FromSeconds ( notification . Delay ) ,
232+ IsEnabled = true
233+ } ;
234+ closeTimer . Tick += CloseNotification ;
235+ }
236+ }
237+
238+ private void CloseNotification ( object sender , EventArgs e )
239+ {
240+ notificationList . RemoveAt ( 0 ) ;
241+ if ( WaitingNotifications . Count != 0 )
242+ {
243+ var notification = WaitingNotifications [ 0 ] ;
244+ WaitingNotifications . RemoveAt ( 0 ) ;
245+ notifyManager . CreateNotification ( notification . Message , notification . Delay ) ;
246+ }
247+ ( sender as DispatcherTimer ) . Stop ( ) ;
235248 }
236249 #endregion
237250 }
0 commit comments