@@ -51,26 +51,9 @@ object IViewFor.ViewModel
5151 }
5252 #endregion ViewModel
5353
54- Dictionary < TypeMessage , System . Windows . Controls . Label > messagesLabels ;
55- static Dictionary < TypeMessage , string > labelPostfix = new Dictionary < TypeMessage , string > ( )
56- {
57- { TypeMessage . Error , "Error" } ,
58- { TypeMessage . Information , "Information" } ,
59- { TypeMessage . Warning , "Warning" } ,
60- { TypeMessage . Debug , "Debug" } ,
61- } ;
62-
6354 public MainWindow ( )
6455 {
6556 InitializeComponent ( ) ;
66- messagesLabels = new Dictionary < TypeMessage , System . Windows . Controls . Label > ( )
67- {
68- { TypeMessage . Error , LabelError } ,
69- { TypeMessage . Information , LabelInformation } ,
70- { TypeMessage . Warning , LabelWarning } ,
71- { TypeMessage . Debug , LabelDebug } ,
72- } ;
73-
7457 ViewModel = new ViewModelMainWindow ( this . NodesCanvas . ViewModel ) ;
7558 SetupSubscriptions ( ) ;
7659 SetupBinding ( ) ;
@@ -169,11 +152,10 @@ private void SetupEvents()
169152 this . ErrorListExpander . Events ( ) . Collapsed . Subscribe ( _=> ErrorListCollapse ( ) ) . DisposeWith ( disposable ) ;
170153 this . ErrorListExpander . Events ( ) . Expanded . Subscribe ( _ => ErrorListExpanded ( ) ) . DisposeWith ( disposable ) ;
171154
172- foreach ( var label in messagesLabels )
173- {
174- label . Value . Events ( ) . PreviewMouseLeftButtonDown . Subscribe ( e => SetDisplayMessageType ( e , label . Key ) ) . DisposeWith ( disposable ) ;
175- }
176-
155+ this . LabelError . Events ( ) . PreviewMouseLeftButtonDown . Subscribe ( e => SetDisplayMessageType ( e , TypeMessage . Error ) ) . DisposeWith ( disposable ) ;
156+ this . LabelWarning . Events ( ) . PreviewMouseLeftButtonDown . Subscribe ( e => SetDisplayMessageType ( e , TypeMessage . Warning ) ) . DisposeWith ( disposable ) ;
157+ this . LabelInformation . Events ( ) . PreviewMouseLeftButtonDown . Subscribe ( e => SetDisplayMessageType ( e , TypeMessage . Information ) ) . DisposeWith ( disposable ) ;
158+ this . LabelDebug . Events ( ) . PreviewMouseLeftButtonDown . Subscribe ( e => SetDisplayMessageType ( e , TypeMessage . Debug ) ) . DisposeWith ( disposable ) ;
177159 this . LabelErrorList . Events ( ) . PreviewMouseLeftButtonDown . Subscribe ( e=> SetDisplayMessageType ( e , TypeMessage . All ) ) . DisposeWith ( disposable ) ;
178160 this . LabelErrorListUpdate . Events ( ) . MouseLeftButtonDown . Subscribe ( _ => NodesCanvas . ViewModel . CommandErrorListUpdate . ExecuteWithSubscribe ( ) ) . DisposeWith ( disposable ) ;
179161 } ) ;
@@ -182,12 +164,15 @@ private void SetupEvents()
182164 private void UpdateLabels ( )
183165 {
184166 var counts = this . NodesCanvas . ViewModel . Messages . GroupBy ( x => x . TypeMessage ) . ToDictionary ( x=> x . Key , x=> x . Count ( ) ) ;
185-
186- foreach ( var lable in messagesLabels )
187- {
188- lable . Value . Content = ( counts . Keys . Contains ( lable . Key ) ? counts [ lable . Key ] . ToString ( ) : "0" ) + " " + labelPostfix [ lable . Key ] ;
189- }
190-
167+ var countError = counts . Keys . Contains ( TypeMessage . Error ) ? counts [ TypeMessage . Error ] . ToString ( ) : "0" ;
168+ var countWarning = counts . Keys . Contains ( TypeMessage . Warning ) ? counts [ TypeMessage . Warning ] . ToString ( ) : "0" ;
169+ var countInformation = counts . Keys . Contains ( TypeMessage . Information ) ? counts [ TypeMessage . Information ] . ToString ( ) : "0" ;
170+ var countDebug = counts . Keys . Contains ( TypeMessage . Debug ) ? counts [ TypeMessage . Debug ] . ToString ( ) : "0" ;
171+
172+ LabelError . Content = countError + " Error" ;
173+ LabelWarning . Content = countWarning + " Warning" ;
174+ LabelInformation . Content = countInformation + " Information" ;
175+ LabelDebug . Content = countDebug + " Debug" ;
191176 }
192177 private void SetDisplayMessageType ( MouseButtonEventArgs e , TypeMessage typeMessage )
193178 {
0 commit comments