调整代码
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using Nice3point.Revit.Toolkit.External.Handlers;
|
||||
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitAddins.Common.Controls;
|
||||
|
||||
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]
|
||||
public partial string Footer { get; set; }
|
||||
|
||||
private readonly UIDocument uidoc;
|
||||
|
||||
[ObservableProperty]
|
||||
public partial List<MessageModel> ErrorModels { get; set; } = [];
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string WinTitle { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial int Count { get; set; }
|
||||
|
||||
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