@@ -33,7 +33,8 @@ public MainViewModel(IWindowManager _windowManager,IThemeService themeService, I
3333
3434 notifyManager = _notifyManager ;
3535 notifyManager . ShowNotification += showNotification ;
36- notificationList = new ObservableCollection < Object > ( ) ;
36+ notifyManager . OnCloseNotification += exitNotification ;
37+ notificationList = new ObservableCollection < NotifyObject > ( ) ;
3738
3839 _themeService = themeService ;
3940 _themeService . ThemeChanged += ThemeChanged ;
@@ -102,6 +103,11 @@ public void ChangePageCommand(string selected_item)
102103
103104 sideBarBtns [ ind ] . background = _themeService . IsLightTheme ? ColorCon . Convert ( "#FCFCFC" ) : ColorCon . Convert ( "#36393F" ) ;
104105 if ( currentPage != Pages [ ind ] ) pageService . Page = Pages [ ind ] ;
106+
107+ if ( selected_item == "Settings" )
108+ {
109+ notifyManager . CreateNotification ( "Simple test" , 10 ) ;
110+ }
105111 }
106112 #region Color
107113 private SolidColorBrush _backgroundColor ;
@@ -195,20 +201,20 @@ public string minImage
195201 }
196202
197203 #region NotificationDialogView
198- private ObservableCollection < Object > _notificationList ;
199- public ObservableCollection < Object > notificationList
204+ private ObservableCollection < NotifyObject > _notificationList ;
205+ public ObservableCollection < NotifyObject > notificationList
200206 {
201207 get => _notificationList ;
202208 set => SetAndNotify ( ref _notificationList , value ) ;
203209 }
204210
205- private List < Object > WaitingNotifications = new List < Object > ( ) ;
211+ private List < NotifyObject > WaitingNotifications = new List < NotifyObject > ( ) ;
206212 private void showNotification ( object sender , EventArgs e )
207213 {
208- var notification = sender as Object ;
214+ var notification = sender as NotifyObject ;
209215
210- var notifcationViewModel = new NotificationDialogViewModel ( _themeService , notification . Message ) ;
211- notification . View = ( System . Object ) notifcationViewModel ;
216+ var notifcationViewModel = new NotificationDialogViewModel ( _themeService , notifyManager , notification ) ;
217+ notification . View = ( Object ) notifcationViewModel ;
212218
213219 if ( notificationList . Count > 2 )
214220 {
@@ -227,16 +233,33 @@ private void showNotification(object sender, EventArgs e)
227233 }
228234 }
229235
236+ private void exitNotification ( object sender , EventArgs e )
237+ {
238+ var notification = sender as NotifyObject ;
239+ notificationList . Remove ( notification ) ;
240+ UpdateNotification ( ) ;
241+ }
242+
230243 private void CloseNotification ( object sender , EventArgs e )
231244 {
232- notificationList . RemoveAt ( 0 ) ;
233- if ( WaitingNotifications . Count != 0 )
245+ if ( notificationList . Count > 0 ) notificationList . RemoveAt ( 0 ) ;
246+ UpdateNotification ( ) ;
247+ ( sender as DispatcherTimer ) . Stop ( ) ;
248+ }
249+
250+ private void UpdateNotification ( )
251+ {
252+ if ( WaitingNotifications . Count > 0 )
234253 {
235- var notification = WaitingNotifications [ 0 ] ;
236- WaitingNotifications . RemoveAt ( 0 ) ;
237- notifyManager . CreateNotification ( notification . Message , notification . Delay ) ;
254+ for ( int i = 0 ; i < ( 3 - notificationList . Count ) ; i ++ )
255+ {
256+ if ( WaitingNotifications . Count == 0 ) break ;
257+
258+ var notification = WaitingNotifications [ i ] ;
259+ WaitingNotifications . RemoveAt ( i ) ;
260+ notifyManager . CreateNotification ( notification . Message , notification . Delay ) ;
261+ }
238262 }
239- ( sender as DispatcherTimer ) . Stop ( ) ;
240263 }
241264 #endregion
242265 }
0 commit comments