Skip to content

Commit b99314d

Browse files
committed
refactoring
1 parent 321edaf commit b99314d

File tree

12 files changed

+78
-254
lines changed

12 files changed

+78
-254
lines changed

sources/RevitDBExplorer/Application.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static string GetMouseStatus()
112112
{
113113
var uiView = Application.UIView;
114114
var view = Application.View;
115-
if ((uiView != null) && (view != null) && (view.IsValidObject) && (uiView.IsValidObject))
115+
if ((uiView != null) && (view != null) && (view.IsValidObject) && (uiView.IsValidObject) && (view.DetailLevel != ViewDetailLevel.Undefined))
116116
{
117117
// source : https://thebuildingcoder.typepad.com/blog/2012/10/uiview-windows-coordinates-referenceintersector-and-my-own-tooltip.html
118118

@@ -148,7 +148,18 @@ public static string GetMouseStatus()
148148
return "(,,?)";
149149
}
150150

151-
return $"({q.X:f3}, {q.Y:f3}, {q.Z:f3})";
151+
if (view.ViewDirection.IsParallelTo(XYZ.BasisX))
152+
{
153+
return $"(-,--, {q.Y:f3}, {q.Z:f3})";
154+
}
155+
if (view.ViewDirection.IsParallelTo(XYZ.BasisY))
156+
{
157+
return $"({q.X:f3}, -,--, {q.Z:f3})";
158+
}
159+
if (view.ViewDirection.IsParallelTo(XYZ.BasisZ))
160+
{
161+
return $"({q.X:f3}, {q.Y:f3}, -,--)";
162+
}
152163
}
153164
catch
154165
{

sources/RevitDBExplorer/Domain/DataModel/ValueContainers/ElementHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected override IEnumerable<DrawingVisual> GetVisualization(SnoopableContext
4040
{
4141
var bb = element.get_BoundingBox(null);
4242

43-
if ((bb != null) && (bb.IsSet))
43+
if (bb != null && (bb.Max != null) && (bb.Min != null))
4444
{
4545
yield return new BoundingBox(bb.Min, bb.Max);
4646
}

sources/RevitDBExplorer/Domain/RevitDatabaseView/Cell.cs

Lines changed: 0 additions & 79 deletions
This file was deleted.

sources/RevitDBExplorer/Domain/RevitDatabaseView/Column.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

sources/RevitDBExplorer/Domain/RevitDatabaseView/Row.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

sources/RevitDBExplorer/Domain/RevitDatabaseView/View.cs

Lines changed: 0 additions & 53 deletions
This file was deleted.

sources/RevitDBExplorer/Domain/VersionChecker.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Net.Http;
33
using System.Net.Http.Json;
4+
using System.Reflection;
45
using System.Threading.Tasks;
56

67
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md
@@ -9,10 +10,11 @@ namespace RevitDBExplorer.Domain
910
{
1011
internal static class VersionChecker
1112
{
12-
public async static Task<(bool, string)> Check(Version ver)
13+
public async static Task<(bool, string)> CheckIfNewVersionIsAvailable()
1314
{
1415
try
1516
{
17+
var ver = Assembly.GetExecutingAssembly().GetName().Version;
1618
var curentVer = ver.ToGitHubTag();
1719

1820
var httpClient = new HttpClient();
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System;
2+
3+
// (c) Revit Database Explorer https://github.com/NeVeSpl/RevitDBExplorer/blob/main/license.md
4+
5+
namespace Autodesk.Revit.DB
6+
{
7+
public static class XYZExtensions
8+
{
9+
public static bool IsParallelTo(this XYZ first, XYZ second)
10+
{
11+
return first.CrossProduct(second).IsZeroLength();
12+
}
13+
14+
public static bool IsPerpendicularTo(this XYZ first, XYZ second)
15+
{
16+
return Math.Abs(first.DotProduct(second)) < 1e-6;
17+
}
18+
19+
public static bool IsCodirectionalTo(this XYZ first, XYZ second)
20+
{
21+
var dotProduct = first.Normalize().DotProduct(second.Normalize());
22+
23+
return Math.Abs(dotProduct - 1.0) < 1e-6;
24+
}
25+
}
26+
}

sources/RevitDBExplorer/MainWindow.xaml.cs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using RevitDBExplorer.UIComponents.Trees.Base.Items;
2727
using RevitDBExplorer.UIComponents.Trees.Explorer;
2828
using RevitDBExplorer.UIComponents.Trees.Utility;
29+
using RevitDBExplorer.Utils;
2930
using RevitDBExplorer.WPF;
3031
using RevitDBExplorer.WPF.Controls;
3132
using RDQCommand = RevitDBExplorer.Domain.RevitDatabaseQuery.Parser.Command;
@@ -210,25 +211,29 @@ public MainWindow()
210211
listVM = new ListVM(this, this);
211212

212213
InitializeComponent();
214+
InitializeAsync().Forget();
215+
213216
this.DataContext = this;
214217
rdscriptingVM = new RDScriptingVM();
215218
breadcrumbs = new BreadcrumbsVM();
216219

217-
var ver = GetType().Assembly.GetName().Version;
218-
var revit_ver = typeof(Autodesk.Revit.DB.Element).Assembly.GetName().Version;
219-
Title += $" 20{revit_ver.Major} - {ver.ToGitHubTag()}";
220+
Title = WindowTitleGenerator.Get();
220221

221-
isRevitBusyDispatcher = new DispatcherTimer(TimeSpan.FromMilliseconds(500), DispatcherPriority.Background, IsRevitBusyDispatcher_Tick, Dispatcher.CurrentDispatcher);
222-
CheckIfNewVersionIsAvailable(ver).Forget();
222+
isRevitBusyDispatcher = new DispatcherTimer(TimeSpan.FromMilliseconds(500), DispatcherPriority.Background, IsRevitBusyDispatcher_Tick, Dispatcher.CurrentDispatcher);
223223

224224
ExplorerTree.SelectedItemChanged += Tree_SelectedItemChanged;
225-
ExplorerTree.ScriptForRDSHasChanged += RDSOpenWithCommand;
225+
ExplorerTree.ScriptWasGenerated += RDSOpenWithCommand;
226226
UtilityTree.SelectedItemChanged += Tree_SelectedItemChanged;
227-
UtilityTree.ScriptForRDSHasChanged += RDSOpenWithCommand;
227+
UtilityTree.ScriptWasGenerated += RDSOpenWithCommand;
228+
228229
OpenScriptingWithQueryCommand = new RelayCommand(RDSOpenWithQuery);
229230
SaveQueryAsFavoriteCommand = new RelayCommand(SaveQueryAsFavorite, x => !string.IsNullOrEmpty(DatabaseQuery) );
230231
rdvController = RevitDatabaseVisualizationFactory.CreateController();
231232
}
233+
private async Task InitializeAsync()
234+
{
235+
(IsNewVerAvailable, NewVersionLink) = await VersionChecker.CheckIfNewVersionIsAvailable();
236+
}
232237

233238

234239
private void IsRevitBusyDispatcher_Tick(object sender, EventArgs e)
@@ -251,14 +256,7 @@ private void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExc
251256
e.Exception.ShowErrorMsg("MainWindow::UnhandledException");
252257
e.Handled = true;
253258
}
254-
private async Task CheckIfNewVersionIsAvailable(Version ver)
255-
{
256-
(IsNewVerAvailable, var link) = await VersionChecker.Check(ver);
257-
if (IsNewVerAvailable)
258-
{
259-
NewVersionLink = link;
260-
}
261-
}
259+
262260
private async void SelectorButton_Click(object sender, RoutedEventArgs e)
263261
{
264262
ExplorerTree.ClearItems();
@@ -430,9 +428,9 @@ private void Window_Closed(object sender, EventArgs e)
430428
Dispatcher.UnhandledException -= Dispatcher_UnhandledException;
431429
isRevitBusyDispatcher.Tick -= IsRevitBusyDispatcher_Tick;
432430
ExplorerTree.SelectedItemChanged -= Tree_SelectedItemChanged;
433-
ExplorerTree.ScriptForRDSHasChanged -= RDSOpenWithCommand;
431+
ExplorerTree.ScriptWasGenerated -= RDSOpenWithCommand;
434432
UtilityTree.SelectedItemChanged -= Tree_SelectedItemChanged;
435-
UtilityTree.ScriptForRDSHasChanged -= RDSOpenWithCommand;
433+
UtilityTree.ScriptWasGenerated -= RDSOpenWithCommand;
436434
}
437435
private void Window_Closing(object sender, EventArgs e)
438436
{

0 commit comments

Comments
 (0)