Files
ShrlAlgoToolkit/ShrlAlgoToolkit.RevitAddins/RvMEP/RoomCheckItem.cs
2026-01-01 10:02:59 +08:00

33 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using CommunityToolkit.Mvvm.ComponentModel;
using ShrlAlgoToolkit.Core.Assists;
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; }
}
}