2025-04-24 20:56:44 +08:00
|
|
|
|
using System.Windows.Media;
|
|
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
2024-09-22 11:05:41 +08:00
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
|
|
|
|
|
2025-04-24 20:56:44 +08:00
|
|
|
|
namespace ShrlAlgoToolkit.RevitAddins.Windows
|
2024-09-22 11:05:41 +08:00
|
|
|
|
{
|
|
|
|
|
|
public partial class ColorPickerViewModel : ObservableObject
|
|
|
|
|
|
{
|
|
|
|
|
|
public ColorPickerViewModel(Color color)
|
|
|
|
|
|
{
|
|
|
|
|
|
SelectedColor = color;
|
|
|
|
|
|
//this.IsActive = true;
|
|
|
|
|
|
//WeakReferenceMessenger.Default.Register<ColorPickerViewModel>(this, (r, m) =>
|
|
|
|
|
|
//{
|
|
|
|
|
|
// // Handle the message here, with r being the recipient and m being the
|
|
|
|
|
|
// // input message. Using the recipient passed as input makes it so that
|
|
|
|
|
|
// // the lambda expression doesn't capture "this", improving performance.
|
|
|
|
|
|
//});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
2025-10-04 08:52:23 +08:00
|
|
|
|
public partial Color SelectedColor { get; set; }
|
2024-09-22 11:05:41 +08:00
|
|
|
|
|
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
|
private void Confirm(object obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (obj is System.Windows.Window window)
|
|
|
|
|
|
{
|
|
|
|
|
|
var colorMessage = new Autodesk.Revit.DB.Color(
|
|
|
|
|
|
SelectedColor.R,
|
|
|
|
|
|
SelectedColor.G,
|
|
|
|
|
|
SelectedColor.B
|
|
|
|
|
|
);
|
|
|
|
|
|
//发布
|
|
|
|
|
|
window.DialogResult = true;
|
|
|
|
|
|
WeakReferenceMessenger.Default.Send(colorMessage);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|