Compare commits

..

No commits in common. "91af50f99a6398eb37cc6f2a0ba2ad4e6aad82aa" and "64c7fea2bc46c541d0f4a89c4a6ce31ec36cb8c4" have entirely different histories.

40 changed files with 117 additions and 285 deletions

View file

@ -84,14 +84,4 @@ public static class Extension
{
return source.Concat(new[] { string.Empty }).ToList();
}
public static bool IsGroupType(this EConfigType configType)
{
return configType is EConfigType.PolicyGroup or EConfigType.ProxyChain;
}
public static bool IsComplexType(this EConfigType configType)
{
return configType is EConfigType.Custom or EConfigType.PolicyGroup or EConfigType.ProxyChain;
}
}

View file

@ -13,6 +13,8 @@ public enum EConfigType
WireGuard = 9,
HTTP = 10,
Anytls = 11,
PolicyGroup = 101,
ProxyChain = 102,
Group = 1000,
PolicyGroup = 1001,
ProxyChain = 1002,
}

View file

@ -1,8 +0,0 @@
namespace ServiceLib.Enums;
public enum ERuleType
{
ALL = 0,
Routing = 1,
DNS = 2,
}

View file

@ -316,8 +316,6 @@ public class Global
EConfigType.HTTP,
];
public static readonly HashSet<EConfigType> SingboxOnlyConfigType = SingboxSupportConfigType.Except(XraySupportConfigType).ToHashSet();
public static readonly List<string> DomainStrategies =
[
AsIs,

View file

@ -357,7 +357,7 @@ public static class ConfigHandler
{
}
}
else if (profileItem.ConfigType.IsGroupType())
else if (profileItem.ConfigType > EConfigType.Group)
{
var profileGroupItem = await AppManager.Instance.GetProfileGroupItem(it.IndexId);
await AddGroupServerCommon(config, profileItem, profileGroupItem, true);
@ -1255,7 +1255,7 @@ public static class ConfigHandler
if (node.ConfigType != EConfigType.Custom && coreType != ECoreType.sing_box && config.TunModeItem.EnableTun)
{
var tun2SocksAddress = node.Address;
if (node.ConfigType.IsGroupType())
if (node.ConfigType > EConfigType.Group)
{
var lstAddresses = (await ProfileGroupItemManager.GetAllChildDomainAddresses(node.IndexId)).ToList();
if (lstAddresses.Count > 0)

View file

@ -77,6 +77,7 @@ public class ActionPrecheckManager(Config config)
return errors;
}
switch (item.ConfigType)
{
case EConfigType.VMess:
@ -112,7 +113,7 @@ public class ActionPrecheckManager(Config config)
}
}
if (item.ConfigType.IsGroupType())
if (item.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
ProfileGroupItemManager.Instance.TryGet(item.IndexId, out var group);
if (group is null || group.ChildItems.IsNullOrEmpty())

View file

@ -95,7 +95,7 @@ public class CoreManager
public async Task<ProcessService?> LoadCoreConfigSpeedtest(List<ServerTestItem> selecteds)
{
var coreType = selecteds.Any(t => Global.SingboxOnlyConfigType.Contains(t.ConfigType)) ? ECoreType.sing_box : ECoreType.Xray;
var coreType = selecteds.Exists(t => t.ConfigType is EConfigType.Hysteria2 or EConfigType.TUIC or EConfigType.Anytls) ? ECoreType.sing_box : ECoreType.Xray;
var fileName = string.Format(Global.CoreSpeedtestConfigFileName, Utils.GetGuid(false));
var configPath = Utils.GetBinConfigPath(fileName);
var result = await CoreConfigHandler.GenerateClientSpeedtestConfig(_config, configPath, selecteds, coreType);

View file

@ -269,7 +269,7 @@ public class ProfileGroupItemManager
{
childAddresses.Add(childNode.Address);
}
else if (childNode.ConfigType.IsGroupType())
else if (childNode.ConfigType > EConfigType.Group)
{
var subAddresses = await GetAllChildDomainAddresses(childNode.IndexId);
foreach (var addr in subAddresses)

View file

@ -66,7 +66,7 @@ public class ProfileItem : ReactiveObject
public bool IsComplex()
{
return ConfigType.IsComplexType();
return ConfigType is EConfigType.Custom or > EConfigType.Group;
}
public bool IsValid()

View file

@ -15,5 +15,4 @@ public class RulesItem
public List<string>? Process { get; set; }
public bool Enabled { get; set; } = true;
public string? Remarks { get; set; }
public ERuleType? RuleType { get; set; }
}

View file

@ -7,5 +7,4 @@ public class RulesItemModel : RulesItem
public string Ips { get; set; }
public string Domains { get; set; }
public string Protocols { get; set; }
public string RuleTypeName { get; set; }
}

View file

@ -3156,24 +3156,6 @@ namespace ServiceLib.Resx {
}
}
/// <summary>
/// 查找类似 Rule Type 的本地化字符串。
/// </summary>
public static string TbRuleType {
get {
return ResourceManager.GetString("TbRuleType", resourceCulture);
}
}
/// <summary>
/// 查找类似 You can set separate rules for Routing and DNS, or select &quot;ALL&quot; to apply to both 的本地化字符串。
/// </summary>
public static string TbRuleTypeTips {
get {
return ResourceManager.GetString("TbRuleTypeTips", resourceCulture);
}
}
/// <summary>
/// 查找类似 Bootstrap DNS (sing-box) 的本地化字符串。
/// </summary>

View file

@ -1596,10 +1596,4 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>If the system does not have a tray function, please do not enable it</value>
</data>
<data name="TbRuleType" xml:space="preserve">
<value>Rule Type</value>
</data>
<data name="TbRuleTypeTips" xml:space="preserve">
<value>You can set separate rules for Routing and DNS, or select "ALL" to apply to both</value>
</data>
</root>

View file

@ -1596,10 +1596,4 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>If the system does not have a tray function, please do not enable it</value>
</data>
<data name="TbRuleTypeTips" xml:space="preserve">
<value>You can set separate rules for Routing and DNS, or select "ALL" to apply to both</value>
</data>
<data name="TbRuleType" xml:space="preserve">
<value>Rule Type</value>
</data>
</root>

View file

@ -1596,10 +1596,4 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>If the system does not have a tray function, please do not enable it</value>
</data>
<data name="TbRuleTypeTips" xml:space="preserve">
<value>You can set separate rules for Routing and DNS, or select "ALL" to apply to both</value>
</data>
<data name="TbRuleType" xml:space="preserve">
<value>Rule Type</value>
</data>
</root>

View file

@ -1596,10 +1596,4 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>If the system does not have a tray function, please do not enable it</value>
</data>
<data name="TbRuleTypeTips" xml:space="preserve">
<value>You can set separate rules for Routing and DNS, or select "ALL" to apply to both</value>
</data>
<data name="TbRuleType" xml:space="preserve">
<value>Rule Type</value>
</data>
</root>

View file

@ -1593,10 +1593,4 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>如果系统没有托盘功能,请不要开启</value>
</data>
<data name="TbRuleType" xml:space="preserve">
<value>规则类型</value>
</data>
<data name="TbRuleTypeTips" xml:space="preserve">
<value>可对 Routing 和 DNS 单独设定规则ALL 则都生效</value>
</data>
</root>

View file

@ -1593,10 +1593,4 @@
<data name="TbSettingsHide2TrayWhenCloseTip" xml:space="preserve">
<value>如果系統沒有托盤功能,請不要開啟</value>
</data>
<data name="TbRuleType" xml:space="preserve">
<value>规则类型</value>
</data>
<data name="TbRuleTypeTips" xml:space="preserve">
<value>可对 Routing 和 DNS 单独设定规则ALL 则都生效</value>
</data>
</root>

View file

@ -1,6 +1,5 @@
using System.Net;
using System.Net.NetworkInformation;
using ServiceLib.Common;
namespace ServiceLib.Services.CoreConfig;
@ -30,13 +29,12 @@ public partial class CoreConfigSingboxService(Config config)
ret.Msg = ResUI.InitialConfiguration;
if (node.ConfigType.IsGroupType())
if (node?.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
switch (node.ConfigType)
{
case EConfigType.PolicyGroup:
return await GenerateClientMultipleLoadConfig(node);
case EConfigType.ProxyChain:
return await GenerateClientChainConfig(node);
}

View file

@ -253,11 +253,6 @@ public partial class CoreConfigSingboxService
continue;
}
if (item.RuleType == ERuleType.Routing)
{
continue;
}
var rule = new Rule4Sbox();
var validDomains = item.Domain.Count(it => ParseV2Domain(it, rule));
if (validDomains <= 0)

View file

@ -208,7 +208,7 @@ public partial class CoreConfigSingboxService
{
try
{
if (!node.ConfigType.IsGroupType())
if (node.ConfigType is not (EConfigType.PolicyGroup or EConfigType.ProxyChain))
{
return -1;
}
@ -236,11 +236,9 @@ public partial class CoreConfigSingboxService
}
break;
case EConfigType.ProxyChain:
await GenChainOutboundsList(childProfiles, singboxConfig, baseTagName);
break;
default:
break;
}
@ -494,7 +492,7 @@ public partial class CoreConfigSingboxService
{
index++;
if (node.ConfigType.IsGroupType())
if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
var (childProfiles, profileGroupItem) = await ProfileGroupItemManager.GetChildProfileItems(node.IndexId);
if (childProfiles.Count <= 0)
@ -669,7 +667,7 @@ public partial class CoreConfigSingboxService
var node = nodes[i];
if (node == null)
continue;
if (node.ConfigType.IsGroupType())
if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
var (childProfiles, profileGroupItem) = await ProfileGroupItemManager.GetChildProfileItems(node.IndexId);
if (childProfiles.Count <= 0)

View file

@ -136,21 +136,13 @@ public partial class CoreConfigSingboxService
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
foreach (var item1 in rules ?? [])
{
if (!item1.Enabled)
if (item1.Enabled)
{
continue;
}
if (item1.RuleType == ERuleType.DNS)
{
continue;
}
await GenRoutingUserRule(item1, singboxConfig);
if (item1.Ip?.Count > 0)
{
ipRules.Add(item1);
await GenRoutingUserRule(item1, singboxConfig);
if (item1.Ip != null && item1.Ip.Count > 0)
{
ipRules.Add(item1);
}
}
}
}
@ -379,7 +371,7 @@ public partial class CoreConfigSingboxService
if (node == null
|| (!Global.SingboxSupportConfigType.Contains(node.ConfigType)
&& !node.ConfigType.IsGroupType()))
&& node.ConfigType is not (EConfigType.PolicyGroup or EConfigType.ProxyChain)))
{
return Global.ProxyTag;
}
@ -391,7 +383,7 @@ public partial class CoreConfigSingboxService
return tag;
}
if (node.ConfigType.IsGroupType())
if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
var ret = await GenGroupOutbound(node, singboxConfig, tag);
if (ret == 0)

