调整代码
This commit is contained in:
31
ShrlAlgoToolkit.RevitAddins/Mep/RoomCheckItem.cs
Normal file
31
ShrlAlgoToolkit.RevitAddins/Mep/RoomCheckItem.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitAddins.RvMEP
|
||||
{
|
||||
public partial class RoomCheckItem : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
public partial bool IsSelected { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial string Name { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial Room Room { get; set; }
|
||||
// 当 Room 属性被赋值时,这个方法会被自动调用
|
||||
partial void OnRoomChanged(Room value)
|
||||
{
|
||||
// 只有当 Room 不为空时才计算默认颜色
|
||||
if (value != null)
|
||||
{
|
||||
// 这里实现了“初始值”逻辑:每当 Room 变了,Color 就重置为 Room 对应的颜色
|
||||
Color = ColorAssist.GetDistinctColorById(value.Id);
|
||||
}
|
||||
}
|
||||
[ObservableProperty]
|
||||
public partial Color Color { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user