Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
072f773245 | ||
|
|
0086f65a96 | ||
|
|
281f14f47e | ||
|
|
9fd20ff001 | ||
|
|
7df90a6034 | ||
|
|
019869ec28 | ||
|
|
b7f4fd7469 | ||
|
|
1273d2aee1 | ||
|
|
88990b4828 | ||
|
|
2f02c2970c | ||
|
|
ade789c6d4 |
@@ -11,7 +11,7 @@ namespace AmazTool
|
||||
Console.WriteLine(fileName);
|
||||
Console.WriteLine("In progress, please wait...(正在进行中,请等待)");
|
||||
|
||||
Thread.Sleep(5000);
|
||||
Thread.Sleep(9000);
|
||||
|
||||
if (!File.Exists(fileName))
|
||||
{
|
||||
@@ -25,7 +25,7 @@ namespace AmazTool
|
||||
var path = GetPath(V2rayN);
|
||||
Console.WriteLine(path);
|
||||
var existing = Process.GetProcessesByName(V2rayN);
|
||||
var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName == path);
|
||||
var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName.Contains(path) == true);
|
||||
pp?.Kill();
|
||||
pp?.WaitForExit(1000);
|
||||
}
|
||||
@@ -54,6 +54,8 @@ namespace AmazTool
|
||||
continue;
|
||||
}
|
||||
|
||||
Console.WriteLine(entry.FullName);
|
||||
|
||||
var lst = entry.FullName.Split(splitKey);
|
||||
if (lst.Length == 1) continue;
|
||||
string fullName = string.Join(splitKey, lst[1..lst.Length]);
|
||||
@@ -78,12 +80,12 @@ namespace AmazTool
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Upgrade Failed(升级失败)." + ex.StackTrace);
|
||||
return;
|
||||
//return;
|
||||
}
|
||||
if (sb.Length > 0)
|
||||
{
|
||||
Console.WriteLine("Upgrade Failed(升级失败)." + sb.ToString());
|
||||
return;
|
||||
//return;
|
||||
}
|
||||
|
||||
Console.WriteLine("Start v2rayN, please wait...(正在重启,请等待)");
|
||||
@@ -92,6 +94,7 @@ namespace AmazTool
|
||||
{
|
||||
StartInfo = new()
|
||||
{
|
||||
UseShellExecute = true,
|
||||
FileName = V2rayN,
|
||||
WorkingDirectory = StartupPath()
|
||||
}
|
||||
|
||||
@@ -37,40 +37,41 @@ namespace ServiceLib.Common
|
||||
foreach (var filePath in files)
|
||||
{
|
||||
var file = new FileInfo(filePath);
|
||||
if (file.CreationTime < now)
|
||||
if (file.CreationTime >= now) continue;
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
file.Delete();
|
||||
}
|
||||
catch { }
|
||||
file.Delete();
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
catch
|
||||
{
|
||||
// ignored
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void SaveLog(string strContent)
|
||||
{
|
||||
if (LogManager.IsLoggingEnabled())
|
||||
{
|
||||
var logger = LogManager.GetLogger("Log1");
|
||||
logger.Info(strContent);
|
||||
}
|
||||
if (!LogManager.IsLoggingEnabled()) return;
|
||||
|
||||
LogManager.GetLogger("Log1").Info(strContent);
|
||||
}
|
||||
|
||||
public static void SaveLog(string strTitle, Exception ex)
|
||||
{
|
||||
if (LogManager.IsLoggingEnabled())
|
||||
if (!LogManager.IsLoggingEnabled()) return;
|
||||
|
||||
var logger = LogManager.GetLogger("Log2");
|
||||
logger.Debug($"{strTitle},{ex.Message}");
|
||||
logger.Debug(ex.StackTrace);
|
||||
if (ex?.InnerException != null)
|
||||
{
|
||||
var logger = LogManager.GetLogger("Log2");
|
||||
logger.Debug($"{strTitle},{ex.Message}");
|
||||
logger.Debug(ex.StackTrace);
|
||||
if (ex?.InnerException != null)
|
||||
{
|
||||
logger.Error(ex.InnerException);
|
||||
}
|
||||
logger.Error(ex.InnerException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -818,6 +818,13 @@ namespace ServiceLib.Common
|
||||
return await GetCliWrapOutput("/bin/bash", arg);
|
||||
}
|
||||
|
||||
public static async Task<string?> GetLinuxFontFamily(string lang)
|
||||
{
|
||||
// var arg = new List<string>() { "-c", $"fc-list :lang={lang} family" };
|
||||
var arg = new List<string>() { "-c", $"fc-list : family" };
|
||||
return await GetCliWrapOutput("/bin/bash", arg);
|
||||
}
|
||||
|
||||
#endregion Platform
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
Shutdown,
|
||||
BrowseServer,
|
||||
ImportRulesFromFile,
|
||||
InitSettingFont,
|
||||
SubEditWindow,
|
||||
RoutingRuleSettingWindow,
|
||||
RoutingRuleDetailsWindow,
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
public bool InitComponents()
|
||||
{
|
||||
Logging.Setup();
|
||||
Logging.LoggingEnabled(true);
|
||||
Logging.LoggingEnabled(_config.GuiItem.EnableLog);
|
||||
Logging.SaveLog($"v2rayN start up | {Utils.GetVersion()} | {Utils.GetExePath()}");
|
||||
Logging.SaveLog($"{Environment.OSVersion} - {(Environment.Is64BitOperatingSystem ? 64 : 32)}");
|
||||
Logging.ClearLogs();
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace ServiceLib.Handler
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var vName in it.CoreExes)
|
||||
foreach (var name in it.CoreExes)
|
||||
{
|
||||
var exe = Utils.GetExeName(Utils.GetBinPath(vName, it.CoreType.ToString()));
|
||||
var exe = Utils.GetBinPath(Utils.GetExeName(name), it.CoreType.ToString());
|
||||
if (File.Exists(exe))
|
||||
{
|
||||
await Utils.SetLinuxChmod(exe);
|
||||
@@ -134,17 +134,12 @@ namespace ServiceLib.Handler
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (string vName in it.CoreExes)
|
||||
foreach (var name in it.CoreExes)
|
||||
{
|
||||
var existing = Process.GetProcessesByName(vName);
|
||||
foreach (Process p in existing)
|
||||
{
|
||||
string? path = p.MainModule?.FileName;
|
||||
if (path == Utils.GetExeName(Utils.GetBinPath(vName, it.CoreType.ToString())))
|
||||
{
|
||||
await KillProcess(p);
|
||||
}
|
||||
}
|
||||
var path = Utils.GetBinPath(Utils.GetExeName(name), it.CoreType.ToString());
|
||||
var existing = Process.GetProcessesByName(name);
|
||||
var pp = existing.FirstOrDefault(p => p.MainModule?.FileName != null && p.MainModule?.FileName.Contains(path) == true);
|
||||
await KillProcess(pp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -173,10 +168,9 @@ namespace ServiceLib.Handler
|
||||
private string CoreFindExe(CoreInfo coreInfo)
|
||||
{
|
||||
string fileName = string.Empty;
|
||||
foreach (string name in coreInfo.CoreExes)
|
||||
foreach (var name in coreInfo.CoreExes)
|
||||
{
|
||||
string vName = Utils.GetExeName(name);
|
||||
vName = Utils.GetBinPath(vName, coreInfo.CoreType.ToString());
|
||||
var vName = Utils.GetBinPath(Utils.GetExeName(name), coreInfo.CoreType.ToString());
|
||||
if (File.Exists(vName))
|
||||
{
|
||||
fileName = vName;
|
||||
|
||||
@@ -88,6 +88,8 @@
|
||||
public int TrayMenuServersLimit { get; set; } = 20;
|
||||
|
||||
public bool EnableHWA { get; set; } = false;
|
||||
|
||||
public bool EnableLog { get; set; } = true;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
9
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
9
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
@@ -2860,6 +2860,15 @@ namespace ServiceLib.Resx {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Install the font to the system and restart the settings 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsCurrentFontFamilyLinuxTip {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsCurrentFontFamilyLinuxTip", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Copy the font TTF/TTC file to the directory guiFonts, restart the settings 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -1360,4 +1360,7 @@
|
||||
<data name="InsecureUrlProtocol" xml:space="preserve">
|
||||
<value>Please do not use the insecure HTTP protocol subscription address</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamilyLinuxTip" xml:space="preserve">
|
||||
<value>Install the font to the system and restart the settings</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1357,4 +1357,7 @@
|
||||
<data name="InsecureUrlProtocol" xml:space="preserve">
|
||||
<value>请不要使用不安全的HTTP协议订阅地址</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamilyLinuxTip" xml:space="preserve">
|
||||
<value>安装字体到系统中,重启设置</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -1237,4 +1237,7 @@
|
||||
<data name="InsecureUrlProtocol" xml:space="preserve">
|
||||
<value>請不要使用不安全的HTTP協定訂閱位址</value>
|
||||
</data>
|
||||
<data name="TbSettingsCurrentFontFamilyLinuxTip" xml:space="preserve">
|
||||
<value>安裝字體到系統中,重新啟動設定</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -42,15 +42,7 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"remarks": "代理GFW",
|
||||
"outboundTag": "proxy",
|
||||
"domain": [
|
||||
"geosite:gfw",
|
||||
"geosite:greatfire"
|
||||
]
|
||||
},
|
||||
{
|
||||
"remarks": "代理Google等",
|
||||
"remarks": "代理IP",
|
||||
"outboundTag": "proxy",
|
||||
"ip": [
|
||||
"1.0.0.1",
|
||||
@@ -65,6 +57,14 @@
|
||||
"geoip:twitter"
|
||||
]
|
||||
},
|
||||
{
|
||||
"remarks": "代理GFW",
|
||||
"outboundTag": "proxy",
|
||||
"domain": [
|
||||
"geosite:gfw",
|
||||
"geosite:greatfire"
|
||||
]
|
||||
},
|
||||
{
|
||||
"remarks": "最终直连",
|
||||
"port": "0-65535",
|
||||
|
||||
@@ -34,19 +34,6 @@
|
||||
"geosite:private"
|
||||
]
|
||||
},
|
||||
{
|
||||
"remarks": "绕过中国域名",
|
||||
"outboundTag": "direct",
|
||||
"domain": [
|
||||
"domain:dns.alidns.com",
|
||||
"domain:doh.pub",
|
||||
"domain:dot.pub",
|
||||
"domain:doh.360.cn",
|
||||
"domain:dot.360.cn",
|
||||
"geosite:cn",
|
||||
"geosite:geolocation-cn"
|
||||
]
|
||||
},
|
||||
{
|
||||
"remarks": "绕过中国IP",
|
||||
"outboundTag": "direct",
|
||||
@@ -73,6 +60,19 @@
|
||||
"geoip:cn"
|
||||
]
|
||||
},
|
||||
{
|
||||
"remarks": "绕过中国域名",
|
||||
"outboundTag": "direct",
|
||||
"domain": [
|
||||
"domain:dns.alidns.com",
|
||||
"domain:doh.pub",
|
||||
"domain:dot.pub",
|
||||
"domain:doh.360.cn",
|
||||
"domain:dot.360.cn",
|
||||
"geosite:cn",
|
||||
"geosite:geolocation-cn"
|
||||
]
|
||||
},
|
||||
{
|
||||
"remarks": "最终代理",
|
||||
"port": "0-65535",
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>7.0.2</Version>
|
||||
<Version>7.0.4</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -16,7 +16,7 @@
|
||||
<PackageReference Include="WebDav.Client" Version="2.8.0" />
|
||||
<PackageReference Include="YamlDotNet" Version="16.1.3" />
|
||||
<PackageReference Include="QRCoder" Version="1.6.0" />
|
||||
<PackageReference Include="CliWrap" Version="3.6.6" />
|
||||
<PackageReference Include="CliWrap" Version="3.6.7" />
|
||||
<PackageReference Include="SkiaSharp.QrCode" Version="0.7.0" />
|
||||
<PackageReference Include="ZXing.Net.Bindings.SkiaSharp" Version="0.16.14" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace ServiceLib.Services
|
||||
_updateFunc?.Invoke(false, ResUI.MsgUpdateSubscriptionStart);
|
||||
var subItem = await AppHandler.Instance.SubItems();
|
||||
|
||||
if (subItem == null || subItem.Count <= 0)
|
||||
if (subItem is not { Count: > 0 })
|
||||
{
|
||||
_updateFunc?.Invoke(false, ResUI.MsgNoValidSubscription);
|
||||
return;
|
||||
@@ -122,10 +122,10 @@ namespace ServiceLib.Services
|
||||
|
||||
foreach (var item in subItem)
|
||||
{
|
||||
string id = item.Id.TrimEx();
|
||||
string url = item.Url.TrimEx();
|
||||
string userAgent = item.UserAgent.TrimEx();
|
||||
string hashCode = $"{item.Remarks}->";
|
||||
var id = item.Id.TrimEx();
|
||||
var url = item.Url.TrimEx();
|
||||
var userAgent = item.UserAgent.TrimEx();
|
||||
var hashCode = $"{item.Remarks}->";
|
||||
if (Utils.IsNullOrEmpty(id) || Utils.IsNullOrEmpty(url) || Utils.IsNotEmpty(subId) && item.Id != subId)
|
||||
{
|
||||
//_updateFunc?.Invoke(false, $"{hashCode}{ResUI.MsgNoValidSubscription}");
|
||||
@@ -219,7 +219,7 @@ namespace ServiceLib.Services
|
||||
_updateFunc?.Invoke(false, $"{hashCode}{result}");
|
||||
}
|
||||
|
||||
int ret = await ConfigHandler.AddBatchServers(config, result, id, true);
|
||||
var ret = await ConfigHandler.AddBatchServers(config, result, id, true);
|
||||
if (ret <= 0)
|
||||
{
|
||||
Logging.SaveLog("FailedImportSubscription");
|
||||
@@ -231,6 +231,8 @@ namespace ServiceLib.Services
|
||||
: $"{hashCode}{ResUI.MsgFailedImportSubscription}");
|
||||
}
|
||||
_updateFunc?.Invoke(false, "-------------------------------------------------------");
|
||||
|
||||
await ConfigHandler.DedupServerList(config, id);
|
||||
}
|
||||
|
||||
_updateFunc?.Invoke(true, $"{ResUI.MsgUpdateSubscriptionEnd}");
|
||||
@@ -309,10 +311,9 @@ namespace ServiceLib.Services
|
||||
{
|
||||
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo(type);
|
||||
string filePath = string.Empty;
|
||||
foreach (string name in coreInfo.CoreExes)
|
||||
foreach (var name in coreInfo.CoreExes)
|
||||
{
|
||||
string vName = Utils.GetExeName(name);
|
||||
vName = Utils.GetBinPath(vName, coreInfo.CoreType.ToString());
|
||||
var vName = Utils.GetBinPath(Utils.GetExeName(name), coreInfo.CoreType.ToString());
|
||||
if (File.Exists(vName))
|
||||
{
|
||||
filePath = vName;
|
||||
|
||||
@@ -45,16 +45,12 @@ namespace ServiceLib.ViewModels
|
||||
|
||||
if (RuntimeInformation.ProcessArchitecture != Architecture.X86)
|
||||
{
|
||||
if (Utils.IsWindows())
|
||||
_checkUpdateItem.Add(new CheckUpdateItem()
|
||||
{
|
||||
_checkUpdateItem.Add(new CheckUpdateItem()
|
||||
{
|
||||
IsSelected = false,
|
||||
CoreType = _v2rayN,
|
||||
Remarks = ResUI.menuCheckUpdate,
|
||||
});
|
||||
}
|
||||
|
||||
IsSelected = false,
|
||||
CoreType = _v2rayN,
|
||||
Remarks = ResUI.menuCheckUpdate,
|
||||
});
|
||||
_checkUpdateItem.Add(new CheckUpdateItem()
|
||||
{
|
||||
IsSelected = true,
|
||||
|
||||
@@ -313,6 +313,7 @@ namespace ServiceLib.ViewModels
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
UseShellExecute = true,
|
||||
FileName = fileName,
|
||||
Arguments = arg.AppendQuotes(),
|
||||
WorkingDirectory = Utils.StartupPath()
|
||||
|
||||
@@ -117,6 +117,8 @@ namespace ServiceLib.ViewModels
|
||||
|
||||
private async Task Init()
|
||||
{
|
||||
await _updateView?.Invoke(EViewAction.InitSettingFont, null);
|
||||
|
||||
#region Core
|
||||
|
||||
var inbound = _config.Inbound[0];
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Notifications;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Styling;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
@@ -9,14 +12,11 @@ namespace v2rayN.Desktop.ViewModels
|
||||
{
|
||||
public class ThemeSettingViewModel : MyReactiveObject
|
||||
{
|
||||
[Reactive]
|
||||
public bool ColorModeDark { get; set; }
|
||||
[Reactive] public bool ColorModeDark { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public int CurrentFontSize { get; set; }
|
||||
[Reactive] public int CurrentFontSize { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string CurrentLanguage { get; set; }
|
||||
[Reactive] public string CurrentLanguage { get; set; }
|
||||
|
||||
public ThemeSettingViewModel()
|
||||
{
|
||||
@@ -29,6 +29,7 @@ namespace v2rayN.Desktop.ViewModels
|
||||
private void RestoreUI()
|
||||
{
|
||||
ModifyTheme(_config.UiItem.ColorModeDark);
|
||||
ModifyFontFamily();
|
||||
}
|
||||
|
||||
private void BindingUI()
|
||||
@@ -38,34 +39,34 @@ namespace v2rayN.Desktop.ViewModels
|
||||
CurrentLanguage = _config.UiItem.CurrentLanguage;
|
||||
|
||||
this.WhenAnyValue(x => x.ColorModeDark)
|
||||
.Subscribe(c =>
|
||||
{
|
||||
if (_config.UiItem.ColorModeDark != ColorModeDark)
|
||||
{
|
||||
_config.UiItem.ColorModeDark = ColorModeDark;
|
||||
ModifyTheme(ColorModeDark);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
});
|
||||
.Subscribe(c =>
|
||||
{
|
||||
if (_config.UiItem.ColorModeDark != ColorModeDark)
|
||||
{
|
||||
_config.UiItem.ColorModeDark = ColorModeDark;
|
||||
ModifyTheme(ColorModeDark);
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
});
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.CurrentFontSize,
|
||||
y => y > 0)
|
||||
.Subscribe(c =>
|
||||
{
|
||||
if (CurrentFontSize >= Global.MinFontSize)
|
||||
{
|
||||
_config.UiItem.CurrentFontSize = CurrentFontSize;
|
||||
double size = CurrentFontSize;
|
||||
ModifyFontSize(size);
|
||||
x => x.CurrentFontSize,
|
||||
y => y > 0)
|
||||
.Subscribe(c =>
|
||||
{
|
||||
if (CurrentFontSize >= Global.MinFontSize)
|
||||
{
|
||||
_config.UiItem.CurrentFontSize = CurrentFontSize;
|
||||
double size = CurrentFontSize;
|
||||
ModifyFontSize(size);
|
||||
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
});
|
||||
ConfigHandler.SaveConfig(_config);
|
||||
}
|
||||
});
|
||||
|
||||
this.WhenAnyValue(
|
||||
x => x.CurrentLanguage,
|
||||
y => y != null && !y.IsNullOrEmpty())
|
||||
x => x.CurrentLanguage,
|
||||
y => y != null && !y.IsNullOrEmpty())
|
||||
.Subscribe(c =>
|
||||
{
|
||||
if (Utils.IsNotEmpty(CurrentLanguage) && _config.UiItem.CurrentLanguage != CurrentLanguage)
|
||||
@@ -89,53 +90,54 @@ namespace v2rayN.Desktop.ViewModels
|
||||
|
||||
private void ModifyFontSize(double size)
|
||||
{
|
||||
Style buttonStyle = new(x => x.OfType<Button>());
|
||||
buttonStyle.Add(new Setter()
|
||||
Style style = new(x => Selectors.Or(
|
||||
x.OfType<Button>(),
|
||||
x.OfType<TextBox>(),
|
||||
x.OfType<TextBlock>(),
|
||||
x.OfType<Menu>(),
|
||||
x.OfType<ContextMenu>(),
|
||||
x.OfType<DataGridRow>(),
|
||||
x.OfType<ListBoxItem>()
|
||||
));
|
||||
style.Add(new Setter()
|
||||
{
|
||||
Property = Button.FontSizeProperty,
|
||||
Property = TemplatedControl.FontSizeProperty,
|
||||
Value = size,
|
||||
});
|
||||
Application.Current?.Styles.Add(buttonStyle);
|
||||
Application.Current?.Styles.Add(style);
|
||||
}
|
||||
|
||||
Style textStyle = new(x => x.OfType<TextBox>());
|
||||
textStyle.Add(new Setter()
|
||||
private void ModifyFontFamily()
|
||||
{
|
||||
var currentFontFamily = _config.UiItem.CurrentFontFamily;
|
||||
if (currentFontFamily.IsNullOrEmpty())
|
||||
{
|
||||
Property = TextBox.FontSizeProperty,
|
||||
Value = size,
|
||||
});
|
||||
Application.Current?.Styles.Add(textStyle);
|
||||
return;
|
||||
}
|
||||
|
||||
Style textBlockStyle = new(x => x.OfType<TextBlock>());
|
||||
textBlockStyle.Add(new Setter()
|
||||
try
|
||||
{
|
||||
Property = TextBlock.FontSizeProperty,
|
||||
Value = size,
|
||||
});
|
||||
Application.Current?.Styles.Add(textBlockStyle);
|
||||
|
||||
Style menuStyle = new(x => x.OfType<Menu>());
|
||||
menuStyle.Add(new Setter()
|
||||
Style style = new(x => Selectors.Or(
|
||||
x.OfType<Button>(),
|
||||
x.OfType<TextBox>(),
|
||||
x.OfType<TextBlock>(),
|
||||
x.OfType<Menu>(),
|
||||
x.OfType<ContextMenu>(),
|
||||
x.OfType<DataGridRow>(),
|
||||
x.OfType<ListBoxItem>(),
|
||||
x.OfType<WindowNotificationManager>()
|
||||
));
|
||||
style.Add(new Setter()
|
||||
{
|
||||
Property = TemplatedControl.FontFamilyProperty,
|
||||
Value = new FontFamily(currentFontFamily),
|
||||
});
|
||||
Application.Current?.Styles.Add(style);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Property = Menu.FontSizeProperty,
|
||||
Value = size,
|
||||
});
|
||||
Application.Current?.Styles.Add(menuStyle);
|
||||
|
||||
Style dataStyle = new(x => x.OfType<DataGridRow>());
|
||||
dataStyle.Add(new Setter()
|
||||
{
|
||||
Property = DataGridRow.FontSizeProperty,
|
||||
Value = size,
|
||||
});
|
||||
Application.Current?.Styles.Add(dataStyle);
|
||||
|
||||
Style listStyle = new(x => x.OfType<ListBoxItem>());
|
||||
listStyle.Add(new Setter()
|
||||
{
|
||||
Property = ListBoxItem.FontSizeProperty,
|
||||
Value = size,
|
||||
});
|
||||
Application.Current?.Styles.Add(listStyle);
|
||||
Logging.SaveLog("ModifyFontFamily", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -533,7 +533,6 @@
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
Classes="Margin8"
|
||||
IsVisible="False"
|
||||
Text="{x:Static resx:ResUI.TbSettingsCurrentFontFamily}" />
|
||||
<ComboBox
|
||||
x:Name="cmbcurrentFontFamily"
|
||||
@@ -541,15 +540,13 @@
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Classes="Margin8"
|
||||
IsVisible="False"
|
||||
MaxDropDownHeight="1000" />
|
||||
<TextBlock
|
||||
Grid.Row="16"
|
||||
Grid.Column="2"
|
||||
VerticalAlignment="Center"
|
||||
Classes="Margin8"
|
||||
IsVisible="False"
|
||||
Text="{x:Static resx:ResUI.TbSettingsCurrentFontFamilyTip}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsCurrentFontFamilyLinuxTip}"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
<TextBlock
|
||||
@@ -677,7 +674,6 @@
|
||||
Classes="Margin8"
|
||||
Text="{x:Static resx:ResUI.TbSettingsChinaUserTip}"
|
||||
TextWrapping="Wrap" />
|
||||
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</TabItem>
|
||||
|
||||
@@ -15,7 +15,6 @@ namespace v2rayN.Desktop.Views
|
||||
|
||||
btnCancel.Click += (s, e) => this.Close();
|
||||
_config = AppHandler.Instance.Config;
|
||||
// var lstFonts = GetFonts(Utils.GetFontsPath());
|
||||
|
||||
ViewModel = new OptionSettingViewModel(UpdateViewHandler);
|
||||
|
||||
@@ -100,9 +99,6 @@ namespace v2rayN.Desktop.Views
|
||||
cmbMainGirdOrientation.Items.Add(it.ToString());
|
||||
}
|
||||
|
||||
//lstFonts.ForEach(it => { cmbcurrentFontFamily.Items.Add(it); });
|
||||
//cmbcurrentFontFamily.Items.Add(string.Empty);
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
this.Bind(ViewModel, vm => vm.localPort, v => v.txtlocalPort.Text).DisposeWith(disposables);
|
||||
@@ -182,58 +178,53 @@ namespace v2rayN.Desktop.Views
|
||||
// WindowsUtils.SetAutoRun(Global.AutoRunRegPath, Global.AutoRunName, togAutoRun.IsChecked ?? false);
|
||||
this.Close(true);
|
||||
break;
|
||||
|
||||
case EViewAction.InitSettingFont:
|
||||
await InitSettingFont();
|
||||
break;
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
//private List<string> GetFonts(string path)
|
||||
//{
|
||||
// var lstFonts = new List<string>();
|
||||
// try
|
||||
// {
|
||||
// string[] searchPatterns = { "*.ttf", "*.ttc" };
|
||||
// var files = new List<string>();
|
||||
// foreach (var pattern in searchPatterns)
|
||||
// {
|
||||
// files.AddRange(Directory.GetFiles(path, pattern));
|
||||
// }
|
||||
// var culture = _config.uiItem.currentLanguage == Global.Languages[0] ? "zh-cn" : "en-us";
|
||||
// var culture2 = "en-us";
|
||||
// foreach (var ttf in files)
|
||||
// {
|
||||
// var families = Fonts.GetFontFamilies(Utils.GetFontsPath(ttf));
|
||||
// foreach (FontFamily family in families)
|
||||
// {
|
||||
// var typefaces = family.GetTypefaces();
|
||||
// foreach (Typeface typeface in typefaces)
|
||||
// {
|
||||
// typeface.TryGetGlyphTypeface(out GlyphTypeface glyph);
|
||||
// //var fontFace = glyph.Win32FaceNames[new CultureInfo("en-us")];
|
||||
// //if (!fontFace.Equals("Regular") && !fontFace.Equals("Normal"))
|
||||
// //{
|
||||
// // continue;
|
||||
// //}
|
||||
// var fontFamily = glyph.Win32FamilyNames[new CultureInfo(culture)];
|
||||
// if (Utils.IsNullOrEmpty(fontFamily))
|
||||
// {
|
||||
// fontFamily = glyph.Win32FamilyNames[new CultureInfo(culture2)];
|
||||
// if (Utils.IsNullOrEmpty(fontFamily))
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// lstFonts.Add(fontFamily);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Logging.SaveLog("fill fonts error", ex);
|
||||
// }
|
||||
// return lstFonts;
|
||||
//}
|
||||
private async Task InitSettingFont()
|
||||
{
|
||||
var lstFonts = await GetFonts();
|
||||
lstFonts.ForEach(it => { cmbcurrentFontFamily.Items.Add(it); });
|
||||
cmbcurrentFontFamily.Items.Add(string.Empty);
|
||||
}
|
||||
|
||||
private async Task<List<string>> GetFonts()
|
||||
{
|
||||
var lstFonts = new List<string>();
|
||||
try
|
||||
{
|
||||
if (Utils.IsWindows())
|
||||
{
|
||||
return lstFonts;
|
||||
}
|
||||
else if (Utils.IsLinux())
|
||||
{
|
||||
var result = await Utils.GetLinuxFontFamily("zh");
|
||||
if (result.IsNullOrEmpty())
|
||||
{
|
||||
return lstFonts;
|
||||
}
|
||||
|
||||
var lst = result.Split(Environment.NewLine)
|
||||
.Where(t => t.IsNotEmpty())
|
||||
.ToList()
|
||||
.Select(t => t.Split(",").FirstOrDefault() ?? "")
|
||||
.OrderBy(t => t)
|
||||
.ToList();
|
||||
return lst;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog("fill fonts error", ex);
|
||||
}
|
||||
return lstFonts;
|
||||
}
|
||||
|
||||
private void ClbdestOverride_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.4" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.4" />
|
||||
<PackageReference Include="DialogHost.Avalonia" Version="0.8.1" />
|
||||
<PackageReference Include="MessageBox.Avalonia" Version="3.1.6.13" />
|
||||
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
|
||||
<PackageReference Include="Semi.Avalonia" Version="11.1.0.4" />
|
||||
<PackageReference Include="Semi.Avalonia.DataGrid" Version="11.1.0.4" />
|
||||
<PackageReference Include="ReactiveUI" Version="20.1.63" />
|
||||
|
||||
@@ -17,7 +17,6 @@ namespace v2rayN.Views
|
||||
|
||||
this.Owner = Application.Current.MainWindow;
|
||||
_config = AppHandler.Instance.Config;
|
||||
var lstFonts = GetFonts(Utils.GetFontsPath());
|
||||
|
||||
ViewModel = new OptionSettingViewModel(UpdateViewHandler);
|
||||
|
||||
@@ -102,9 +101,6 @@ namespace v2rayN.Views
|
||||
cmbMainGirdOrientation.Items.Add(it.ToString());
|
||||
}
|
||||
|
||||
lstFonts.ForEach(it => { cmbcurrentFontFamily.Items.Add(it); });
|
||||
cmbcurrentFontFamily.Items.Add(string.Empty);
|
||||
|
||||
this.WhenActivated(disposables =>
|
||||
{
|
||||
this.Bind(ViewModel, vm => vm.localPort, v => v.txtlocalPort.Text).DisposeWith(disposables);
|
||||
@@ -191,11 +187,22 @@ namespace v2rayN.Views
|
||||
WindowsUtils.SetAutoRun(Global.AutoRunRegPath, Global.AutoRunName, togAutoRun.IsChecked ?? false);
|
||||
this.DialogResult = true;
|
||||
break;
|
||||
|
||||
case EViewAction.InitSettingFont:
|
||||
await InitSettingFont();
|
||||
break;
|
||||
}
|
||||
return await Task.FromResult(true);
|
||||
}
|
||||
|
||||
private List<string> GetFonts(string path)
|
||||
private async Task InitSettingFont()
|
||||
{
|
||||
var lstFonts = await GetFonts(Utils.GetFontsPath());
|
||||
lstFonts.ForEach(it => { cmbcurrentFontFamily.Items.Add(it); });
|
||||
cmbcurrentFontFamily.Items.Add(string.Empty);
|
||||
}
|
||||
|
||||
private async Task<List<string>> GetFonts(string path)
|
||||
{
|
||||
var lstFonts = new List<string>();
|
||||
try
|
||||
@@ -241,7 +248,7 @@ namespace v2rayN.Views
|
||||
{
|
||||
Logging.SaveLog("fill fonts error", ex);
|
||||
}
|
||||
return lstFonts;
|
||||
return lstFonts.OrderBy(t => t).ToList();
|
||||
}
|
||||
|
||||
private void ClbdestOverride_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||
|
||||
Reference in New Issue
Block a user