View file

@ -30,13 +30,12 @@ public partial class CoreConfigV2rayService(Config config)
ret.Msg = ResUI.InitialConfiguration;
if (node.ConfigType.IsGroupType())
if (node?.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
switch (node.ConfigType)
{
case EConfigType.PolicyGroup:
return await GenerateClientMultipleLoadConfig(node);
case EConfigType.ProxyChain:
return await GenerateClientChainConfig(node);
}

View file

@ -142,11 +142,6 @@ public partial class CoreConfigV2rayService
continue;
}
if (item.RuleType == ERuleType.Routing)
{
continue;
}
foreach (var domain in item.Domain)
{
if (domain.StartsWith('#'))

View file

@ -484,7 +484,7 @@ public partial class CoreConfigV2rayService
{
try
{
if (!node.ConfigType.IsGroupType())
if (node.ConfigType is not (EConfigType.PolicyGroup or EConfigType.ProxyChain))
{
return -1;
}
@ -511,11 +511,9 @@ public partial class CoreConfigV2rayService
await GenOutboundsListWithChain(childProfiles, v2rayConfig, baseTagName);
}
break;
case EConfigType.ProxyChain:
await GenChainOutboundsList(childProfiles, v2rayConfig, baseTagName);
break;
default:
break;
}
@ -631,7 +629,7 @@ public partial class CoreConfigV2rayService
{
index++;
if (node.ConfigType.IsGroupType())
if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
var (childProfiles, _) = await ProfileGroupItemManager.GetChildProfileItems(node.IndexId);
if (childProfiles.Count <= 0)
@ -782,7 +780,7 @@ public partial class CoreConfigV2rayService
var node = nodes[i];
if (node == null)
continue;
if (node.ConfigType.IsGroupType())
if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
var (childProfiles, _) = await ProfileGroupItemManager.GetChildProfileItems(node.IndexId);
if (childProfiles.Count <= 0)

View file

@ -20,18 +20,11 @@ public partial class CoreConfigV2rayService
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
foreach (var item in rules)
{
if (!item.Enabled)
if (item.Enabled)
{
continue;
var item2 = JsonUtils.Deserialize<RulesItem4Ray>(JsonUtils.Serialize(item));
await GenRoutingUserRule(item2, v2rayConfig);
}
if (item.RuleType == ERuleType.DNS)
{
continue;
}
var item2 = JsonUtils.Deserialize<RulesItem4Ray>(JsonUtils.Serialize(item));
await GenRoutingUserRule(item2, v2rayConfig);
}
}
}
@ -135,7 +128,7 @@ public partial class CoreConfigV2rayService
if (node == null
|| (!Global.XraySupportConfigType.Contains(node.ConfigType)
&& !node.ConfigType.IsGroupType()))
&& node.ConfigType is not (EConfigType.PolicyGroup or EConfigType.ProxyChain)))
{
return Global.ProxyTag;
}
@ -146,7 +139,7 @@ public partial class CoreConfigV2rayService
return tag;
}
if (node.ConfigType.IsGroupType())
if (node.ConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
var ret = await GenGroupOutbound(node, v2rayConfig, tag);
if (ret == 0)

View file

@ -64,7 +64,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
var lstSelected = new List<ServerTestItem>();
foreach (var it in selecteds)
{
if (it.ConfigType.IsComplexType())
if (it.ConfigType == EConfigType.Custom)
{
continue;
}
@ -116,6 +116,10 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
List<Task> tasks = [];
foreach (var it in selecteds)
{
if (it.ConfigType == EConfigType.Custom)
{
continue;
}
tasks.Add(Task.Run(async () =>
{
try
@ -195,6 +199,10 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
{
continue;
}
if (it.ConfigType == EConfigType.Custom)
{
continue;
}
tasks.Add(Task.Run(async () =>
{
await DoRealPing(it);
@ -208,10 +216,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
}
finally
{
if (processService != null)
{
await processService?.StopAsync();
}
await processService?.StopAsync();
}
return true;
}
@ -228,6 +233,10 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
await UpdateFunc(it.IndexId, "", ResUI.SpeedtestingSkip);
continue;
}
if (it.ConfigType == EConfigType.Custom)
{
continue;
}
await concurrencySemaphore.WaitAsync();
tasks.Add(Task.Run(async () =>
@ -263,10 +272,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
}
finally
{
if (processService != null)
{
await processService?.StopAsync();
}
await processService?.StopAsync();
concurrencySemaphore.Release();
}
}));
@ -339,7 +345,7 @@ public class SpeedtestService(Config config, Func<SpeedTestResult, Task> updateF
{
List<List<ServerTestItem>> lstTest = new();
var lst1 = lstSelected.Where(t => Global.XraySupportConfigType.Contains(t.ConfigType)).ToList();
var lst2 = lstSelected.Where(t => Global.SingboxOnlyConfigType.Contains(t.ConfigType)).ToList();
var lst2 = lstSelected.Where(t => Global.SingboxSupportConfigType.Contains(t.ConfigType) && !Global.XraySupportConfigType.Contains(t.ConfigType)).ToList();
for (var num = 0; num < (int)Math.Ceiling(lst1.Count * 1.0 / pageSize); num++)
{

View file

@ -350,7 +350,7 @@ public class MainWindowViewModel : MyReactiveObject
{
ret = await _updateView?.Invoke(EViewAction.AddServer2Window, item);
}
else if (eConfigType.IsGroupType())
else if (eConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
ret = await _updateView?.Invoke(EViewAction.AddGroupServerWindow, item);
}

View file

@ -510,7 +510,7 @@ public class ProfilesViewModel : MyReactiveObject
{
ret = await _updateView?.Invoke(EViewAction.AddServer2Window, item);
}
else if (eConfigType.IsGroupType())
else if (eConfigType is EConfigType.PolicyGroup or EConfigType.ProxyChain)
{
ret = await _updateView?.Invoke(EViewAction.AddGroupServerWindow, item);
}

View file

@ -21,9 +21,6 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
[Reactive]
public string Process { get; set; }
[Reactive]
public string? RuleType { get; set; }
[Reactive]
public bool AutoSort { get; set; }
@ -54,7 +51,6 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
Domain = Utils.List2String(SelectedSource.Domain, true);
IP = Utils.List2String(SelectedSource.Ip, true);
Process = Utils.List2String(SelectedSource.Process, true);
RuleType = SelectedSource.RuleType?.ToString();
}
private async Task SaveRulesAsync()
@ -77,7 +73,6 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
}
SelectedSource.Protocol = ProtocolItems?.ToList();
SelectedSource.InboundTag = InboundTagItems?.ToList();
SelectedSource.RuleType = RuleType.IsNullOrEmpty() ? null : (ERuleType)Enum.Parse(typeof(ERuleType), RuleType);
var hasRule = SelectedSource.Domain?.Count > 0
|| SelectedSource.Ip?.Count > 0

View file

@ -107,13 +107,13 @@ public class RoutingRuleSettingViewModel : MyReactiveObject
var it = new RulesItemModel()
{
Id = item.Id,
RuleTypeName = item.RuleType?.ToString(),
OutboundTag = item.OutboundTag,
Port = item.Port,
Network = item.Network,
Protocols = Utils.List2String(item.Protocol),
InboundTags = Utils.List2String(item.InboundTag),
Domains = Utils.List2String((item.Domain ?? []).Concat(item.Ip ?? []).ToList()),
Domains = Utils.List2String(item.Domain),
Ips = Utils.List2String(item.Ip),
Enabled = item.Enabled,
Remarks = item.Remarks,
};

View file

@ -40,7 +40,6 @@ public partial class AddGroupServerWindow : WindowBase<AddGroupServerViewModel>
case EConfigType.PolicyGroup:
this.Title = ResUI.TbConfigTypePolicyGroup;
break;
case EConfigType.ProxyChain:
this.Title = ResUI.TbConfigTypeProxyChain;
gridPolicyGroup.IsVisible = false;
@ -116,22 +115,18 @@ public partial class AddGroupServerWindow : WindowBase<AddGroupServerViewModel>
ViewModel?.MoveServer(EMove.Top);
e.Handled = true;
break;
case Key.U:
ViewModel?.MoveServer(EMove.Up);
e.Handled = true;
break;
case Key.D:
ViewModel?.MoveServer(EMove.Down);
e.Handled = true;
break;
case Key.B:
ViewModel?.MoveServer(EMove.Bottom);
e.Handled = true;
break;
case Key.Delete:
ViewModel?.ChildRemoveAsync();
e.Handled = true;
@ -167,4 +162,5 @@ public partial class AddGroupServerWindow : WindowBase<AddGroupServerViewModel>
ViewModel.SelectedChildren = lstChild.SelectedItems.Cast<ProfileItem>().ToList();
}
}
}

View file

@ -31,6 +31,12 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
_config = AppManager.Instance.Config;
_manager = new WindowNotificationManager(TopLevel.GetTopLevel(this)) { MaxItems = 3, Position = NotificationPosition.TopRight };
if (_config.UiItem.AutoHideStartup)
{
this.ShowActivated = false;
this.WindowState = WindowState.Minimized;
}
this.KeyDown += MainWindow_KeyDown;
menuSettingsSetUWP.Click += menuSettingsSetUWP_Click;
menuPromotion.Click += menuPromotion_Click;
@ -178,11 +184,6 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
}
menuAddServerViaScan.IsVisible = false;
if (_config.UiItem.AutoHideStartup)
{
this.WindowState = WindowState.Minimized;
}
AddHelpMenuItem();
}

