@@ -50,6 +50,7 @@ object IViewFor.ViewModel
5050 set { ViewModel = ( ViewModelMainWindow ) value ; }
5151 }
5252 #endregion ViewModel
53+
5354 Dictionary < TypeMessage , System . Windows . Controls . Label > messagesLabels ;
5455 static Dictionary < TypeMessage , string > labelPostfix = new Dictionary < TypeMessage , string > ( )
5556 {
@@ -71,7 +72,6 @@ public MainWindow()
7172 } ;
7273
7374 ViewModel = new ViewModelMainWindow ( this . NodesCanvas . ViewModel ) ;
74- SetupCommands ( ) ;
7575 SetupSubscriptions ( ) ;
7676 SetupBinding ( ) ;
7777 SetupEvents ( ) ;
@@ -106,34 +106,6 @@ private void SetupBinding()
106106 this . BindCommand ( this . ViewModel , x => x . NodesCanvas . CommandRedo , x => x . ItemRedo ) . DisposeWith ( disposable ) ;
107107 this . BindCommand ( this . ViewModel , x => x . NodesCanvas . CommandSelectAll , x => x . ItemSelectAll ) . DisposeWith ( disposable ) ;
108108
109-
110- this . WhenAnyValue ( x => x . NodesCanvas . ViewModel . Messages . Count ) . Subscribe ( _=> UpdateLabels ( ) ) ;
111- //var informationCount = this.ObservableForProperty(x => x.NodesCanvas.ViewModel.Messages).Select(x=>x.Value.Where(x=>x.TypeMessage==TypeMessage.Information).Count().ToString());
112- ////var SelectedItem = this.ObservableForProperty(x => x.NodesCanvas.ViewModel.Messages).Select(x=>x.);
113- //this.OneWayBind(this.ViewModel, x => informationCount, x => x.LabelError.Content).DisposeWith(disposable);
114-
115- //informationCount.WhenAnyValue().Sub
116- //this.LabelError.Content.
117- //this.LabelError.Events().PreviewMouseLeftButtonDown.Subscribe(e => SetDisplayMessageType(e, TypeMessage.Error)).DisposeWith(disposable);
118- //this.LabelInformation.Events().MouseLeftButtonDown.Subscribe(e => SetDisplayMessageType(e, TypeMessage.Information)).DisposeWith(disposable);
119- //this.LabelWarning.Events().MouseLeftButtonDown.Subscribe(e => SetDisplayMessageType(e, TypeMessage.Warning)).DisposeWith(disposable);
120- //this.LabelDebug.Events().MouseLeftButtonDown.Subscribe(e => SetDisplayMessageType(e, TypeMessage.Debug)).DisposeWith(disposable);
121-
122-
123- //ItemSave.Command = CommandSave;
124- //this.OneWayBind(this, x => x.CommandSave, x => x.ItemSave.Command).DisposeWith(disposable);
125-
126- //this.OneWayBind(this, x => x.CommandSave, x => x.BindingSave.Command).DisposeWith(disposable);
127-
128- //this.OneWayBind(this.ViewModel, x=>x.CommandCopyError, x=>x.BindingSave.Command)
129-
130-
131- //this.ItemSave.Inp
132-
133- //this.OneWayBind(this.NodesCanvas.ViewModel, x => x.CommandSave, x => x.BindingSave.Command);
134- //this.OneWayBind(this.NodesCanvas.ViewModel, x => x.CommandSave, x => x.BindingSave.Command);
135-
136-
137109 } ) ;
138110 }
139111 #endregion Setup Binding
@@ -144,8 +116,8 @@ private void SetupSubscriptions()
144116 {
145117 this . WhenActivated ( disposable =>
146118 {
147- this . WhenAnyValue ( x=> x . ViewModel . NodesCanvas . Path ) . Subscribe ( value=> UpdateSchemeName ( value ) ) . DisposeWith ( disposable ) ;
148-
119+ this . WhenAnyValue ( x=> x . ViewModel . NodesCanvas . SchemePath ) . Subscribe ( value=> UpdateSchemeName ( value ) ) . DisposeWith ( disposable ) ;
120+ this . WhenAnyValue ( x => x . NodesCanvas . ViewModel . Messages . Count ) . Subscribe ( _ => UpdateLabels ( ) ) ;
149121
150122 } ) ;
151123 }
@@ -160,39 +132,28 @@ private void UpdateSchemeName(string newName)
160132 }
161133 #endregion Setup Subscriptions
162134
163- #region Setup Commands
164-
165- public ReactiveCommand < Unit , Unit > CommandSave { get ; set ; }
166- private void SetupCommands ( )
167- {
168- this . WhenActivated ( disposable =>
169- {
170- CommandSave = ReactiveCommand . Create ( Save ) ;
171-
172- //this.Events().KeyUp.Where(x => x.Key == Key.S && (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))).Subscribe(_ => Save()).DisposeWith(disposable);
173- //this.Events().KeyUp.Where(x => x.Key == Key.F4 && (Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt))).Subscribe(_ => Close()).DisposeWith(disposable);
174- } ) ;
175- }
176- #endregion Setup Commands
177135
178136 #region SetupEvents
179137 private void SetupEvents ( )
180138 {
181139 this . WhenActivated ( disposable =>
182140 {
141+
183142 this . ItemExportToJPEG . Events ( ) . Click . Subscribe ( _ => ExportToImage ( ImageFormats . JPEG ) ) . DisposeWith ( disposable ) ;
184143 this . ItemExportToPNG . Events ( ) . Click . Subscribe ( _ => ExportToImage ( ImageFormats . PNG ) ) . DisposeWith ( disposable ) ;
185144
145+
186146 this . Header . Events ( ) . PreviewMouseLeftButtonDown . Subscribe ( e => HeaderClick ( e ) ) . DisposeWith ( disposable ) ;
187147 this . ButtonClose . Events ( ) . Click . Subscribe ( _ => WithoutSaving ( ButtonCloseClick ) ) . DisposeWith ( disposable ) ;
188148 this . ButtonMin . Events ( ) . Click . Subscribe ( e => ButtonMinClick ( e ) ) . DisposeWith ( disposable ) ;
189149 this . ButtonMax . Events ( ) . Click . Subscribe ( e => ButtonMaxClick ( e ) ) . DisposeWith ( disposable ) ;
190150
191151 this . ItemSave . Events ( ) . Click . Subscribe ( _ => Save ( ) ) . DisposeWith ( disposable ) ;
192152 this . ItemSaveAs . Events ( ) . Click . Subscribe ( _ => SaveAs ( ) ) . DisposeWith ( disposable ) ;
193- this . ItemOpen . Events ( ) . Click . Subscribe ( async _ => await WithoutSavingAsync ( OpenAsync ) ) . DisposeWith ( disposable ) ;
153+ this . ItemOpen . Events ( ) . Click . Subscribe ( _ => WithoutSaving ( Open ) ) . DisposeWith ( disposable ) ;
194154 this . ItemExit . Events ( ) . Click . Subscribe ( _=> WithoutSaving ( ButtonCloseClick ) ) . DisposeWith ( disposable ) ;
195155 this . ItemNew . Events ( ) . Click . Subscribe ( _ => WithoutSaving ( New ) ) . DisposeWith ( disposable ) ;
156+
196157 this . ErrorListExpander . Events ( ) . Collapsed . Subscribe ( _=> ErrorListCollapse ( ) ) . DisposeWith ( disposable ) ;
197158 this . ErrorListExpander . Events ( ) . Expanded . Subscribe ( _ => ErrorListExpanded ( ) ) . DisposeWith ( disposable ) ;
198159
@@ -300,7 +261,7 @@ void ExportToImage(ImageFormats format)
300261 dlg . FileName = SchemeName ( ) ;
301262 dlg . Filter = ( format == ImageFormats . JPEG ) ? "JPEG Image (.jpeg)|*.jpeg" : "Png Image (.png)|*.png" ;
302263
303- DialogResult dialogResult = dlg . ShowDialog ( ) ;
264+ System . Windows . Forms . DialogResult dialogResult = dlg . ShowDialog ( ) ;
304265 if ( dialogResult == System . Windows . Forms . DialogResult . OK )
305266 {
306267 this . NodesCanvas . SaveCanvasToImage ( dlg . FileName , format ) ;
@@ -321,62 +282,55 @@ void WithoutSaving(Action action)
321282 if ( result == MessageBoxResult . Yes )
322283 action . Invoke ( ) ;
323284 }
324- async Task WithoutSavingAsync ( Func < Task > action )
325- {
326- var result = MessageBoxResult . Yes ;
327- if ( ! this . NodesCanvas . ViewModel . ItSaved )
328- {
329- result = System . Windows . MessageBox . Show ( "Exit without saving ?" , "Test" , MessageBoxButton . YesNo ) ;
330- }
331285
332- if ( result == MessageBoxResult . Yes )
333- await action . Invoke ( ) ;
334- }
335286 void Save ( )
336287 {
337- if ( string . IsNullOrEmpty ( this . ViewModel . NodesCanvas . Path ) )
288+ if ( string . IsNullOrEmpty ( this . ViewModel . NodesCanvas . SchemePath ) )
338289 {
339290 SaveAs ( ) ;
340291 }
341292 else
342293 {
343- this . NodesCanvas . ViewModel . CommandSave . ExecuteWithSubscribe ( this . ViewModel . NodesCanvas . Path ) ;
294+ this . NodesCanvas . ViewModel . CommandSave . ExecuteWithSubscribe ( this . ViewModel . NodesCanvas . SchemePath ) ;
344295 }
345296 }
346297 void SaveAs ( )
347298 {
348299 SaveFileDialog dlg = new SaveFileDialog ( ) ;
349300 dlg . FileName = SchemeName ( ) ;
350301 dlg . Filter = "XML-File | *.xml" ;
351-
352- DialogResult dialogResult = dlg . ShowDialog ( ) ;
302+
303+ System . Windows . Forms . DialogResult dialogResult = dlg . ShowDialog ( ) ;
353304 if ( dialogResult == System . Windows . Forms . DialogResult . OK )
354305 {
306+ Mouse . OverrideCursor = System . Windows . Input . Cursors . Wait ;
355307 this . NodesCanvas . ViewModel . CommandSave . ExecuteWithSubscribe ( dlg . FileName ) ;
308+ Mouse . OverrideCursor = null ;
356309 }
357310 }
358311 private string SchemeName ( )
359312 {
360- if ( ! string . IsNullOrEmpty ( this . ViewModel . NodesCanvas . Path ) )
313+ if ( ! string . IsNullOrEmpty ( this . ViewModel . NodesCanvas . SchemePath ) )
361314 {
362- return Path . GetFileNameWithoutExtension ( this . ViewModel . NodesCanvas . Path ) ;
315+ return Path . GetFileNameWithoutExtension ( this . ViewModel . NodesCanvas . SchemePath ) ;
363316 }
364317 else
365318 {
366319 return "SimpleStateMachine" ;
367320 }
368321 }
369- async Task OpenAsync ( )
322+ private void Open ( )
370323 {
371324 OpenFileDialog dlg = new OpenFileDialog ( ) ;
372325 dlg . FileName = SchemeName ( ) ;
373326 dlg . Filter = "XML-File | *.xml" ;
374327
375- DialogResult dialogResult = dlg . ShowDialog ( ) ;
328+ System . Windows . Forms . DialogResult dialogResult = dlg . ShowDialog ( ) ;
376329 if ( dialogResult == System . Windows . Forms . DialogResult . OK )
377330 {
378- //this.NodesCanvas.ViewModel.CommandOpen.ExecuteWithSubscribe(dlg.FileName);
379- await this . NodesCanvas . ViewModel . CommandOpen . Execute ( dlg . FileName ) ;
331+ Mouse . OverrideCursor = System . Windows . Input . Cursors . Wait ;
332+ this . NodesCanvas . ViewModel . CommandOpen . ExecuteWithSubscribe ( dlg . FileName ) ;
333+ Mouse . OverrideCursor = null ;
380334 }
381335
382336 }
0 commit comments