3030
3131namespace RevitDBExplorer
3232{
33- internal partial class MainWindow : Window , INotifyPropertyChanged , IRecipient < OpenWindowCommand >
33+ internal partial class MainWindow : Window , INotifyPropertyChanged , IRecipient < OpenWindowCommand > , IRecipient < RunQueryCommand >
3434 {
3535 private readonly IMessenger iAmMessenger ;
3636 private readonly QueryEditorViewModel queryEditorVM ;
@@ -149,7 +149,7 @@ public MainWindow()
149149
150150 queryEditorVM = new QueryEditorViewModel ( TryQueryDatabase , GenerateScriptForQueryAndOpenRDS ) ;
151151 queryVisualizationVM = new QueryVisualizationVM ( ) ;
152- workspacesVM = new WorkspacesViewModel ( iAmMessenger , queryEditorVM , OpenRDSWithGivenScript ) ;
152+ workspacesVM = new WorkspacesViewModel ( iAmMessenger , OpenRDSWithGivenScript ) ;
153153 visualizationsManagerVM = new VisualizationsManagerVM ( rvController ) ;
154154
155155 InitializeComponent ( ) ;
@@ -165,7 +165,20 @@ public MainWindow()
165165 globalKeyboardHook . KeyDown += GlobalKeyboardHook_KeyDown ;
166166 }
167167
168-
168+
169+ public void Receive ( OpenWindowCommand cmd )
170+ {
171+ SaveUserSettings ( ) ;
172+ var window = new MainWindow ( cmd . sourceOfObjects ) ;
173+ window . Owner = this ;
174+ window . Show ( ) ;
175+ }
176+ public void Receive ( RunQueryCommand cmd )
177+ {
178+ queryEditorVM . Query ( cmd . query ) ;
179+ }
180+
181+
169182 private async Task InitializeAsync ( )
170183 {
171184 ( IsNewVerAvailable , NewVersionLink ) = await VersionChecker . CheckIfNewVersionIsAvailable ( ) ;
@@ -225,13 +238,7 @@ private void Workspaces_SelectedItemChanged(SelectedItemChangedEventArgs obj)
225238 {
226239 UpdateVisualizations ( ) ;
227240 }
228- public void Receive ( OpenWindowCommand cmd )
229- {
230- SaveUserSettings ( ) ;
231- var window = new MainWindow ( cmd . sourceOfObjects ) ;
232- window . Owner = this ;
233- window . Show ( ) ;
234- }
241+
235242 private async void TryQueryDatabase ( string query )
236243 {
237244 Workspaces . Reset ( ) ;
@@ -422,4 +429,6 @@ protected virtual void OnPropertyChanged([CallerMemberName] String propertyName
422429 }
423430
424431 internal sealed record OpenWindowCommand ( SourceOfObjects sourceOfObjects ) ;
432+ internal sealed record RunQueryCommand ( string query ) ;
433+
425434}
0 commit comments