View file

@ -18,7 +18,7 @@
Margin="{StaticResource Margin4}"
ColumnDefinitions="Auto,Auto,Auto"
DockPanel.Dock="Top"
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto">
RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto">
<TextBlock
Grid.Row="0"
Grid.Column="0"
@ -32,57 +32,29 @@
Width="300"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" />
<StackPanel
<ToggleSwitch
x:Name="togEnabled"
Grid.Row="0"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Orientation="Horizontal">
<ToggleSwitch
x:Name="togEnabled"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
VerticalAlignment="Center" />
</StackPanel>
VerticalAlignment="Center" />
<TextBlock
Grid.Row="1"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbRuleType}" />
<ComboBox
x:Name="cmbRuleType"
Grid.Row="1"
Grid.Column="1"
Width="300"
Margin="{StaticResource Margin4}"
MaxDropDownHeight="1000" />
<TextBlock
Grid.Row="1"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Text="{x:Static resx:ResUI.TbRuleTypeTips}" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="outboundTag" />
<ComboBox
Name="cmbOutboundTag"
Grid.Row="2"
Grid.Row="1"
Grid.Column="1"
Width="300"
Margin="{StaticResource Margin4}"
IsEditable="True" />
<StackPanel
Grid.Row="2"
Grid.Row="1"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
@ -97,20 +69,20 @@
</StackPanel>
<TextBlock
Grid.Row="3"
Grid.Row="2"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="port" />
<TextBox
x:Name="txtPort"
Grid.Row="3"
Grid.Row="2"
Grid.Column="1"
Width="300"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="3"
Grid.Row="2"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
@ -118,21 +90,21 @@
Text="{x:Static resx:ResUI.TbRuleMatchingTips}" />
<TextBlock
Grid.Row="4"
Grid.Row="3"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="protocol" />
<ListBox
x:Name="clbProtocol"
Grid.Row="4"
Grid.Row="3"
Grid.Column="1"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
SelectionMode="Multiple,Toggle"
Theme="{DynamicResource CardCheckGroupListBox}" />
<TextBlock
Grid.Row="4"
Grid.Row="3"
Grid.Column="2"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center">
@ -142,20 +114,20 @@
</TextBlock>
<TextBlock
Grid.Row="5"
Grid.Row="4"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="inboundTag" />
<ListBox
x:Name="clbInboundTag"
Grid.Row="5"
Grid.Row="4"
Grid.Column="1"
Margin="{StaticResource Margin4}"
SelectionMode="Multiple,Toggle"
Theme="{DynamicResource CardCheckGroupListBox}" />
<TextBlock
Grid.Row="5"
Grid.Row="4"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
@ -163,20 +135,20 @@
Text="{x:Static resx:ResUI.TbRoutingInboundTagTips}" />
<TextBlock
Grid.Row="6"
Grid.Row="5"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Text="network" />
<ComboBox
x:Name="cmbNetwork"
Grid.Row="6"
Grid.Row="5"
Grid.Column="1"
Width="300"
Margin="{StaticResource Margin4}"
MaxDropDownHeight="1000" />
<TextBlock
Grid.Row="6"
Grid.Row="5"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"

