Skip to content

Commit b6cc5a4

Browse files
committed
refactoring
1 parent 923de8c commit b6cc5a4

File tree

7 files changed

+48
-17
lines changed

7 files changed

+48
-17
lines changed

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Yet another [RevitLookup](https://github.com/jeremytammik/RevitLookup) like tool. RevitLookup was an indispensable tool to work with Revit API for many years. But now, there is a better tool for the job. Let me introduce you to Revit database explorer and its capabilities. It not only allows us to **explore** database but also to:
66
- **edit**, any parameter value
7-
- **query**, with intuitive syntax that is translated into a FilteredElementCollector
7+
- **query**, database with intuitive syntax that is translated into a FilteredElementCollector
88
- **script**, by running ad hoc scripts written in C#
99
- **visualize**, geometrical features of elements
1010

sources/RevitDBExplorer/Application.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@
1313
using RevitDBExplorer.Domain.DataModel.ValueContainers.Base;
1414
using RevitDBExplorer.Domain.RevitDatabaseQuery;
1515
using RevitDBExplorer.Properties;
16+
using RevitDBExplorer.Utils;
1617
using RevitDBScripting;
1718

1819
namespace RevitDBExplorer
1920
{
2021
public class Application : IExternalApplication, IScriptRunner
2122
{
23+
private static UIView UIView;
24+
private static View View;
2225
public static IntPtr RevitWindowHandle;
2326
public static UIApplication UIApplication;
2427
public static RDSController RDSController;
25-
private static UIView UIView;
26-
private static View View;
28+
2729

2830
public Application()
2931
{
@@ -59,10 +61,7 @@ public Result OnStartup(UIControlledApplication application)
5961
UIApplication.ViewActivated += UIApplication_ViewActivated;
6062

6163
return Result.Succeeded;
62-
}
63-
64-
65-
64+
}
6665
public Result OnShutdown(UIControlledApplication application)
6766
{
6867
application.Idling -= Application_Idling;
@@ -169,6 +168,7 @@ public static string GetMouseStatus()
169168
return "";
170169
}
171170

171+
172172
private static DateTime LastTimeWhenInCharge;
173173
private void Application_Idling(object sender, Autodesk.Revit.UI.Events.IdlingEventArgs e)
174174
{

sources/RevitDBExplorer/Command.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using System;
2-
using System.Linq;
32
using System.Collections.Generic;
3+
using System.Diagnostics;
4+
using System.Linq;
45
using Autodesk.Revit.Attributes;
56
using Autodesk.Revit.DB;
67
using Autodesk.Revit.UI;
78
using RevitDBExplorer.Domain.Selectors;
8-
using System.Diagnostics;
99

1010
namespace RevitDBExplorer
1111
{

sources/RevitDBExplorer/ConfigWindow.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Windows.Controls;
99
using RevitDBExplorer.Domain.RevitDatabaseQuery.Autocompletion;
1010
using RevitDBExplorer.Properties;
11+
using RevitDBExplorer.Utils;
1112
using RevitDBExplorer.WPF;
1213

1314
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md

sources/RevitDBExplorer/MainWindow.xaml.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
using System.Windows.Threading;
1111
using RevitDBExplorer.Augmentations;
1212
using RevitDBExplorer.Domain;
13+
using RevitDBExplorer.Domain.DataModel.ValueViewModels;
1314
using RevitDBExplorer.Domain.RevitDatabaseQuery;
1415
using RevitDBExplorer.Domain.RevitDatabaseScripting;
1516
using RevitDBExplorer.Domain.Selectors;
1617
using RevitDBExplorer.Properties;
1718
using RevitDBExplorer.UIComponents.Breadcrumbs;
1819
using RevitDBExplorer.UIComponents.List;
20+
using RevitDBExplorer.UIComponents.List.ViewModels;
1921
using RevitDBExplorer.UIComponents.QueryEditor;
2022
using RevitDBExplorer.UIComponents.QueryVisualization;
2123
using RevitDBExplorer.UIComponents.Trees.Base;
@@ -47,7 +49,7 @@ internal partial class MainWindow : Window, IAmWindowOpener, INotifyPropertyChan
4749
private string newVersionLink;
4850
private bool isWiderThan800px;
4951
private string mouseStatus;
50-
private string rdqGeneratedCSharpSyntax;
52+
private string rdqGeneratedCSharpSyntax = "";
5153

5254

5355
public QueryEditorViewModel QueryEditor => queryEditorVM;
@@ -172,9 +174,13 @@ public MainWindow()
172174
ExplorerTree.ScriptWasGenerated += OpenRDSWithGivenScript;
173175
UtilityTree.SelectedItemChanged += Tree_SelectedItemChanged;
174176
UtilityTree.ScriptWasGenerated += OpenRDSWithGivenScript;
177+
List.SelectedItemChanged += List_SelectedItemChanged;
175178

176179
rdvController = RevitDatabaseVisualizationFactory.CreateController();
177180
}
181+
182+
183+
178184
private async Task InitializeAsync()
179185
{
180186
(IsNewVerAvailable, NewVersionLink) = await VersionChecker.CheckIfNewVersionIsAvailable();
@@ -280,6 +286,21 @@ private async void Tree_SelectedItemChanged(SelectedItemChangedEventArgs eventAr
280286
}
281287
RightView = RightView.None;
282288
}
289+
private void List_SelectedItemChanged(ListSelectedItemChangedEventArgs args)
290+
{
291+
if (args.NewOne is ListItemForMember listItemForMember)
292+
{
293+
var leftOne = listItemForMember[0];
294+
var righttOne = listItemForMember[1];
295+
296+
if (leftOne?.ValueViewModel is DefaultPresenter { ValueContainer: { } } presenter)
297+
{
298+
var v = presenter.ValueContainer.GetVisualization();
299+
300+
//return Enumerable.Empty<DrawingVisual>();
301+
}
302+
}
303+
}
283304
bool ignoreEvents = false;
284305
void IAmWindowOpener.Open(SourceOfObjects sourceOfObjects)
285306
{
@@ -364,7 +385,8 @@ private void Window_Closed(object sender, EventArgs e)
364385
ExplorerTree.SelectedItemChanged -= Tree_SelectedItemChanged;
365386
ExplorerTree.ScriptWasGenerated -= OpenRDSWithGivenScript;
366387
UtilityTree.SelectedItemChanged -= Tree_SelectedItemChanged;
367-
UtilityTree.ScriptWasGenerated -= OpenRDSWithGivenScript;
388+
UtilityTree.ScriptWasGenerated -= OpenRDSWithGivenScript;
389+
List.SelectedItemChanged -= List_SelectedItemChanged;
368390
}
369391
private void Window_Closing(object sender, EventArgs e)
370392
{

sources/RevitDBExplorer/UIComponents/List/ListVM.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using RevitDBExplorer.Domain.DataModel.ValueViewModels.Base;
1212
using RevitDBExplorer.UIComponents.List.ViewModels;
1313
using RevitDBExplorer.UIComponents.List.WPF;
14+
using RevitDBExplorer.UIComponents.Trees.Base;
1415
using RevitDBExplorer.UIComponents.Trees.Base.Items;
1516
using RevitDBExplorer.WPF;
1617

@@ -64,11 +65,17 @@ public IListItem ListSelectedItem
6465
return listSelectedItem;
6566
}
6667
set
67-
{
68-
listSelectedItem = value;
68+
{
69+
if (listSelectedItem != value)
70+
{
71+
var oldOne = listSelectedItem;
72+
listSelectedItem = value;
73+
SelectedItemChanged?.Invoke(new ListSelectedItemChangedEventArgs(oldOne, listSelectedItem));
74+
}
6975
OnPropertyChanged();
7076
}
7177
}
78+
public event Action<ListSelectedItemChangedEventArgs> SelectedItemChanged;
7279
public RelayCommand KeyDown_Enter_Command { get; }
7380
public RelayCommand ListItem_Click_Command { get; }
7481
public RelayCommand ReloadCommand { get; }
@@ -381,6 +388,7 @@ private async void Reload()
381388
}
382389
}
383390

391+
internal record class ListSelectedItemChangedEventArgs(IListItem OldOne, IListItem NewOne);
384392
internal interface IAmWindowOpener
385393
{
386394
void Open(SourceOfObjects sourceOfObjects);

sources/RevitDBExplorer/ApplicationModifyTab.cs renamed to sources/RevitDBExplorer/Utils/ApplicationModifyTab.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using Autodesk.Windows;
22
using RevitDBExplorer.Domain;
33

4-
namespace RevitDBExplorer
4+
namespace RevitDBExplorer.Utils
55
{
66
public static class ApplicationModifyTab
77
{
8-
private static Autodesk.Windows.RibbonPanel ribbonPanel;
8+
private static RibbonPanel ribbonPanel;
99

1010

11-
public static void Init(Autodesk.Windows.RibbonPanel ribbonPanel, bool visible = false)
11+
public static void Init(RibbonPanel ribbonPanel, bool visible = false)
1212
{
1313
ApplicationModifyTab.ribbonPanel = ribbonPanel.Clone();
1414
UpdateInternal(visible);
@@ -21,7 +21,7 @@ public static void Update(bool visible)
2121

2222
private static void UpdateInternal(bool visible)
2323
{
24-
if (ApplicationModifyTab.ribbonPanel is null) return;
24+
if (ribbonPanel is null) return;
2525

2626
var tab = ComponentManager.Ribbon.FindTab("Modify");
2727
if (tab is null) return;

0 commit comments

Comments
 (0)