@@ -33,6 +33,7 @@ public MainViewModel(IWindowManager _windowManager,IThemeService themeService, I
33
33
34
34
notifyManager = _notifyManager ;
35
35
notifyManager . ShowNotification += showNotification ;
36
+ notificationList = new ObservableCollection < NotifyModel > ( ) ;
36
37
37
38
_themeService = themeService ;
38
39
_themeService . ThemeChanged += ThemeChanged ;
@@ -102,12 +103,14 @@ public void ChangePageCommand(string selected_item)
102
103
sideBarBtns [ ind ] . background = _themeService . IsLightTheme ? ColorCon . Convert ( "#FCFCFC" ) : ColorCon . Convert ( "#36393F" ) ;
103
104
if ( currentPage != Pages [ ind ] ) pageService . Page = Pages [ ind ] ;
104
105
106
+
105
107
if ( selected_item == "Share" )
106
108
{
107
- notifyManager . CreateNotification ( "This is just for test" , 6 ) ;
109
+ notifyManager . CreateNotification ( $ "{ k } : This is just for test", 5 ) ;
110
+ k ++ ;
108
111
}
109
112
}
110
-
113
+ private int k = 1 ;
111
114
#region Color
112
115
private SolidColorBrush _backgroundColor ;
113
116
public SolidColorBrush backgroundColor
@@ -200,38 +203,48 @@ public string minImage
200
203
}
201
204
202
205
#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
212
208
{
213
- get => _notifcationDialogVisibility ;
214
- set => SetAndNotify ( ref _notifcationDialogVisibility , value ) ;
209
+ get => _notificationList ;
210
+ set => SetAndNotify ( ref _notificationList , value ) ;
215
211
}
216
212
213
+ private List < NotifyModel > WaitingNotifications = new List < NotifyModel > ( ) ;
217
214
private void showNotification ( object sender , EventArgs e )
218
215
{
219
- var noitification = sender as NotifyModel ;
216
+ var notification = sender as NotifyModel ;
220
217
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 ;
223
220
224
- notifcationDialogVisibility = Visibility . Visible ;
225
- var closeTimer = new DispatcherTimer
221
+ if ( notificationList . Count > 2 )
226
222
{
227
- Interval = TimeSpan . FromSeconds ( noitification . Delay ) ,
228
- IsEnabled = true
229
- } ;
230
- closeTimer . Tick += ( object sender , EventArgs e ) =>
223
+ WaitingNotifications . Add ( notification ) ;
224
+ }
225
+ else
231
226
{
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 ( ) ;
235
248
}
236
249
#endregion
237
250
}
0 commit comments