View file

@ -28,7 +28,6 @@ public partial class RoutingRuleDetailsWindow : WindowBase<RoutingRuleDetailsVie
clbProtocol.ItemsSource = Global.RuleProtocols;
clbInboundTag.ItemsSource = Global.InboundTags;
cmbNetwork.ItemsSource = Global.RuleNetworks;
cmbRuleType.ItemsSource = Utils.GetEnumNames<ERuleType>().AppendEmpty();
if (!rulesItem.Id.IsNullOrEmpty())
{
@ -54,7 +53,6 @@ public partial class RoutingRuleDetailsWindow : WindowBase<RoutingRuleDetailsVie
this.Bind(ViewModel, vm => vm.IP, v => v.txtIP.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Process, v => v.txtProcess.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoSort, v => v.chkAutoSort.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.RuleType, v => v.cmbRuleType.SelectedValue).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
});

View file

@ -209,11 +209,7 @@
Binding="{Binding Remarks}"
Header="{x:Static resx:ResUI.LvRemarks}" />
<DataGridTextColumn
Width="100"
Binding="{Binding RuleTypeName}"
Header="{x:Static resx:ResUI.TbRuleType}" />
<DataGridTextColumn
Width="130"
Width="120"
Binding="{Binding OutboundTag}"
Header="outboundTag" />
<DataGridTextColumn
@ -229,13 +225,17 @@
Binding="{Binding InboundTags}"
Header="inboundTag" />
<DataGridTextColumn
Width="100"
Width="90"
Binding="{Binding Network}"
Header="network" />
<DataGridTextColumn
Width="*"
Binding="{Binding Domains}"
Header="domain / ip" />
Header="domain" />
<DataGridTextColumn
Width="*"
Binding="{Binding Ips}"
Header="ip" />
</DataGrid.Columns>
</DataGrid>
</TabItem>

