diff --git a/sources/RevitDBExplorer/MainWindow.xaml b/sources/RevitDBExplorer/MainWindow.xaml
index cc94c21..11b37b8 100644
--- a/sources/RevitDBExplorer/MainWindow.xaml
+++ b/sources/RevitDBExplorer/MainWindow.xaml
@@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:componentQueryEditor="clr-namespace:RevitDBExplorer.UIComponents.QueryEditor"
xmlns:componentQueryVisualization="clr-namespace:RevitDBExplorer.UIComponents.QueryVisualization"
xmlns:componentBusyIndicator="clr-namespace:RevitDBExplorer.UIComponents.BusyIndicator"
xmlns:componentList="clr-namespace:RevitDBExplorer.UIComponents.List"
@@ -12,8 +13,7 @@
xmlns:componentCAndC="clr-namespace:RevitDBExplorer.UIComponents.CommandAndControl"
xmlns:componentScripting="clr-namespace:RevitDBExplorer.UIComponents.Scripting"
xmlns:componentBreadcrumbs="clr-namespace:RevitDBExplorer.UIComponents.Breadcrumbs"
- xmlns:converters="clr-namespace:RevitDBExplorer.WPF.Converters"
- xmlns:controls="clr-namespace:RevitDBExplorer.WPF.Controls"
+ xmlns:converters="clr-namespace:RevitDBExplorer.WPF.Converters"
xmlns:ext="clr-namespace:RevitDBExplorer.WPF.MarkupExtensions"
xmlns:wpf="clr-namespace:RevitDBExplorer.WPF"
xmlns:ap="clr-namespace:RevitDBExplorer.WPF.AttachedProperties"
@@ -47,11 +47,6 @@
-
@@ -207,40 +202,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
@@ -297,13 +263,13 @@
-
+
-
-
+
+
diff --git a/sources/RevitDBExplorer/MainWindow.xaml.cs b/sources/RevitDBExplorer/MainWindow.xaml.cs
index 48c48be..16da421 100644
--- a/sources/RevitDBExplorer/MainWindow.xaml.cs
+++ b/sources/RevitDBExplorer/MainWindow.xaml.cs
@@ -11,12 +11,12 @@
using RevitDBExplorer.Augmentations;
using RevitDBExplorer.Domain;
using RevitDBExplorer.Domain.RevitDatabaseQuery;
-using RevitDBExplorer.Domain.RevitDatabaseQuery.Autocompletion;
using RevitDBExplorer.Domain.RevitDatabaseScripting;
using RevitDBExplorer.Domain.Selectors;
using RevitDBExplorer.Properties;
using RevitDBExplorer.UIComponents.Breadcrumbs;
using RevitDBExplorer.UIComponents.List;
+using RevitDBExplorer.UIComponents.QueryEditor;
using RevitDBExplorer.UIComponents.QueryVisualization;
using RevitDBExplorer.UIComponents.Trees.Base;
using RevitDBExplorer.UIComponents.Trees.Base.Items;
@@ -24,8 +24,6 @@
using RevitDBExplorer.UIComponents.Trees.Utility;
using RevitDBExplorer.Utils;
using RevitDBExplorer.WPF;
-using RevitDBExplorer.WPF.Controls;
-using RDQCommand = RevitDBExplorer.Domain.RevitDatabaseQuery.Parser.Command;
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md
@@ -33,32 +31,31 @@ namespace RevitDBExplorer
{
internal enum RightView { None, List, CommandAndControl, CompareAndPinToolInfo }
- internal partial class MainWindow : Window, IAmWindowOpener, IAmQueryExecutor, INotifyPropertyChanged
+ internal partial class MainWindow : Window, IAmWindowOpener, INotifyPropertyChanged
{
- private readonly ExplorerTreeViewModel explorerTreeViewModel = new();
- private readonly UtilityTreeViewModel utilityTreeViewModel = new();
- private readonly ListVM listVM;
- private readonly QueryVisualizationVM queryVisualizationVM = new();
- private readonly BreadcrumbsVM breadcrumbs;
- private RightView rightView;
- private string databaseQuery = string.Empty;
- private string databaseQueryToolTip = string.Empty;
- private bool isPopupOpen;
+ private readonly QueryEditorViewModel queryEditorVM;
+ private readonly QueryVisualizationVM queryVisualizationVM = new();
+ private readonly ExplorerTreeViewModel explorerTreeVM = new();
+ private readonly UtilityTreeViewModel utilityTreeVM = new();
+ private readonly ListVM listVM;
+ private readonly BreadcrumbsVM breadcrumbsVM;
+ private readonly DispatcherTimer isRevitBusyDispatcher;
+ private readonly IRDV3DController rdvController;
+ private RightView rightView;
private bool isRevitBusy;
private bool isNewVerAvailable;
private string newVersionLink;
private bool isWiderThan800px;
private string mouseStatus;
- private readonly DispatcherTimer isRevitBusyDispatcher;
- private readonly IAutocompleteItemProvider databaseQueryAutocompleteItemProvider = new AutocompleteItemProvider();
- private readonly IRDV3DController rdvController;
+ private string rdqGeneratedCSharpSyntax;
- public ExplorerTreeViewModel ExplorerTree => explorerTreeViewModel;
- public UtilityTreeViewModel UtilityTree => utilityTreeViewModel;
+ public QueryEditorViewModel QueryEditor => queryEditorVM;
+ public ExplorerTreeViewModel ExplorerTree => explorerTreeVM;
+ public UtilityTreeViewModel UtilityTree => utilityTreeVM;
public ListVM List => listVM;
public QueryVisualizationVM QueryVisualization => queryVisualizationVM;
- public BreadcrumbsVM Breadcrumbs => breadcrumbs;
+ public BreadcrumbsVM Breadcrumbs => breadcrumbsVM;
public RightView RightView
{
get
@@ -71,46 +68,6 @@ public RightView RightView
OnPropertyChanged();
}
}
- public string DatabaseQuery
- {
- get
- {
- return databaseQuery;
- }
- set
- {
- databaseQuery = value;
- if (IsPopupOpen == false)
- {
- TryQueryDatabase(value);
- }
- OnPropertyChanged();
- }
- }
- public string DatabaseQueryToolTip
- {
- get
- {
- return databaseQueryToolTip;
- }
- set
- {
- databaseQueryToolTip = value;
- OnPropertyChanged();
- }
- }
- public bool IsPopupOpen
- {
- get
- {
- return isPopupOpen;
- }
- set
- {
- isPopupOpen = value;
- OnPropertyChanged();
- }
- }
public bool IsRevitBusy
{
get
@@ -173,15 +130,8 @@ public string MouseStatus
mouseStatus = value;
OnPropertyChanged();
}
- }
- public IAutocompleteItemProvider DatabaseQueryAutocompleteItemProvider
- {
- get
- {
- return databaseQueryAutocompleteItemProvider;
- }
- }
- public bool IsBoundingBoxVisualizerEnabled
+ }
+ public bool IsRDVEnabled
{
get
{
@@ -194,9 +144,7 @@ public bool IsBoundingBoxVisualizerEnabled
OnPropertyChanged();
}
}
- public RelayCommand OpenScriptingWithQueryCommand { get; }
- public RelayCommand SaveQueryAsFavoriteCommand { get; }
-
+
public MainWindow(SourceOfObjects sourceOfObjects, IntPtr? parentWindowHandle = null) : this()
{
@@ -209,25 +157,22 @@ public MainWindow(SourceOfObjects sourceOfObjects, IntPtr? parentWindowHandle =
public MainWindow()
{
Dispatcher.UnhandledException += Dispatcher_UnhandledException;
- listVM = new ListVM(this, this);
- breadcrumbs = new BreadcrumbsVM();
+ queryEditorVM = new QueryEditorViewModel(TryQueryDatabase, GenerateScriptForQueryAndOpenRDS);
+ listVM = new ListVM(this, queryEditorVM);
+ breadcrumbsVM = new BreadcrumbsVM();
InitializeComponent();
InitializeAsync().Forget();
-
this.DataContext = this;
Title = WindowTitleGenerator.Get();
-
isRevitBusyDispatcher = new DispatcherTimer(TimeSpan.FromMilliseconds(500), DispatcherPriority.Background, IsRevitBusyDispatcher_Tick, Dispatcher.CurrentDispatcher);
ExplorerTree.SelectedItemChanged += Tree_SelectedItemChanged;
ExplorerTree.ScriptWasGenerated += OpenRDSWithGivenScript;
UtilityTree.SelectedItemChanged += Tree_SelectedItemChanged;
UtilityTree.ScriptWasGenerated += OpenRDSWithGivenScript;
-
- OpenScriptingWithQueryCommand = new RelayCommand(GenerateScriptForQueryAndOpenRDS);
- SaveQueryAsFavoriteCommand = new RelayCommand(SaveQueryAsFavorite, x => !string.IsNullOrEmpty(DatabaseQuery) );
+
rdvController = RevitDatabaseVisualizationFactory.CreateController();
}
private async Task InitializeAsync()
@@ -356,15 +301,11 @@ private async void TryQueryDatabase(string query)
return result;
});
- DatabaseQueryToolTip = rdqResult.GeneratedCSharpSyntax;
+ rdqGeneratedCSharpSyntax = rdqResult.GeneratedCSharpSyntax;
QueryVisualization.Update(rdqResult.Commands).Forget();
ExplorerTree.PopulateTreeView(rdqResult.SourceOfObjects);
}
- void IAmQueryExecutor.Query(string query)
- {
- DatabaseQuery = query;
- }
-
+
private void PopulateExplorerTree(SourceOfObjects sourceOfObjects)
{
@@ -373,16 +314,11 @@ private void PopulateExplorerTree(SourceOfObjects sourceOfObjects)
}
private void ResetDatabaseQuery()
{
- databaseQuery = "";
- OnPropertyChanged(nameof(DatabaseQuery));
- DatabaseQueryToolTip = "";
- QueryVisualization.Update(Enumerable.Empty()).Forget();
- }
- private void SaveQueryAsFavorite()
- {
- FavoritesManager.Add(DatabaseQuery);
+ QueryEditor.ResetDatabaseQuery();
+ rdqGeneratedCSharpSyntax = "";
+ QueryVisualization.Reset().Forget();
}
-
+
private void UpdateRDV()
{
@@ -401,9 +337,9 @@ private void UpdateRDV()
private void GenerateScriptForQueryAndOpenRDS()
{
- var scriptText = CodeGenerator.GenerateQueryFor(DatabaseQueryToolTip);
+ var scriptText = CodeGenerator.GenerateQueryFor(rdqGeneratedCSharpSyntax);
OpenRDSWithGivenScript(scriptText);
- }
+ }
private void OpenRDSWithGivenScript(string scriptText)
{
OpenRDS();
diff --git a/sources/RevitDBExplorer/UIComponents/QueryEditor/QueryEditorView.xaml b/sources/RevitDBExplorer/UIComponents/QueryEditor/QueryEditorView.xaml
new file mode 100644
index 0000000..e48d271
--- /dev/null
+++ b/sources/RevitDBExplorer/UIComponents/QueryEditor/QueryEditorView.xaml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sources/RevitDBExplorer/UIComponents/QueryEditor/QueryEditorView.xaml.cs b/sources/RevitDBExplorer/UIComponents/QueryEditor/QueryEditorView.xaml.cs
new file mode 100644
index 0000000..952600c
--- /dev/null
+++ b/sources/RevitDBExplorer/UIComponents/QueryEditor/QueryEditorView.xaml.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace RevitDBExplorer.UIComponents.QueryEditor
+{
+ ///
+ /// Interaction logic for QueryEditorView.xaml
+ ///
+ public partial class QueryEditorView : UserControl
+ {
+ public QueryEditorView()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/sources/RevitDBExplorer/UIComponents/QueryEditor/QueryEditorViewModel.cs b/sources/RevitDBExplorer/UIComponents/QueryEditor/QueryEditorViewModel.cs
new file mode 100644
index 0000000..0c888b3
--- /dev/null
+++ b/sources/RevitDBExplorer/UIComponents/QueryEditor/QueryEditorViewModel.cs
@@ -0,0 +1,101 @@
+using System;
+using RevitDBExplorer.Domain.RevitDatabaseQuery.Autocompletion;
+using RevitDBExplorer.Domain.RevitDatabaseScripting;
+using RevitDBExplorer.UIComponents.List;
+using RevitDBExplorer.WPF;
+using RevitDBExplorer.WPF.Controls;
+
+// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md
+
+namespace RevitDBExplorer.UIComponents.QueryEditor
+{
+ internal class QueryEditorViewModel : BaseViewModel, IAmQueryExecutor
+ {
+ private readonly IAutocompleteItemProvider databaseQueryAutocompleteItemProvider = new AutocompleteItemProvider();
+ private readonly Action tryQueryDatabase;
+ private bool isPopupOpen;
+ private string databaseQuery = string.Empty;
+ private string databaseQueryToolTip = string.Empty;
+
+
+
+ public bool IsPopupOpen
+ {
+ get
+ {
+ return isPopupOpen;
+ }
+ set
+ {
+ isPopupOpen = value;
+ OnPropertyChanged();
+ }
+ }
+ public string DatabaseQuery
+ {
+ get
+ {
+ return databaseQuery;
+ }
+ set
+ {
+ databaseQuery = value;
+ if (IsPopupOpen == false)
+ {
+ tryQueryDatabase(value);
+ }
+ OnPropertyChanged();
+ }
+ }
+ public string DatabaseQueryToolTip
+ {
+ get
+ {
+ return databaseQueryToolTip;
+ }
+ set
+ {
+ databaseQueryToolTip = value;
+ OnPropertyChanged();
+ }
+ }
+
+ public IAutocompleteItemProvider DatabaseQueryAutocompleteItemProvider
+ {
+ get
+ {
+ return databaseQueryAutocompleteItemProvider;
+ }
+ }
+ public RelayCommand OpenScriptingWithQueryCommand { get; }
+ public RelayCommand SaveQueryAsFavoriteCommand { get; }
+
+
+
+
+ public QueryEditorViewModel(Action tryQueryDatabase, Action generateScriptForQueryAndOpenRDS)
+ {
+ this.tryQueryDatabase = tryQueryDatabase;
+
+ OpenScriptingWithQueryCommand = new RelayCommand(generateScriptForQueryAndOpenRDS);
+ SaveQueryAsFavoriteCommand = new RelayCommand(SaveQueryAsFavorite, x => !string.IsNullOrEmpty(DatabaseQuery));
+ }
+
+ public void ResetDatabaseQuery()
+ {
+ databaseQuery = "";
+ OnPropertyChanged(nameof(DatabaseQuery));
+ }
+ void IAmQueryExecutor.Query(string query)
+ {
+ DatabaseQuery = query;
+ }
+
+
+
+ private void SaveQueryAsFavorite()
+ {
+ FavoritesManager.Add(DatabaseQuery);
+ }
+ }
+}
diff --git a/sources/RevitDBExplorer/UIComponents/QueryVisualization/QueryVisualizationVM.cs b/sources/RevitDBExplorer/UIComponents/QueryVisualization/QueryVisualizationVM.cs
index 553b8f5..449e7ed 100644
--- a/sources/RevitDBExplorer/UIComponents/QueryVisualization/QueryVisualizationVM.cs
+++ b/sources/RevitDBExplorer/UIComponents/QueryVisualization/QueryVisualizationVM.cs
@@ -91,5 +91,9 @@ public async Task Update(IEnumerable commands)
semaphore.Release();
}
}
+ public async Task Reset()
+ {
+ await Update(Enumerable.Empty());
+ }
}
}
\ No newline at end of file