-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
628ea21
commit 792f430
Showing
17 changed files
with
659 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
source/RevitLookup/Core/ComponentModel/Descriptors/XyzDescriptor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2003-2024 by Autodesk, Inc. | ||
// | ||
// Permission to use, copy, modify, and distribute this software in | ||
// object code form for any purpose and without fee is hereby granted, | ||
// provided that the above copyright notice appears in all copies and | ||
// that both that copyright notice and the limited warranty and | ||
// restricted rights notice below appear in all supporting | ||
// documentation. | ||
// | ||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. | ||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF | ||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. | ||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE | ||
// UNINTERRUPTED OR ERROR FREE. | ||
// | ||
// Use, duplication, or disclosure by the U.S. Government is subject to | ||
// restrictions set forth in FAR 52.227-19 (Commercial Computer | ||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) | ||
// (Rights in Technical Data and Computer Software), as applicable. | ||
|
||
using System.Windows.Controls; | ||
using System.Windows.Input; | ||
using Microsoft.Extensions.Logging; | ||
using RevitLookup.Core.Contracts; | ||
using RevitLookup.Core.Objects; | ||
using RevitLookup.ViewModels.Contracts; | ||
using RevitLookup.Views.Dialogs.Visualization; | ||
using RevitLookup.Views.Extensions; | ||
|
||
namespace RevitLookup.Core.ComponentModel.Descriptors; | ||
|
||
public class XyzDescriptor : Descriptor, IDescriptorConnector | ||
{ | ||
private readonly XYZ _point; | ||
|
||
public XyzDescriptor(XYZ point) | ||
{ | ||
_point = point; | ||
Name = point.ToString(); | ||
} | ||
|
||
public void RegisterMenu(ContextMenu contextMenu) | ||
{ | ||
contextMenu.AddMenuItem("VisualizeMenuItem") | ||
.SetAvailability(!_point.IsUnitLength()) | ||
.SetCommand(_point, async point => | ||
{ | ||
if (Context.UiDocument is null) return; | ||
|
||
var context = (ISnoopViewModel) contextMenu.DataContext; | ||
|
||
try | ||
{ | ||
var dialog = new XyzVisualizationDialog(context.ServiceProvider, point); | ||
await dialog.ShowAsync(); | ||
} | ||
catch (Exception exception) | ||
{ | ||
var logger = context.ServiceProvider.GetService<ILogger<XyzDescriptor>>(); | ||
logger.LogError(exception, "VisualizationDialog error"); | ||
} | ||
}) | ||
.SetShortcut(Key.F8); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.