View file

@ -25,6 +25,12 @@ public partial class MainWindow
_config = AppManager.Instance.Config;
ThreadPool.RegisterWaitForSingleObject(App.ProgramStarted, OnProgramStarted, null, -1, false);
if (_config.UiItem.AutoHideStartup)
{
this.ShowActivated = false;
this.WindowState = WindowState.Minimized;
}
App.Current.SessionEnding += Current_SessionEnding;
this.Closing += MainWindow_Closing;
this.PreviewKeyDown += MainWindow_PreviewKeyDown;
@ -158,10 +164,6 @@ public partial class MainWindow
});
this.Title = $"{Utils.GetVersion()} - {(Utils.IsAdministrator() ? ResUI.RunAsAdmin : ResUI.NotRunAsAdmin)}";
if (_config.UiItem.AutoHideStartup)
{
this.WindowState = WindowState.Minimized;
}
if (!_config.GuiItem.EnableHWA)
{

View file

@ -26,7 +26,6 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@ -49,19 +48,13 @@
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
Style="{StaticResource DefTextBox}" />
<StackPanel
<ToggleButton
x:Name="togEnabled"
Grid.Row="0"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Orientation="Horizontal">
<ToggleButton
x:Name="togEnabled"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
VerticalAlignment="Center" />
</StackPanel>
VerticalAlignment="Center" />
<TextBlock
Grid.Row="1"
@ -69,34 +62,10 @@
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbRuleType}" />
<ComboBox
x:Name="cmbRuleType"
Grid.Row="1"
Grid.Column="1"
Width="200"
Margin="{StaticResource Margin4}"
MaxDropDownHeight="1000"
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="1"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbRuleTypeTips}" />
<TextBlock
Grid.Row="2"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="outboundTag" />
<ComboBox
x:Name="cmbOutboundTag"
Grid.Row="2"
Grid.Row="1"
Grid.Column="1"
Width="200"
Margin="{StaticResource Margin4}"
@ -104,7 +73,7 @@
MaxDropDownHeight="1000"
Style="{StaticResource DefComboBox}" />
<StackPanel
Grid.Row="2"
Grid.Row="1"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
@ -123,7 +92,7 @@
</StackPanel>
<TextBlock
Grid.Row="3"
Grid.Row="2"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
@ -131,14 +100,14 @@
Text="port" />
<TextBox
x:Name="txtPort"
Grid.Row="3"
Grid.Row="2"
Grid.Column="1"
Width="200"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
Style="{StaticResource DefTextBox}" />
<TextBlock
Grid.Row="3"
Grid.Row="2"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
@ -147,7 +116,7 @@
Text="{x:Static resx:ResUI.TbRuleMatchingTips}" />
<TextBlock
Grid.Row="4"
Grid.Row="3"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
@ -155,14 +124,14 @@
Text="protocol" />
<ListBox
x:Name="clbProtocol"
Grid.Row="4"
Grid.Row="3"
Grid.Column="1"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
FontSize="{DynamicResource StdFontSize}"
Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" />
<TextBlock
Grid.Row="4"
Grid.Row="3"
Grid.Column="2"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
@ -174,7 +143,7 @@
</TextBlock>
<TextBlock
Grid.Row="5"
Grid.Row="4"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
@ -182,13 +151,13 @@
Text="inboundTag" />
<ListBox
x:Name="clbInboundTag"
Grid.Row="5"
Grid.Row="4"
Grid.Column="1"
Margin="{StaticResource Margin4}"
FontSize="{DynamicResource StdFontSize}"
Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" />
<TextBlock
Grid.Row="5"
Grid.Row="4"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"
@ -197,7 +166,7 @@
Text="{x:Static resx:ResUI.TbRoutingInboundTagTips}" />
<TextBlock
Grid.Row="6"
Grid.Row="5"
Grid.Column="0"
Margin="{StaticResource Margin4}"
VerticalAlignment="Center"
@ -205,7 +174,7 @@
Text="network" />
<ComboBox
x:Name="cmbNetwork"
Grid.Row="6"
Grid.Row="5"
Grid.Column="1"
Width="200"
Margin="{StaticResource Margin4}"
@ -213,7 +182,7 @@
Style="{StaticResource DefComboBox}" />
<TextBlock
Grid.Row="6"
Grid.Row="5"
Grid.Column="2"
Margin="{StaticResource Margin4}"
HorizontalAlignment="Left"

