整理代码
This commit is contained in:
42
ShrlAlgoToolkit.RevitAddins/Windows/ColorPickerViewModel.cs
Normal file
42
ShrlAlgoToolkit.RevitAddins/Windows/ColorPickerViewModel.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace ShrlAlgo.RvKits.Windows
|
||||
{
|
||||
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]
|
||||
private Color selectedColor;
|
||||
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user