32 lines
995 B
C#
32 lines
995 B
C#
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; }
|
||
|
||
}
|
||
}
|