Skip to content

Commit 22dbcf4

Browse files
committed
Cleanup
1 parent 5879b92 commit 22dbcf4

File tree

9 files changed

+131
-75
lines changed

9 files changed

+131
-75
lines changed

source/RevitLookup.Abstractions/ViewModels/Visualization/ICurveLoopVisualizationViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// RevitLookup.Abstractions/ViewModels/Visualization/ICurveLoopVisualizationViewModel.cs
21
using System.Windows.Media;
32

43
namespace RevitLookup.Abstractions.ViewModels.Visualization

source/RevitLookup.UI.Framework/Views/Visualization/CurveLoopVisualizationDialog.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
xmlns:colorPicker="clr-namespace:RevitLookup.UI.Framework.Controls.ColorPicker"
99
xmlns:local="clr-namespace:RevitLookup.UI.Framework.Views.Visualization"
1010
xmlns:visualization="clr-namespace:RevitLookup.Abstractions.ViewModels.Visualization;assembly=RevitLookup.Abstractions"
11-
Title="Curve Loop Visualization settings"
11+
Title="CurveLoop Visualization settings"
1212
DialogMaxWidth="470"
1313
VerticalContentAlignment="Center"
1414
mc:Ignorable="d"
@@ -21,6 +21,7 @@
2121
<ResourceDictionary.MergedDictionaries>
2222
<ui:ControlsDictionary />
2323
</ResourceDictionary.MergedDictionaries>
24+
<!-- ReSharper disable once Xaml.StaticResourceNotResolved -->
2425
<Style
2526
BasedOn="{StaticResource DefaultContentDialogStyle}"
2627
TargetType="{x:Type local:CurveLoopVisualizationDialog}" />

source/RevitLookup.UI.Framework/Views/Visualization/CurveLoopVisualizationDialog.xaml.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1-
// RevitLookup.UI.Framework/Views/Visualization/CurveLoopVisualizationDialog.xaml.cs
1+
// Copyright 2003-2024 by Autodesk, Inc.
2+
//
3+
// Permission to use, copy, modify, and distribute this software in
4+
// object code form for any purpose and without fee is hereby granted,
5+
// provided that the above copyright notice appears in all copies and
6+
// that both that copyright notice and the limited warranty and
7+
// restricted rights notice below appear in all supporting
8+
// documentation.
9+
//
10+
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
11+
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
12+
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
13+
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
14+
// UNINTERRUPTED OR ERROR FREE.
15+
//
16+
// Use, duplication, or disclosure by the U.S. Government is subject to
17+
// restrictions set forth in FAR 52.227-19 (Commercial Computer
18+
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
19+
// (Rights in Technical Data and Computer Software), as applicable.
20+
221
using RevitLookup.Abstractions.Services.Appearance;
322
using RevitLookup.Abstractions.ViewModels.Visualization;
423
using Wpf.Ui;
524

