add:Dlass遥测
This commit is contained in:
@@ -65,17 +65,20 @@ namespace Ink_Canvas
|
||||
privacyPath = Path.Combine(App.RootPath, "privacy");
|
||||
}
|
||||
|
||||
if (File.Exists(privacyPath))
|
||||
if (!File.Exists(privacyPath))
|
||||
{
|
||||
string privacyText = File.ReadAllText(privacyPath, System.Text.Encoding.UTF8);
|
||||
var confirmResult = MessageBox.Show(
|
||||
privacyText + "\n\n是否同意以上隐私说明并启用匿名使用数据上传?",
|
||||
"隐私说明确认",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Information,
|
||||
MessageBoxResult.No);
|
||||
MessageBox.Show(
|
||||
"未找到隐私说明文件(privacy.txt 或 privacy)。\n\n将切换回正式通道。",
|
||||
"隐私文件缺失",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
}
|
||||
else
|
||||
{
|
||||
var privacyWindow = new PrivacyAgreementWindow();
|
||||
bool? dialogResult = privacyWindow.ShowDialog();
|
||||
|
||||
if (confirmResult == MessageBoxResult.Yes)
|
||||
if (dialogResult == true && privacyWindow.UserAccepted)
|
||||
{
|
||||
Settings.Startup.HasAcceptedTelemetryPrivacy = true;
|
||||
Settings.Startup.TelemetryUploadLevel = TelemetryUploadLevel.Basic;
|
||||
@@ -98,14 +101,6 @@ namespace Ink_Canvas
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show(
|
||||
"未找到隐私说明文件(privacy.txt 或 privacy)。\n\n将切换回正式通道。",
|
||||
"隐私文件缺失",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -334,28 +329,10 @@ namespace Ink_Canvas
|
||||
|
||||
if (isChecked)
|
||||
{
|
||||
// 读取 privacy 文本并展示给用户二次确认
|
||||
string privacyText = null;
|
||||
try
|
||||
{
|
||||
string pathTxt = System.IO.Path.Combine(App.RootPath, "privacy.txt");
|
||||
string pathNoExt = System.IO.Path.Combine(App.RootPath, "privacy");
|
||||
string pathTxt = System.IO.Path.Combine(App.RootPath, "privacy.txt");
|
||||
string pathNoExt = System.IO.Path.Combine(App.RootPath, "privacy");
|
||||
|
||||
if (System.IO.File.Exists(pathTxt))
|
||||
{
|
||||
privacyText = System.IO.File.ReadAllText(pathTxt);
|
||||
}
|
||||
else if (System.IO.File.Exists(pathNoExt))
|
||||
{
|
||||
privacyText = System.IO.File.ReadAllText(pathNoExt);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"Settings | 读取隐私说明失败: {ex.Message}", LogHelper.LogType.Warning);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(privacyText))
|
||||
if (!System.IO.File.Exists(pathTxt) && !System.IO.File.Exists(pathNoExt))
|
||||
{
|
||||
MessageBox.Show(
|
||||
"未找到隐私说明文件(privacy / privacy.txt),暂时无法启用匿名使用数据上传。",
|
||||
@@ -378,16 +355,16 @@ namespace Ink_Canvas
|
||||
return;
|
||||
}
|
||||
|
||||
var result = MessageBox.Show(
|
||||
privacyText + "\n\n是否同意以上隐私说明并启用匿名使用数据上传?",
|
||||
"隐私说明确认",
|
||||
MessageBoxButton.YesNo,
|
||||
MessageBoxImage.Information,
|
||||
MessageBoxResult.No);
|
||||
var privacyWindow = new PrivacyAgreementWindow();
|
||||
bool? dialogResult = privacyWindow.ShowDialog();
|
||||
|
||||
if (result != MessageBoxResult.Yes)
|
||||
if (dialogResult == true && privacyWindow.UserAccepted)
|
||||
{
|
||||
Settings.Startup.HasAcceptedTelemetryPrivacy = true;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 用户不同意,取消勾选
|
||||
_isChangingTelemetryPrivacyInternally = true;
|
||||
try
|
||||
{
|
||||
@@ -400,12 +377,7 @@ namespace Ink_Canvas
|
||||
|
||||
Settings.Startup.HasAcceptedTelemetryPrivacy = false;
|
||||
SaveSettingsToFile();
|
||||
return;
|
||||
}
|
||||
|
||||
// 同意隐私说明
|
||||
Settings.Startup.HasAcceptedTelemetryPrivacy = true;
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<Window x:Class="Ink_Canvas.PrivacyAgreementWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Ink_Canvas"
|
||||
mc:Ignorable="d" FontFamily="Microsoft YaHei UI" ui:WindowHelper.UseModernWindowStyle="True"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern" Topmost="True"
|
||||
Title="隐私说明 - Ink Canvas" Height="600" Width="600"
|
||||
Loaded="Window_Loaded" Closing="Window_Closing">
|
||||
<Window.Resources>
|
||||
<SolidColorBrush x:Key="PrivacyAgreementWindowBackground" Color="White"/>
|
||||
<SolidColorBrush x:Key="PrivacyAgreementWindowForeground" Color="Black"/>
|
||||
<SolidColorBrush x:Key="PrivacyAgreementWindowButtonBackground" Color="#F4F4F5"/>
|
||||
<SolidColorBrush x:Key="PrivacyAgreementWindowButtonForeground" Color="Black"/>
|
||||
<SolidColorBrush x:Key="PrivacyAgreementWindowBorderBrush" Color="#E4E4E7"/>
|
||||
<SolidColorBrush x:Key="PrivacyAgreementWindowButtonAcceptBackground" Color="#3584e4"/>
|
||||
<SolidColorBrush x:Key="PrivacyAgreementWindowButtonAcceptForeground" Color="White"/>
|
||||
</Window.Resources>
|
||||
<Grid Background="{DynamicResource PrivacyAgreementWindowBackground}">
|
||||
<Label Content="隐私说明"
|
||||
Margin="10,10,10,0"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource PrivacyAgreementWindowForeground}"
|
||||
FontFamily="Microsoft YaHei UI"
|
||||
FontSize="18"
|
||||
FontWeight="Bold"/>
|
||||
<ScrollViewer Margin="10,45,10,60"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Disabled">
|
||||
<TextBox Name="TextBoxPrivacyContent"
|
||||
FontFamily="Microsoft YaHei UI"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
AcceptsReturn="True"
|
||||
IsReadOnly="True"
|
||||
TextWrapping="Wrap"
|
||||
Background="{DynamicResource PrivacyAgreementWindowBackground}"
|
||||
Foreground="{DynamicResource PrivacyAgreementWindowForeground}"
|
||||
BorderBrush="{DynamicResource PrivacyAgreementWindowBorderBrush}"
|
||||
Padding="10"/>
|
||||
</ScrollViewer>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Margin="10">
|
||||
<Button Name="ButtonCancel"
|
||||
Margin="0,0,10,0"
|
||||
Content="取消"
|
||||
FontFamily="Microsoft YaHei UI"
|
||||
Width="100"
|
||||
Height="35"
|
||||
Click="ButtonCancel_Click"
|
||||
Background="{DynamicResource PrivacyAgreementWindowButtonBackground}"
|
||||
Foreground="{DynamicResource PrivacyAgreementWindowButtonForeground}"
|
||||
BorderBrush="{DynamicResource PrivacyAgreementWindowBorderBrush}"/>
|
||||
<Button Name="ButtonAccept"
|
||||
Content="同意"
|
||||
FontFamily="Microsoft YaHei UI"
|
||||
Width="100"
|
||||
Height="35"
|
||||
Click="ButtonAccept_Click"
|
||||
Background="{DynamicResource PrivacyAgreementWindowButtonAcceptBackground}"
|
||||
Foreground="{DynamicResource PrivacyAgreementWindowButtonAcceptForeground}"
|
||||
BorderBrush="{DynamicResource PrivacyAgreementWindowBorderBrush}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Ink_Canvas
|
||||
{
|
||||
public partial class PrivacyAgreementWindow : Window
|
||||
{
|
||||
public bool UserAccepted { get; private set; } = false;
|
||||
|
||||
public PrivacyAgreementWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
AnimationsHelper.ShowWithSlideFromBottomAndFade(this, 0.25);
|
||||
ApplyTheme();
|
||||
}
|
||||
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string privacyText = null;
|
||||
string pathTxt = Path.Combine(App.RootPath, "privacy.txt");
|
||||
string pathNoExt = Path.Combine(App.RootPath, "privacy");
|
||||
|
||||
if (File.Exists(pathTxt))
|
||||
{
|
||||
privacyText = File.ReadAllText(pathTxt, System.Text.Encoding.UTF8);
|
||||
}
|
||||
else if (File.Exists(pathNoExt))
|
||||
{
|
||||
privacyText = File.ReadAllText(pathNoExt, System.Text.Encoding.UTF8);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(privacyText))
|
||||
{
|
||||
privacyText = "未找到隐私说明文件(privacy.txt 或 privacy)。";
|
||||
}
|
||||
|
||||
TextBoxPrivacyContent.Text = privacyText;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"读取隐私说明失败: {ex.Message}", LogHelper.LogType.Warning);
|
||||
TextBoxPrivacyContent.Text = "读取隐私说明文件时出错。";
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
UserAccepted = false;
|
||||
DialogResult = false;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ButtonAccept_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
UserAccepted = true;
|
||||
DialogResult = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ApplyTheme()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (MainWindow.Settings != null)
|
||||
{
|
||||
ApplyTheme(MainWindow.Settings);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"应用隐私说明窗口主题出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyTheme(Settings settings)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (settings.Appearance.Theme == 0)
|
||||
{
|
||||
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Light);
|
||||
ApplyThemeResources("Light");
|
||||
}
|
||||
else if (settings.Appearance.Theme == 1)
|
||||
{
|
||||
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Dark);
|
||||
ApplyThemeResources("Dark");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isSystemLight = IsSystemThemeLight();
|
||||
if (isSystemLight)
|
||||
{
|
||||
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Light);
|
||||
ApplyThemeResources("Light");
|
||||
}
|
||||
else
|
||||
{
|
||||
iNKORE.UI.WPF.Modern.ThemeManager.SetRequestedTheme(this, iNKORE.UI.WPF.Modern.ElementTheme.Dark);
|
||||
ApplyThemeResources("Dark");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"应用隐私说明窗口主题出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyThemeResources(string theme)
|
||||
{
|
||||
try
|
||||
{
|
||||
var resources = this.Resources;
|
||||
|
||||
if (theme == "Light")
|
||||
{
|
||||
resources["PrivacyAgreementWindowBackground"] = new SolidColorBrush(Color.FromRgb(255, 255, 255));
|
||||
resources["PrivacyAgreementWindowForeground"] = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
resources["PrivacyAgreementWindowButtonBackground"] = new SolidColorBrush(Color.FromRgb(244, 244, 245));
|
||||
resources["PrivacyAgreementWindowButtonForeground"] = new SolidColorBrush(Color.FromRgb(24, 24, 27));
|
||||
resources["PrivacyAgreementWindowBorderBrush"] = new SolidColorBrush(Color.FromRgb(228, 228, 231));
|
||||
resources["PrivacyAgreementWindowButtonAcceptBackground"] = new SolidColorBrush(Color.FromRgb(53, 132, 228));
|
||||
resources["PrivacyAgreementWindowButtonAcceptForeground"] = new SolidColorBrush(Colors.White);
|
||||
}
|
||||
else
|
||||
{
|
||||
resources["PrivacyAgreementWindowBackground"] = new SolidColorBrush(Color.FromRgb(31, 31, 31));
|
||||
resources["PrivacyAgreementWindowForeground"] = new SolidColorBrush(Colors.White);
|
||||
resources["PrivacyAgreementWindowButtonBackground"] = new SolidColorBrush(Color.FromRgb(42, 42, 42));
|
||||
resources["PrivacyAgreementWindowButtonForeground"] = new SolidColorBrush(Colors.White);
|
||||
resources["PrivacyAgreementWindowBorderBrush"] = new SolidColorBrush(Color.FromRgb(224, 224, 224));
|
||||
resources["PrivacyAgreementWindowButtonAcceptBackground"] = new SolidColorBrush(Color.FromRgb(53, 132, 228));
|
||||
resources["PrivacyAgreementWindowButtonAcceptForeground"] = new SolidColorBrush(Colors.White);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"应用隐私说明窗口主题资源出错: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsSystemThemeLight()
|
||||
{
|
||||
var light = false;
|
||||
try
|
||||
{
|
||||
var registryKey = Microsoft.Win32.Registry.CurrentUser;
|
||||
var themeKey = registryKey.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize");
|
||||
if (themeKey != null)
|
||||
{
|
||||
var value = themeKey.GetValue("AppsUseLightTheme");
|
||||
if (value != null)
|
||||
{
|
||||
light = (int)value == 1;
|
||||
}
|
||||
themeKey.Close();
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
light = true;
|
||||
}
|
||||
return light;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user