View file

@ -21,7 +21,6 @@ public partial class RoutingRuleDetailsWindow
clbProtocol.ItemsSource = Global.RuleProtocols;
clbInboundTag.ItemsSource = Global.InboundTags;
cmbNetwork.ItemsSource = Global.RuleNetworks;
cmbRuleType.ItemsSource = Utils.GetEnumNames<ERuleType>().AppendEmpty();
if (!rulesItem.Id.IsNullOrEmpty())
{
@ -46,7 +45,6 @@ public partial class RoutingRuleDetailsWindow
this.Bind(ViewModel, vm => vm.IP, v => v.txtIP.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.Process, v => v.txtProcess.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.AutoSort, v => v.chkAutoSort.IsChecked).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.RuleType, v => v.cmbRuleType.Text).DisposeWith(disposables);
this.BindCommand(ViewModel, vm => vm.SaveCmd, v => v.btnSave).DisposeWith(disposables);
});

View file

@ -301,11 +301,7 @@
Binding="{Binding Remarks}"
Header="{x:Static resx:ResUI.LvRemarks}" />
<DataGridTextColumn
Width="100"
Binding="{Binding RuleTypeName}"
Header="{x:Static resx:ResUI.TbRuleType}" />
<DataGridTextColumn
Width="130"
Width="120"
Binding="{Binding OutboundTag}"
Header="outboundTag" />
<DataGridTextColumn
@ -321,13 +317,17 @@
Binding="{Binding InboundTags}"
Header="inboundTag" />
<DataGridTextColumn
Width="100"
Width="90"
Binding="{Binding Network}"
Header="network" />
<DataGridTextColumn
Width="*"
Binding="{Binding Domains}"
Header="domain / ip" />
Header="domain" />
<DataGridTextColumn
Width="*"
Binding="{Binding Ips}"
Header="ip" />
</DataGrid.Columns>
</DataGrid>
</TabItem>