Initial commit to new repository
This commit is contained in:
57
src/AxCopilot/Views/ColorPickResultWindow.xaml.cs
Normal file
57
src/AxCopilot/Views/ColorPickResultWindow.xaml.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
|
||||
namespace AxCopilot.Views;
|
||||
|
||||
/// <summary>
|
||||
/// 스포이드 색상 추출 결과를 반투명 창으로 5초간 표시합니다.
|
||||
/// 클릭 위치 근처에 나타나며, HEX 코드를 클립보드에 복사합니다.
|
||||
/// </summary>
|
||||
public partial class ColorPickResultWindow : Window
|
||||
{
|
||||
private readonly DispatcherTimer _timer;
|
||||
|
||||
public ColorPickResultWindow(System.Drawing.Color color, double screenX, double screenY)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 색상 표시
|
||||
var wpfColor = Color.FromRgb(color.R, color.G, color.B);
|
||||
ColorPreview.Fill = new SolidColorBrush(wpfColor);
|
||||
HexText.Text = $"#{color.R:X2}{color.G:X2}{color.B:X2}";
|
||||
RgbText.Text = $"RGB({color.R}, {color.G}, {color.B})";
|
||||
|
||||
// 클립보드에 HEX 코드 복사
|
||||
try { Clipboard.SetText(HexText.Text); }
|
||||
catch { }
|
||||
|
||||
// 위치: 클릭 지점 오른쪽 아래
|
||||
var area = SystemParameters.WorkArea;
|
||||
Left = Math.Min(screenX + 20, area.Right - 200);
|
||||
Top = Math.Min(screenY + 20, area.Bottom - 160);
|
||||
|
||||
// 5초 타이머
|
||||
_timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(5) };
|
||||
_timer.Tick += (_, _) => Close();
|
||||
_timer.Start();
|
||||
|
||||
// 클릭으로 닫기
|
||||
MouseDown += (_, _) => Close();
|
||||
|
||||
// 등장 애니메이션
|
||||
Opacity = 0;
|
||||
Loaded += (_, _) =>
|
||||
{
|
||||
var anim = new System.Windows.Media.Animation.DoubleAnimation(0, 1,
|
||||
TimeSpan.FromMilliseconds(200));
|
||||
BeginAnimation(OpacityProperty, anim);
|
||||
};
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
_timer.Stop();
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user