样式demo
This commit is contained in:
@@ -7,7 +7,7 @@ using CommunityToolkit.Mvvm.Input;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External.Handlers;
|
||||
|
||||
using RandomColorGenerator;
|
||||
//using RandomColorGenerator;
|
||||
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitAddins.RvMEP;
|
||||
@@ -37,33 +37,24 @@ public partial class HeadroomCheckViewModel : ObservableObject
|
||||
var allRooms = uiapp.ActiveUIDocument.Document.OfClass<SpatialElement>().OfType<Room>();
|
||||
var groups = allRooms.GroupBy(r => r.Name);
|
||||
IEnumerable<IGrouping<string, Room>> enumerable = groups as IGrouping<string, Room>[] ?? groups.ToArray();
|
||||
var colors = GetRandomColors(enumerable.Count());
|
||||
for (int i = 0; i < enumerable.Count(); i++)
|
||||
{
|
||||
var group = enumerable.ElementAt(i);
|
||||
var color = colors.ElementAt(i);
|
||||
foreach (var room in group)
|
||||
{
|
||||
var r = new RoomCheckItem()
|
||||
{
|
||||
Room = room,
|
||||
Name = room.Name,
|
||||
Color = color,
|
||||
};
|
||||
roomItems.Add(r);
|
||||
}
|
||||
}
|
||||
return roomItems;
|
||||
}
|
||||
private static IEnumerable<Color> GetRandomColors(int count)
|
||||
{
|
||||
var colors = RandomColor.GetColors(ColorScheme.Random, Luminosity.Light, count);
|
||||
|
||||
return colors.Select(color => new Color(color.R, color.G, color.B));
|
||||
}
|
||||
private bool CanClick()
|
||||
{
|
||||
return Enumerable.Any<RoomCheckItem>(Rooms);
|
||||
return Rooms is { Count: > 0 };
|
||||
}
|
||||
[RelayCommand(CanExecute = nameof(CanClick))]
|
||||
private void AnalysisHeadroom()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using ShrlAlgoToolkit.Core.Assists;
|
||||
|
||||
namespace ShrlAlgoToolkit.RevitAddins.RvMEP
|
||||
{
|
||||
@@ -13,9 +14,10 @@ namespace ShrlAlgoToolkit.RevitAddins.RvMEP
|
||||
public partial string Name { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyPropertyChangedFor(nameof(Color))]
|
||||
public partial Room Room { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
public partial Color Color { get; set; }
|
||||
public partial Color Color { get; set; } = ColorAssist.GetDistinctColorById(Room.Id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user