feat: Better-Seewo v2.0.0 - 希沃白板功能增强插件
- Fluent Design 风格 UI,深色/浅色主题切换 - 平滑过渡动画(页面切换、按钮交互、状态变化) - 五大核心功能:安装管理、墨迹管理、格式转换、触摸设置、激活管理 - 基于 dotnetCampus.EasiPlugin.Sdk v2.1.1-alpha.3 插件框架 - WPF 安装向导(欢迎页 -> 安装页 -> 完成页)
This commit is contained in:
322
Manager/Pages/ActivatePage.xaml.cs
Normal file
322
Manager/Pages/ActivatePage.xaml.cs
Normal file
@@ -0,0 +1,322 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Better_Seewo.Manager.Pages
|
||||
{
|
||||
/// <summary>
|
||||
/// ActivatePage.xaml 的交互逻辑
|
||||
/// 激活管理页面 - 管理 Better-Seewo 许可证
|
||||
/// </summary>
|
||||
public partial class ActivatePage : Page
|
||||
{
|
||||
// ===== 当前激活状态 =====
|
||||
private bool _isActivated = false;
|
||||
|
||||
/// <summary>
|
||||
/// 许可证信息数据模型
|
||||
/// </summary>
|
||||
public class LicenseInfo
|
||||
{
|
||||
/// <summary>许可证类型(个人版/专业版/教育版)</summary>
|
||||
public string LicenseType { get; set; } = "个人版";
|
||||
/// <summary>激活码</summary>
|
||||
public string ActivationCode { get; set; } = string.Empty;
|
||||
/// <summary>激活日期</summary>
|
||||
public DateTime ActivateDate { get; set; }
|
||||
/// <summary>到期日期</summary>
|
||||
public DateTime ExpiryDate { get; set; }
|
||||
/// <summary>设备标识</summary>
|
||||
public string DeviceId { get; set; } = string.Empty;
|
||||
/// <summary>是否已激活</summary>
|
||||
public bool IsActivated { get; set; } = false;
|
||||
}
|
||||
|
||||
private LicenseInfo _licenseInfo = new LicenseInfo();
|
||||
|
||||
public ActivatePage()
|
||||
{
|
||||
InitializeComponent();
|
||||
Loaded += ActivatePage_Loaded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 页面加载时检测激活状态
|
||||
/// </summary>
|
||||
private async void ActivatePage_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await CheckActivationStatusAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步检查激活状态
|
||||
/// </summary>
|
||||
private async Task CheckActivationStatusAsync()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// TODO: 实际从配置文件或注册表读取激活状态
|
||||
// 当前模拟为未激活
|
||||
_isActivated = _licenseInfo.IsActivated;
|
||||
});
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
UpdateActivationUI();
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据激活状态更新界面
|
||||
/// </summary>
|
||||
private void UpdateActivationUI()
|
||||
{
|
||||
if (_isActivated)
|
||||
{
|
||||
PanelNotActivated.Visibility = Visibility.Collapsed;
|
||||
PanelActivated.Visibility = Visibility.Visible;
|
||||
|
||||
// 填充许可证信息
|
||||
LicenseTypeText.Text = _licenseInfo.LicenseType;
|
||||
ActivateDateText.Text = _licenseInfo.ActivateDate.ToString("yyyy-MM-dd");
|
||||
ExpiryDateText.Text = _licenseInfo.ExpiryDate.ToString("yyyy-MM-dd");
|
||||
DeviceInfoText.Text = string.IsNullOrEmpty(_licenseInfo.DeviceId)
|
||||
? "当前设备已绑定"
|
||||
: $"设备:{_licenseInfo.DeviceId}";
|
||||
}
|
||||
else
|
||||
{
|
||||
PanelNotActivated.Visibility = Visibility.Visible;
|
||||
PanelActivated.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 输入框获得焦点时 - 边框发光效果
|
||||
/// </summary>
|
||||
private void ActivationCodeInput_GotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var glowAnimation = new ColorAnimation
|
||||
{
|
||||
From = Colors.Transparent,
|
||||
To = Color.FromArgb(0xFF, 0x4C, 0xAF, 0x50),
|
||||
Duration = TimeSpan.FromMilliseconds(250),
|
||||
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
|
||||
};
|
||||
ActivationInputBorder.BorderBrush = new SolidColorBrush(Colors.Transparent);
|
||||
var brush = new SolidColorBrush(Colors.Transparent);
|
||||
brush.BeginAnimation(SolidColorBrush.ColorProperty, glowAnimation);
|
||||
ActivationInputBorder.BorderBrush = brush;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 输入框失去焦点时 - 恢复默认边框
|
||||
/// </summary>
|
||||
private void ActivationCodeInput_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var resetAnimation = new ColorAnimation
|
||||
{
|
||||
To = Color.FromArgb(0xFF, 0xBD, 0xBD, 0xBD),
|
||||
Duration = TimeSpan.FromMilliseconds(200),
|
||||
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
|
||||
};
|
||||
var brush = new SolidColorBrush(Color.FromArgb(0xFF, 0x4C, 0xAF, 0x50));
|
||||
brush.BeginAnimation(SolidColorBrush.ColorProperty, resetAnimation);
|
||||
ActivationInputBorder.BorderBrush = brush;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 激活按钮点击事件
|
||||
/// </summary>
|
||||
private async void BtnActivate_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var code = ActivationCodeInput.Text?.Trim();
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
ShowError("请输入激活码");
|
||||
return;
|
||||
}
|
||||
|
||||
if (code.Length < 8)
|
||||
{
|
||||
ShowError("激活码格式不正确,请检查后重试");
|
||||
return;
|
||||
}
|
||||
|
||||
HideError();
|
||||
BtnActivate.IsEnabled = false;
|
||||
BtnActivate.Content = "验证中...";
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// TODO: 实际验证逻辑 - 联网验证激活码
|
||||
// 当前为模拟激活
|
||||
System.Threading.Thread.Sleep(1500);
|
||||
});
|
||||
|
||||
// 模拟激活成功
|
||||
_licenseInfo = new LicenseInfo
|
||||
{
|
||||
LicenseType = "个人版",
|
||||
ActivationCode = code,
|
||||
ActivateDate = DateTime.Now,
|
||||
ExpiryDate = DateTime.Now.AddYears(1),
|
||||
DeviceId = "DEVICE-" + Environment.MachineName.GetHashCode().ToString("X8"),
|
||||
IsActivated = true
|
||||
};
|
||||
_isActivated = true;
|
||||
|
||||
// 切换到已激活界面
|
||||
UpdateActivationUI();
|
||||
PlayCelebrationAnimation();
|
||||
|
||||
BtnActivate.IsEnabled = true;
|
||||
BtnActivate.Content = "激活";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 激活成功庆祝动画:绿色勾号从 0 -> 1.2 -> 1.0 弹出
|
||||
/// </summary>
|
||||
private void PlayCelebrationAnimation()
|
||||
{
|
||||
CelebrationPanel.Visibility = Visibility.Visible;
|
||||
var grid = (Grid)CelebrationPanel.Children[0];
|
||||
var transform = (ScaleTransform)grid.RenderTransform;
|
||||
|
||||
// 阶段1:Scale 0 -> 1.2(弹出)
|
||||
var popOut = new DoubleAnimation
|
||||
{
|
||||
From = 0,
|
||||
To = 1.2,
|
||||
Duration = TimeSpan.FromMilliseconds(400),
|
||||
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
|
||||
};
|
||||
|
||||
// 阶段2:Scale 1.2 -> 1.0(回弹)
|
||||
var bounceBack = new DoubleAnimation
|
||||
{
|
||||
From = 1.2,
|
||||
To = 1.0,
|
||||
Duration = TimeSpan.FromMilliseconds(200),
|
||||
EasingFunction = new QuadraticEase { EasingMode = EasingMode.EaseInOut }
|
||||
};
|
||||
|
||||
popOut.Completed += (s, e) =>
|
||||
{
|
||||
transform.BeginAnimation(ScaleTransform.ScaleXProperty, bounceBack);
|
||||
transform.BeginAnimation(ScaleTransform.ScaleYProperty, bounceBack);
|
||||
};
|
||||
|
||||
transform.BeginAnimation(ScaleTransform.ScaleXProperty, popOut);
|
||||
transform.BeginAnimation(ScaleTransform.ScaleYProperty, popOut);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入许可证文件按钮点击事件
|
||||
/// </summary>
|
||||
private void BtnImportLicense_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var dialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "许可证文件 (*.lic;*.license)|*.lic;*.license|所有文件 (*.*)|*.*",
|
||||
Title = "选择许可证文件"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == true)
|
||||
{
|
||||
ActivationCodeInput.Text = $"已选择文件:{System.IO.Path.GetFileName(dialog.FileName)}";
|
||||
|
||||
// TODO: 实际读取许可证文件内容
|
||||
// 当前为模拟实现
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 续费按钮点击事件
|
||||
/// </summary>
|
||||
private async void BtnRenew_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// TODO: 实际续费逻辑 - 打开续费页面或验证新的激活码
|
||||
System.Threading.Thread.Sleep(500);
|
||||
});
|
||||
|
||||
MessageBox.Show("续费功能开发中,敬请期待。", "提示",
|
||||
MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取消激活按钮点击事件
|
||||
/// </summary>
|
||||
private async void BtnDeactivate_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var result = MessageBox.Show(
|
||||
"确定要取消激活吗?取消后将无法使用高级功能。",
|
||||
"确认取消激活",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Question);
|
||||
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// TODO: 实际取消激活逻辑
|
||||
System.Threading.Thread.Sleep(500);
|
||||
});
|
||||
|
||||
_licenseInfo.IsActivated = false;
|
||||
_isActivated = false;
|
||||
CelebrationPanel.Visibility = Visibility.Collapsed;
|
||||
UpdateActivationUI();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示错误信息
|
||||
/// </summary>
|
||||
private void ShowError(string message)
|
||||
{
|
||||
ErrorText.Text = message;
|
||||
ErrorPanel.Visibility = Visibility.Visible;
|
||||
|
||||
// 错误面板淡入动画
|
||||
var fadeIn = new DoubleAnimation
|
||||
{
|
||||
From = 0,
|
||||
To = 1,
|
||||
Duration = TimeSpan.FromMilliseconds(250),
|
||||
EasingFunction = new CubicEase { EasingMode = EasingMode.EaseOut }
|
||||
};
|
||||
ErrorPanel.BeginAnimation(OpacityProperty, fadeIn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 隐藏错误信息
|
||||
/// </summary>
|
||||
private void HideError()
|
||||
{
|
||||
ErrorPanel.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 供外部调用的公共方法:获取激活状态
|
||||
/// </summary>
|
||||
public bool IsActivated()
|
||||
{
|
||||
return _isActivated;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 供外部调用的公共方法:获取许可证信息
|
||||
/// </summary>
|
||||
public LicenseInfo GetLicenseInfo()
|
||||
{
|
||||
return _licenseInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user