625
namespace RevitLookup.UI.Framework.Views.Visualization
726
{
8-
public sealed partial class CurveLoopVisualizationDialog: Wpf.Ui.Controls.ContentDialog
27+
public sealed partial class CurveLoopVisualizationDialog
928
{
1029
private readonly ICurveLoopVisualizationViewModel _viewModel;
1130

source/RevitLookup.UI.Playground/Mockups/Services/Settings/MockSettingsService.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.IO;
1+
using System.IO;
22
using System.Text.Json;
33
using System.Windows.Media;
44
using Microsoft.Extensions.Logging;
@@ -22,9 +22,9 @@ public sealed class MockSettingsService(
2222
private DecompositionSettings? _decompositionSettings;
2323
private VisualizationSettings? _visualizationSettings;
2424

25-
public ApplicationSettings ApplicationSettings => _applicationSettings ?? throw new InvalidOperationException("Settings is not loaded.");
26-
public DecompositionSettings DecompositionSettings => _decompositionSettings ?? throw new InvalidOperationException("Settings is not loaded.");
27-
public VisualizationSettings VisualizationSettings => _visualizationSettings ?? throw new InvalidOperationException("Settings is not loaded.");
25+
public ApplicationSettings ApplicationSettings => _applicationSettings ?? throw new InvalidOperationException("Application settings is not loaded.");
26+
public DecompositionSettings DecompositionSettings => _decompositionSettings ?? throw new InvalidOperationException("Decomposition settings is not loaded.");
27+
public VisualizationSettings VisualizationSettings => _visualizationSettings ?? throw new InvalidOperationException("Visualization settings is not loaded.");
2828

2929
public void SaveSettings()
3030
{
@@ -67,7 +67,7 @@ private void SaveVisualizationSettings()
6767
File.WriteAllText(path, json);
6868
}
6969

70-
private void LoadApplicationSettings()
70+
private void LoadApplicationSettings()
7171
{
7272
var path = foldersOptions.Value.ApplicationSettingsPath;
7373
if (!File.Exists(path))
@@ -85,6 +85,11 @@ private void LoadApplicationSettings()
8585
{
8686
logger.LogError(exception, "Application settings loading error");
8787
}
88+
89+
if (_applicationSettings is null)
90+
{
91+
ResetApplicationSettings();
92+
}
8893
}
8994

9095
private void LoadDecompositionSettings()
@@ -105,6 +110,11 @@ private void LoadDecompositionSettings()
105110
{
106111
logger.LogError(exception, "Decomposition settings loading error");
107112
}
113+
114+
if (_decompositionSettings is null)
115+
{
116+
ResetDecompositionSettings();
117+
}
108118
}
109119

110120
private void LoadVisualizationSettings()
@@ -125,6 +135,11 @@ private void LoadVisualizationSettings()
125135
{
126136
logger.LogError(exception, "Application settings loading error");
127137
}
138+
139+
if (_visualizationSettings is null)
140+
{
141+
ResetVisualizationSettings();
142+
}
128143
}
129144

130145
public void ResetApplicationSettings()

source/RevitLookup/Core/Decomposition/Descriptors/CurveLoopDescriptor.cs

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,7 @@
1-
// Copyright 2003-2024 by Autodesk, Inc.
2-
//
3-
// Permission to use, copy, modify, and distribute this software in
4-
// object code form for any purpose and without fee is hereby granted,
5-
// provided that the above copyright notice appears in all copies and
6-
// that both that copyright notice and the limited warranty and
7-
// restricted rights notice below appear in all supporting
8-
// documentation.
9-
//
10-
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
11-
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
12-
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
13-
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
14-
// UNINTERRUPTED OR ERROR FREE.
15-
//
16-
// Use, duplication, or disclosure by the U.S. Government is subject to
17-
// restrictions set forth in FAR 52.227-19 (Commercial Computer
18-
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
19-
// (Rights in Technical Data and Computer Software), as applicable.
20-
211
using System.Globalization;
222
using System.Reflection;
233
using System.Windows.Controls;
244
using System.Windows.Input;
25-
using Autodesk.Revit.DB;
265
using LookupEngine.Abstractions.Configuration;
276
using LookupEngine.Abstractions.Decomposition;
287
using Microsoft.Extensions.DependencyInjection;
@@ -38,10 +17,10 @@ public sealed class CurveLoopDescriptor : Descriptor, IDescriptorResolver, ICont
3817
{
3918
private readonly CurveLoop _curveLoop;
4019

41-
public CurveLoopDescriptor(CurveLoop curveloop)
20+
public CurveLoopDescriptor(CurveLoop curveLoop)
4221
{
43-
_curveLoop = curveloop;
44-
Name = $"{curveloop.GetExactLength().ToString(CultureInfo.InvariantCulture)} ft";
22+
_curveLoop = curveLoop;
23+
Name = $"{curveLoop.GetExactLength().ToString(CultureInfo.InvariantCulture)} ft";
4524
}
4625

4726
public Func<IVariant>? Resolve(string target, ParameterInfo[] parameters)
@@ -94,48 +73,48 @@ public void RegisterMenu(ContextMenu contextMenu, IServiceProvider serviceProvid
9473
.SetCommand(_curveLoop, VisualizeCurve)
9574
.SetShortcut(Key.F8);
9675

97-
async Task VisualizeCurve(CurveLoop curveloop)
76+
async Task VisualizeCurve(CurveLoop curveLoop)
9877
{
9978
if (Context.ActiveUiDocument is null) return;
10079

10180
try
10281
{
10382
var dialog = serviceProvider.GetRequiredService<CurveLoopVisualizationDialog>();
104-
await dialog.ShowDialogAsync(curveloop);
83+
await dialog.ShowDialogAsync(curveLoop);
10584
}
10685
catch (Exception exception)
10786
{
10887
var logger = serviceProvider.GetRequiredService<ILogger<CurveLoopDescriptor>>();
10988
var notificationService = serviceProvider.GetRequiredService<INotificationService>();
11089

111-
logger.LogError(exception, "Visualize curveloop error");
90+
logger.LogError(exception, "Visualize curve loop error");
11291
notificationService.ShowError("Visualization error", exception);
11392
}
11493
}
11594

11695
#if REVIT2023_OR_GREATER
117-
void SelectCurve(CurveLoop curveloop)
96+
void SelectCurve(CurveLoop curveLoop)
11897
{
11998
if (Context.ActiveUiDocument is null) return;
120-
if (curveloop.Any(curve => curve.Reference is null)) return;
99+
if (curveLoop.Any(curve => curve.Reference is null)) return;
121100

122-
foreach (var curve in curveloop)
101+
foreach (var curve in curveLoop)
123102
{
124103
RevitShell.ActionEventHandler.Raise(_ => Context.ActiveUiDocument.Selection.SetReferences([curve.Reference]));
125104
}
126105
}
127106

128-
void ShowCurve(CurveLoop curveloop)
107+
void ShowCurve(CurveLoop curveLoop)
129108
{
130109
if (Context.ActiveUiDocument is null) return;
131-
if (curveloop.Any(curve => curve.Reference is null)) return;
110+
if (curveLoop.Any(curve => curve.Reference is null)) return;
132111

133112
RevitShell.ActionEventHandler.Raise(application =>
134113
{
135114
var uiDocument = application.ActiveUIDocument;
136115
if (uiDocument is null) return;
137116

138-
foreach (var curve in curveloop)
117+
foreach (var curve in curveLoop)
139118
{
140119
var element = curve.Reference.ElementId.ToElement(uiDocument.Document);
141120
if (element is not null) uiDocument.ShowElements(element);

source/RevitLookup/Core/Decomposition/DescriptorsMap.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2003-2024 by Autodesk, Inc.
1+
// Copyright 2003-2024 by Autodesk, Inc.
22
//
33
// Permission to use, copy, modify, and distribute this software in
44
// object code form for any purpose and without fee is hereby granted,
@@ -58,8 +58,7 @@ public static Descriptor FindDescriptor(object? obj, Type? type)
5858
//System
5959
string value when type is null || type == typeof(string) => new StringDescriptor(value),
6060
bool value when type is null || type == typeof(bool) => new BooleanDescriptor(value),
61-
CurveLoop value when type is null || type == typeof(CurveLoop) => new CurveLoopDescriptor(value),//before regular IEnumerable
62-
IEnumerable value => new EnumerableDescriptor(value),
61+
IEnumerable value and not CurveLoop => new EnumerableDescriptor(value),
6362
Exception value when type is null || type == typeof(Exception) => new ExceptionDescriptor(value),
6463

6564
//Root
@@ -84,6 +83,7 @@ public static Descriptor FindDescriptor(object? obj, Type? type)
8483
Solid value when type is null || type == typeof(Solid) => new SolidDescriptor(value),
8584
Mesh value when type is null || type == typeof(Mesh) => new MeshDescriptor(value),
8685
CylindricalFace value when type is null || type == typeof(CylindricalFace) => new CylindricalFaceDescriptor(value),
86+
CurveLoop value when type is null || type == typeof(CurveLoop) => new CurveLoopDescriptor(value),
8787
Face value when type is null || type == typeof(Face) => new FaceDescriptor(value),
8888
City value when type is null || type == typeof(City) => new CityDescriptor(value),
8989
PaperSize value when type is null || type == typeof(PaperSize) => new PaperSizeDescriptor(value),

source/RevitLookup/Core/Visualization/CurveLoopVisualizationServer.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1-
// RevitLookup.Core/Visualization/CurveLoopVisualizationServer.cs
2-
using Autodesk.Revit.DB;
1+
// Copyright 2003-2024 by Autodesk, Inc.
2+
//
3+
// Permission to use, copy, modify, and distribute this software in
4+
// object code form for any purpose and without fee is hereby granted,
5+
// provided that the above copyright notice appears in all copies and
6+
// that both that copyright notice and the limited warranty and
7+
// restricted rights notice below appear in all supporting
8+
// documentation.
9+
//
10+
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
11+
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
12+
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
13+
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
14+
// UNINTERRUPTED OR ERROR FREE.
15+
//
16+
// Use, duplication, or disclosure by the U.S. Government is subject to
17+
// restrictions set forth in FAR 52.227-19 (Commercial Computer
18+
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
19+
// (Rights in Technical Data and Computer Software), as applicable.
20+
321
using Autodesk.Revit.DB.DirectContext3D;
422
using Autodesk.Revit.DB.ExternalService;
523
using RevitLookup.Core.Visualization.Buffers;

source/RevitLookup/Services/Settings/SettingsService.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.IO;
1+
using System.IO;
22
using System.Text.Json;
33
using System.Windows.Media;
44
using Microsoft.Extensions.Logging;
@@ -23,9 +23,9 @@ public sealed class SettingsService(
2323
private DecompositionSettings? _decompositionSettings;
2424
private VisualizationSettings? _visualizationSettings;
2525

26-
public ApplicationSettings ApplicationSettings => _applicationSettings ?? throw new InvalidOperationException("Settings is not loaded.");
27-
public DecompositionSettings DecompositionSettings => _decompositionSettings ?? throw new InvalidOperationException("Settings is not loaded.");
28-
public VisualizationSettings VisualizationSettings => _visualizationSettings ?? throw new InvalidOperationException("Settings is not loaded.");
26+
public ApplicationSettings ApplicationSettings => _applicationSettings ?? throw new InvalidOperationException("Application settings is not loaded.");
27+
public DecompositionSettings DecompositionSettings => _decompositionSettings ?? throw new InvalidOperationException("Decomposition settings is not loaded.");
28+
public VisualizationSettings VisualizationSettings => _visualizationSettings ?? throw new InvalidOperationException("Visualization settings is not loaded.");
2929

3030
public void SaveSettings()
3131
{
@@ -86,6 +86,11 @@ private void LoadApplicationSettings()
8686
{
8787
logger.LogError(exception, "Application settings loading error");
8888
}
89+
90+
if (_applicationSettings is null)
91+
{
92+
ResetApplicationSettings();
93+
}
8994
}
9095

9196
private void LoadDecompositionSettings()
@@ -106,6 +111,11 @@ private void LoadDecompositionSettings()
106111
{
107112
logger.LogError(exception, "Decomposition settings loading error");
108113
}
114+
115+
if (_decompositionSettings is null)
116+
{
117+
ResetDecompositionSettings();
118+
}
109119
}
110120

111121
private void LoadVisualizationSettings()
@@ -126,6 +136,11 @@ private void LoadVisualizationSettings()
126136
{
127137
logger.LogError(exception, "Application settings loading error");
128138
}
139+
140+
if (_visualizationSettings is null)
141+
{
142+
ResetVisualizationSettings();
143+
}
129144
}
130145

131146
public void ResetApplicationSettings()

0 commit comments

Comments
 (0)