整理代码
This commit is contained in:
87
ShrlAlgoToolkit.RevitAddins/Windows/MessageViewModel.cs
Normal file
87
ShrlAlgoToolkit.RevitAddins/Windows/MessageViewModel.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External.Handlers;
|
||||
|
||||
|
||||
|
||||
namespace ShrlAlgo.RvKits.Windows;
|
||||
|
||||
public partial class MessageViewModel : ObservableObject
|
||||
{
|
||||
public MessageViewModel(UIDocument uidoc, List<MessageModel> errorModels, string winTitle = "错误处理")
|
||||
{
|
||||
this.uidoc = uidoc;
|
||||
showElementsSectionBox = new ActionEventHandler();
|
||||
ErrorModels.AddRange(errorModels);
|
||||
WinTitle = winTitle;
|
||||
count = errorModels.Count();
|
||||
}
|
||||
|
||||
[ObservableProperty]
|
||||
private string footer;
|
||||
|
||||
private readonly UIDocument uidoc;
|
||||
|
||||
[ObservableProperty]
|
||||
private List<MessageModel> errorModels = [];
|
||||
|
||||
[ObservableProperty]
|
||||
private string winTitle;
|
||||
[ObservableProperty]
|
||||
private int count;
|
||||
private readonly ActionEventHandler showElementsSectionBox;
|
||||
[RelayCommand]
|
||||
private void ShowElement(object obj)
|
||||
{
|
||||
if (obj is not MessageModel model)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var doc = uidoc.Document;
|
||||
//if (UiDocument.ActiveView.IsTemporaryHideIsolateActive())
|
||||
//{
|
||||
// UiDocument.ActiveView.temporary
|
||||
//}
|
||||
if (model.Element.IsValidObject)
|
||||
{
|
||||
if (model.Element.IsHidden(uidoc.ActiveView))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ids = new List<ElementId> { model.Element.Id };
|
||||
//UiDocument.ActiveView.IsolateElementTemporary(model.ElementToMove.ViewId);
|
||||
showElementsSectionBox.Raise(
|
||||
_ =>
|
||||
{
|
||||
if (uidoc.ActiveView is not View3D view3d)
|
||||
{
|
||||
view3d = doc.OfClass<View3D>().FirstElement() as View3D;
|
||||
}
|
||||
if (!model.Element.ViewSpecific)
|
||||
{
|
||||
uidoc.ActiveView = view3d;
|
||||
}
|
||||
doc.Invoke(
|
||||
_ =>
|
||||
{
|
||||
if (uidoc.ActiveView is View3D)
|
||||
{
|
||||
view3d.SectionBoxElements(ids);
|
||||
}
|
||||
view3d.ZoomElements(uidoc, ids);
|
||||
uidoc.Selection.SetElementIds(ids);
|
||||
});
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorModels.Remove(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user